Programming Language PHP
Namespace Oro\Bundle\WorkflowBundle\Entity
Class WorkflowItem
Method/Function setAclIdentities
Total Examples 1
1 code examples of PHP Oro\Bundle\WorkflowBundle\Entity\WorkflowItem::setAclIdentities extracted from open source projects
/**
* @throws WorkflowException
*/
public function updateAclIdentities(WorkflowItem $workflowItem): WorkflowItem
{
$workflow = $this->workflowRegistry->getWorkflow($workflowItem->getWorkflowName());
$definition = $workflowItem->getDefinition();
$currentStepName = $workflowItem->getCurrentStep()->getName();
$aclIdentities = [];
foreach ($definition->getEntityAcls() as $entityAcl) {
if ($entityAcl->getStep()->getName() == $currentStepName) {
$attributeName = $entityAcl->getAttribute();
$attribute = $workflow->getAttributeManager()->getAttribute($attributeName);
$entity = $workflowItem->getData()->get($attributeName);
if (!$entity) {
continue;
}
if (!is_object($entity)) {
throw new WorkflowException(sprintf('Value of attribute "%s" must be an object', $attributeName));
}
$aclIdentity = new WorkflowEntityAclIdentity();
$aclIdentity->setAcl($entityAcl)
->setEntityClass($attribute->getOption('class'))
->setEntityId($this->doctrineHelper->getSingleEntityIdentifier($entity));
$aclIdentities[] = $aclIdentity;
}
}
$workflowItem->setAclIdentities($aclIdentities);
return $workflowItem;
}