Forums › Forums › OroPlatform › OroPlatform – Programming Questions › Error with acl
This topic contains 8 replies, has 2 voices, and was last updated by dimitri.seguin17 8 years, 5 months ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- October 22, 2015 at 8:53 am #33986
Hello, I would like to use acl annotation.
But I have an error
An exception has been thrown during the rendering of a template ("A single-valued association path expression to an inverse side is not supported in DQL queries.
Use an explicit join instead.") in /home/admin/www/crm/current/orocrm/vendor/oro/platform/src/Oro/Bundle/UIBundle/Resources/views/actions/index.html.twig at line 38.This is my controller
class WebContactController extends Controller
{
/**
* @Route("/", name="my_account_event_web_contact_index")
* @AclAncestor("event_web_contact_view")
* @Template()
*/
public function indexAction()
{
return [
'entity_class' => $this->container->getParameter('myaccount.webcontact.entity.class')
];
}
}acl.yml
event_web_contact_view:
type: entity
class: RcApiMyAccountBundle:WebContact
permission: VIEW
group_name: ""
bindings: ~
But I don’t know how to fix it. Do you any ideas ?
- CreatorTopic
- AuthorReplies
- October 22, 2015 at 11:23 am #33987
Hi, @dimitri-seguin17.
I’m afraid, but i think, in this case this error goes from your datagrid configuration, not from the ACL check.
Can you show your template for this action, datagrid configuration and entity structure?
October 22, 2015 at 11:40 pm #33988Hello,
This is my template for this action
{% extends "OroUIBundle:actions:index.html.twig" %}
{% import 'OroUIBundle::macros.html.twig' as UI %}{% set pageTitle = 'orocrm.myaccount.web_contact.entity_plural_label'|trans %}
{% set gridName = 'myaccount-webcontact-grid' %}{% block navButtons %}
{% include 'OroImportExportBundle:ImportExport:buttons.html.twig' with {
entity_class: entity_class,
dataGridName: gridName
} %}
{% endblock %}
my datagrid
datagrid:
myaccount-webcontact-grid:
source:
type: orm
query:
select:
- w.id_web_contact
- w.contact_date
- w.message
- w.object_id
- w.destination_id
- w.public
- w.ip
- w.user_agent
- w.mongo_id
- CONCAT(tourist.firstName, CONCAT(' ', tourist.lastName)) as touristName
- businessUnit.name as businessName
- account.id_account as accountId
from:
- { table: Rc\ApiMyAccountBundle\Entity\WebContact , alias: w }
join:
left:
- { join: w.tourist, alias: tourist }
- { join: w.business_unit, alias: businessUnit }
- { join: w.account, alias: account }
columns:
contact_date:
label: orocrm.myaccount.web_contact.contact_date.label
frontend_type: datetime
message:
label: orocrm.myaccount.web_contact.message.label
object_id:
label: orocrm.myaccount.object_id.label
touristName:
label: orocrm.myaccount.tourist.label
sorters:
columns:
contact_date: { data_name: w.contact_date }
touristName: { data_name: touristName }
object_id: { data_name: w.object_id}
default:
contact_date: DESC
filters:
columns:
contact_date:
type: datetime
data_name: w.contact_date
message:
type: string
data_name: w.message
touristName:
type: string
data_name: touristName
options:
entityHint: webContact
export: true
entity_pagination: true
and my entity
<?phpnamespace Rc\ApiMyAccountBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;use JMS\Serializer\Annotation\Exclude;
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config;
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\ConfigField;
use Oro\Bundle\OrganizationBundle\Entity\BusinessUnit;use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="Rc\ApiMyAccountBundle\Entity\Repository\WebContactRepository")
* @ORM\Table(name="rc_web_contact", uniqueConstraints={@ORM\UniqueConstraint(name="unique_idx", columns={"mongo_id"})})
* @Config(
* routeView="my_account_event_web_contact_index",
* routeView="my_account_event_web_contact_view",
* defaultValues={
* "entity"={
* "label"="Web contact"
* },
* "form"={
* "grid_name"="myaccount-webcontact-grid",
* },
* "ownership"={
* "owner_type"="BUSINESS_UNIT",
* "owner_field_name"="owner",
* "owner_column_name"="business_unit_owner_id",
* "organization_field_name"="organization",
* "organization_column_name"="organization_id"
* },
* "security"={
* "type"="ACL",
* "permissions"="ALL"
* }
* }
* )
*/
class WebContact
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @ConfigField(
* defaultValues={
* "entity"={
* "label"="Web contact id"
* }
* }
* )
*/
private $id_web_contact;/**
* @var \DateTime
*
* @ORM\Column(type="datetime")
* @ConfigField(
* defaultValues={
* "entity"={
* "label"="Contact date"
* }
* }
* )
*/
private $contact_date;/**
* @var string
*
* @ORM\Column(type="string", length=1000)
* @ConfigField(
* defaultValues={
* "entity"={
* "label"="Message"
* }
* }
* )
*/
private $message;/**
* @var \DateTime
*
* @ORM\Column(type="datetime", nullable=true)
* @ConfigField(
* defaultValues={
* "entity"={
* "label"="Stay end date"
* }
* }
* )
*/
private $stay_end_date;/**
* @var \DateTime
*
* @ORM\Column(type="datetime", nullable=true)
* @ConfigField(
* defaultValues={
* "entity"={
* "label"="Stay start date"
* }
* }
* )
*/
private $stay_start_date;/**
* @var string
*
* @ORM\Column(type="string", length=255, nullable=true)
* @ConfigField(
* defaultValues={
* "entity"={
* "label"="Object id"
* }
* }
* )
*/
private $object_id;/**
* @var string
*
* @ORM\Column(type="string", length=255)
* @ConfigField(
* defaultValues={
* "entity"={
* "label"="Destination id"
* }
* }
* )
*/
private $destination_id;/**
* @var boolean
*
* @ORM\Column(type="boolean")
* @ConfigField(
* defaultValues={
* "entity"={
* "label"="Public"
* }
* }
* )
*/
private $public;/**
* @var string
*
* @ORM\Column(type="string", length=255, nullable=true)
* @ConfigField(
* defaultValues={
* "entity"={
* "label"="Ip"
* }
* }
* )
*/
private $ip;/**
* @var string
*
* @ORM\Column(type="string", length=255, nullable=true)
* @ConfigField(
* defaultValues={
* "entity"={
* "label"="User agent"
* }
* }
* )
*/
private $user_agent;/**
* @var string
*
* @ORM\Column(type="string", length=255)
* @ConfigField(
* defaultValues={
* "entity"={
* "label"="Mongo id"
* }
* }
* )
*/
private $mongo_id;/**
* @var \DateTime
*
* @ORM\Column(type="datetime")
* @ConfigField(
* defaultValues={
* "entity"={
* "label"="Creation date"
* }
* }
* )
*/
private $created;/**
* @var Tourist
*
* @ORM\ManyToOne(targetEntity="Tourist", inversedBy="web_contacts")
* @ORM\JoinColumn(name="id_tourist", referencedColumnName="id")
* @ConfigField(
* defaultValues={
* "entity"={
* "label"="Tourist id"
* }
* }
* )
*/
private $tourist;/**
* @var BusinessUnit
*
* @ORM\ManyToOne(targetEntity="\Oro\Bundle\OrganizationBundle\Entity\BusinessUnit")
* @ORM\JoinColumn(name="id_business_unit", referencedColumnName="id")
* @ConfigField(
* defaultValues={
* "entity"={
* "label"="Business unit id"
* }
* }
* )
*/
private $business_unit;/**
* @var Account
*
* @ORM\ManyToOne(targetEntity="Account", inversedBy="web_contacts")
* @ORM\JoinColumn(name="id_account", referencedColumnName="id_account")
* @ConfigField(
* defaultValues={
* "entity"={
* "label"="Account id"
* }
* }
* )
*/
private $account;/** @var string */
private $event_type = 'contacted';/** @var string */
private $website_uid = '';/** @var string */
private $mobile_uid = '';/** @var string */
private $user_id = '';/** @var \Datetime */
private $inserted = null;/** @var array */
private $parameters_contacted;/**
* @return mixed
*/
public function getEventType()
{
return $this->event_type;
}/**
* @param mixed $event_type
*/
public function setEventType($event_type)
{
$this->event_type = $event_type;
}/**
* @return \DateTime
*/
public function getContactDate()
{
return $this->contact_date;
}/**
* @param \DateTime $contact_date
*/
public function setContactDate($contact_date)
{
$this->contact_date = $contact_date;
}/**
* @return mixed
*/
public function getId()
{
return $this->id_web_contact;
}/**
* @param mixed $id_web_contact
*/
public function setId($id_web_contact)
{
$this->id_web_contact = $id_web_contact;
}/**
* @return string
*/
public function getDestinationId()
{
return $this->destination_id;
}/**
* @param string $destination_id
*/
public function setDestinationId($destination_id)
{
$this->destination_id = $destination_id;
}/**
* @return string
*/
public function getIp()
{
return $this->ip;
}/**
* @param string $ip
*/
public function setIp($ip)
{
$this->ip = $ip;
}/**
* @return string
*/
public function getMongoId()
{
return $this->mongo_id;
}/**
* @param string $mongo_id
*/
public function setMongoId($mongo_id)
{
$this->mongo_id = $mongo_id;
}/**
* @return string
*/
public function getObjectId()
{
return $this->object_id;
}/**
* @param string $object_id
*/
public function setObjectId($object_id)
{
$this->object_id = $object_id;
}/**
* @return boolean
*/
public function isPublic()
{
return $this->public;
}/**
* @param boolean $public
*/
public function setPublic($public)
{
$this->public = $public;
}/**
* @return string
*/
public function getUserAgent()
{
return $this->user_agent;
}/**
* @param string $user_agent
*/
public function setUserAgent($user_agent)
{
$this->user_agent = $user_agent;
}/**
* @return \Oro\Bundle\OrganizationBundle\Entity\BusinessUnit
*/
public function getBusinessUnit()
{
return $this->business_unit;
}/**
* @param \Oro\Bundle\OrganizationBundle\Entity\BusinessUnit $id_business_unit
*/
public function setBusinessUnit($id_business_unit)
{
$this->business_unit = $id_business_unit;
}/**
* @return Tourist
*/
public function getTourist()
{
return $this->tourist;
}/**
* @param Tourist $tourist
*/
public function setTourist($tourist)
{
$this->tourist = $tourist;
}/**
* @return string
*/
public function getWebsiteUid()
{
return $this->website_uid;
}/**
* @param string $website_uid
*/
public function setWebsiteUid($website_uid)
{
$this->website_uid = $website_uid;
}/**
* @return string
*/
public function getMobileUid()
{
return $this->mobile_uid;
}/**
* @param string $mobile_uid
*/
public function setMobileUid($mobile_uid)
{
$this->mobile_uid = $mobile_uid;
}/**
* @return string
*/
public function getUserId()
{
return $this->user_id;
}/**
* @param string $user_id
*/
public function setUserId($user_id)
{
$this->user_id = $user_id;
}/**
* @return array
*/
public function getParametersContacted()
{
return $this->parameters_contacted;
}/**
* @param array $parameters_contacted
*/
public function setParametersContacted($parameters_contacted)
{
$this->parameters_contacted = $parameters_contacted;
}/**
* @return Account
*/
public function getAccount()
{
return $this->account;
}/**
* @param Account $account
*/
public function setAccount($account)
{
$this->account = $account;
}/**
* @return string
*/
public function getMessage()
{
return $this->message;
}/**
* @param string $message
*/
public function setMessage($message)
{
$this->message = $message;
}/**
* @return \Datetime
*/
public function getInserted()
{
return $this->inserted;
}/**
* @param \Datetime $inserted
*/
public function setInserted($inserted)
{
$this->inserted = $inserted;
}/**
* @return \DateTime
*/
public function getCreated()
{
return $this->created;
}/**
* @param \DateTime $created
*/
public function setCreated($created)
{
$this->created = $created;
}/**
* @return \DateTime
*/
public function getStayEndDate()
{
return $this->stay_end_date;
}/**
* @param \DateTime $stay_end_date
*/
public function setStayEndDate($stay_end_date)
{
$this->stay_end_date = $stay_end_date;
}/**
* @return \DateTime
*/
public function getStayStartDate()
{
return $this->stay_start_date;
}/**
* @param \DateTime $stay_start_date
*/
public function setStayStartDate($stay_start_date)
{
$this->stay_start_date = $stay_start_date;
}public function getOrganization() {}
public function setOrganization() {}
}
October 23, 2015 at 5:18 am #33989And is it allowed to use many times the same acl (here “event_web_contact_view”) ?
October 26, 2015 at 3:42 am #33990Hello,
I look it’s a acl problem.
When I log
array (
'doctrine.customTreeWalkers' =>
array (
0 => 'Oro\\Bundle\\SecurityBundle\\ORM\\Walker\\AclWalker',
),
'oro_acl.condition' =>
Oro\Bundle\SecurityBundle\ORM\Walker\Condition\AclConditionStorage::__set_state(array(
'whereConditions' =>
array (
0 =>
Oro\Bundle\SecurityBundle\ORM\Walker\Condition\AclCondition::__set_state(array(
'entityAlias' => 'w',
'entityField' => NULL,
'value' => NULL,
'pathExpressionType' => NULL,
'organizationField' => 'organization',
'organizationValue' => 1,
'ignoreOwner' => true,
)),
),
'joinConditions' =>
array (
),
'subRequests' => NULL,
)),
)It’s a serious problem, it blocks me for my development.
October 26, 2015 at 4:01 am #33991Hi, @dimitri-seguin17.
Your entity is not correct.You have ownership config:
123456789* "ownership"={* "owner_type"="BUSINESS_UNIT",* "owner_field_name"="owner",* "owner_column_name"="business_unit_owner_id",* "organization_field_name"="organization",* "organization_column_name"="organization_id"* },But:
- Your entity have no owner field but you have business_unit field. You should change owner_field_name parameter to business_unit or rename business_unit field to owner.
- Your entity have no organization relation. You should add it.
October 26, 2015 at 7:26 am #33992Thank’s for your reply.
I replace owner by businuess_unit
* "ownership"={
* "owner_type"="BUSINESS_UNIT",
* "owner_field_name"="business_unit",
* "owner_column_name"="id_business_unit",
* "organization_field_name"="organization",
* "organization_column_name"="organization_id"
* },
but it’s possible to delete organization_field_name and organization_column_name or it’s mandatory ?
October 26, 2015 at 8:35 am #33993Hi, @dimitri-seguin17.
Unfortunately, organization field is mandatory and your entity should have real relation to organization entity with this field.October 27, 2015 at 1:05 am #33994Ok thank’s for your reply, the application is ok now.
- AuthorReplies
The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.