Programming Language PHP
Namespace Oro\Bundle\WorkflowBundle\Entity
Class WorkflowItem
Method/Function setRestrictionIdentities
Total Examples 1
1 code examples of PHP Oro\Bundle\WorkflowBundle\Entity\WorkflowItem::setRestrictionIdentities extracted from open source projects
/**
* @throws WorkflowException
*/
public function updateEntityRestrictions(WorkflowItem $workflowItem): WorkflowItem
{
$definition = $workflowItem->getDefinition();
$currentStepName = $workflowItem->getCurrentStep()->getName();
$restrictionIdentities = [];
foreach ($definition->getRestrictions() as $restriction) {
if ($restriction->getStep() && $restriction->getStep()->getName() === $currentStepName) {
$attributeName = $restriction->getAttribute();
$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));
}
$restrictionIdentity = new WorkflowRestrictionIdentity();
$restrictionIdentity->setRestriction($restriction)
->setEntityId($this->doctrineHelper->getSingleEntityIdentifier($entity));
$restrictionIdentities[] = $restrictionIdentity;
}
}
$workflowItem->setRestrictionIdentities($restrictionIdentities);
return $workflowItem;
}