/**
  * Updates default values
  *
  * @param FormEvent $event
  */
 public function setDefaultValues(FormEvent $event)
 {
     /** @var WorkflowData $workflowData */
     $workflowData = $event->getData();
     foreach ($this->defaultValues as $attributeName => $value) {
         $workflowData->set($attributeName, $this->contextAccessor->getValue($this->workflowItem, $value));
     }
 }
 public function testGetValueNoSuchProperty()
 {
     $context = $this->createObject(array());
     $value = new PropertyPath('test');
     $propertyAccessor = $this->getMockBuilder('Symfony\\Component\\PropertyAccess\\PropertyAccessor')->disableOriginalConstructor()->setMethods(array('getValue'))->getMock();
     $propertyAccessor->expects($this->once())->method('getValue')->with($context, $value)->will($this->throwException(new NoSuchPropertyException('No such property')));
     $propertyAccessorReflection = new \ReflectionProperty('Oro\\Bundle\\WorkflowBundle\\Model\\ContextAccessor', 'propertyAccessor');
     $propertyAccessorReflection->setAccessible(true);
     $propertyAccessorReflection->setValue($this->contextAccessor, $propertyAccessor);
     $this->assertNull($this->contextAccessor->getValue($context, $value));
 }
Example #3
0
 /**
  * {@inheritDoc}
  */
 public function isAllowed($context, Collection $errors = null)
 {
     if (null !== $this->channel) {
         /** @var Channel $dataChannel */
         $dataChannel = $this->contextAccessor->getValue($context, $this->channel);
         $entities = $dataChannel->getEntities();
         $allowed = count(array_intersect($this->entities, $entities)) === count($this->entities);
     } else {
         $allowed = $this->stateProvider->isEntitiesEnabledInSomeChannel($this->entities);
     }
     return $allowed;
 }
Example #4
0
 /**
  * Check ACL for resource.
  *
  * @param mixed $context
  * @return boolean
  */
 protected function isConditionAllowed($context)
 {
     $attributes = $this->contextAccessor->getValue($context, $this->attributes);
     $objectOrClass = $this->contextAccessor->getValue($context, $this->objectOrClass);
     if (is_object($objectOrClass)) {
         $unitOfWork = $this->doctrineHelper->getEntityManager($objectOrClass)->getUnitOfWork();
         if (!$unitOfWork->isInIdentityMap($objectOrClass) || $unitOfWork->isScheduledForInsert($objectOrClass)) {
             $objectOrClass = 'Entity:' . $this->doctrineHelper->getEntityClass($objectOrClass);
         }
     }
     return $this->securityFacade->isGranted($attributes, $objectOrClass);
 }
 /**
  * @param array $options
  * @param mixed $context
  *
  * @dataProvider executeOptionsDataProvider
  */
 public function testExecute(array $options, $context)
 {
     $matched = new \stdClass();
     $this->automaticDiscovery->expects($this->once())->method('discoverSimilar')->willReturn($matched);
     $this->action->initialize($options);
     $this->action->execute($context);
     $this->assertSame($matched, $this->contextAccessor->getValue($context, new PropertyPath('attribute')));
 }
Example #6
0
 /**
  * @param mixed $context
  * @param mixed $identifier
  * @return mixed
  */
 protected function convertIdentifier($context, $identifier)
 {
     if (is_array($identifier)) {
         foreach ($identifier as $key => $value) {
             $identifier[$key] = $this->contextAccessor->getValue($context, $value);
         }
     } else {
         $identifier = $this->contextAccessor->getValue($context, $identifier);
     }
     return $identifier;
 }
Example #7
0
 /**
  * Returns TRUE is target is empty in context
  *
  * @param mixed $context
  * @return boolean
  */
 protected function isConditionAllowed($context)
 {
     $value = $this->contextAccessor->getValue($context, $this->target);
     return '' === $value || null === $value;
 }
 /**
  * {@inheritdoc}
  */
 protected function isConditionAllowed($context)
 {
     $type = $this->contextAccessor->getValue($context, $this->type);
     return (bool) $this->getActiveIntegration($type);
 }
 /**
  * Gets value of Workflow Item by path
  *
  * @param WorkflowItem $workflowItem
  * @param \Symfony\Component\PropertyAccess\PropertyPath $path
  * @return mixed
  */
 public function getValueByPropertyPath(WorkflowItem $workflowItem, $path)
 {
     return $this->contextAccessor->getValue($workflowItem, $path);
 }
Example #10
0
 /**
  * Check if values equals.
  *
  * @param mixed $context
  * @return boolean
  */
 protected function isConditionAllowed($context)
 {
     return $this->doCompare($this->contextAccessor->getValue($context, $this->left), $this->contextAccessor->getValue($context, $this->right));
 }