예제 #1
0
 /**
  * @param mixed $context
  * @return bool
  */
 protected function isAllowed($context)
 {
     if (!$this->condition) {
         return true;
     }
     return $this->condition->evaluate($context) ? true : false;
 }
 /**
  * {@inheritdoc}
  */
 public function startVisit(VisitContext $visitContext)
 {
     $writer = $visitContext->createWriter();
     $class = $visitContext->getClass();
     $class->addInterfaceName('Oro\\Component\\ConfigExpression\\ExpressionFactoryAwareInterface');
     $setFactoryMethod = PhpMethod::create('setExpressionFactory');
     $setFactoryMethod->addParameter(PhpParameter::create('expressionFactory')->setType('Oro\\Component\\ConfigExpression\\ExpressionFactoryInterface'));
     $setFactoryMethod->setBody($writer->write('$this->expressionFactory = $expressionFactory;')->getContent());
     $class->setMethod($setFactoryMethod);
     $factoryProperty = PhpProperty::create('expressionFactory');
     $factoryProperty->setVisibility(PhpProperty::VISIBILITY_PRIVATE);
     $class->setProperty($factoryProperty);
     $visitContext->getUpdateMethodWriter()->writeln('if (null === $this->expressionFactory) {')->writeln('    throw new \\RuntimeException(\'Missing expression factory for layout update\');')->writeln('}')->writeln('')->writeln(sprintf('$expr = %s;', $this->expression->compile('$this->expressionFactory')))->writeln(sprintf('$context = [\'context\' => $%s->getContext()];', LayoutUpdateGeneratorInterface::PARAM_LAYOUT_ITEM))->writeln('if ($expr->evaluate($context)) {')->indent();
 }
예제 #3
0
 /**
  * Check is transition pre condition is allowed for current workflow item.
  *
  * @param WorkflowItem $workflowItem
  * @param Collection|null $errors
  * @return boolean
  */
 protected function isPreConditionAllowed(WorkflowItem $workflowItem, Collection $errors = null)
 {
     if (!$this->preCondition) {
         return true;
     }
     return $this->preCondition->evaluate($workflowItem, $errors) ? true : false;
 }
예제 #4
0
파일: Not.php 프로젝트: ramunasd/platform
 /**
  * {@inheritdoc}
  */
 protected function isConditionAllowed($context)
 {
     return !$this->operand->evaluate($context, $this->errors);
 }
 /**
  * @param ExpressionInterface   $expr
  * @param ContextInterface      $context
  * @param DataAccessorInterface $data
  * @param bool                  $evaluate
  * @param string                $encoding
  *
  * @return mixed|string
  */
 protected function processExpression(ExpressionInterface $expr, ContextInterface $context, DataAccessorInterface $data, $evaluate, $encoding)
 {
     return $evaluate ? $expr->evaluate(['context' => $context, 'data' => $data]) : $this->encoderRegistry->getEncoder($encoding)->encodeExpr($expr);
 }
 /**
  * {@inheritdoc}
  */
 public function encodeExpr(ExpressionInterface $expr)
 {
     return json_encode($expr->toArray());
 }