コード例 #1
0
 /**
  * @param mixed                               $subject
  * @param ConstraintValidatorFactoryInterface $constraintValidatorFactory
  * @param ExecutionContextInterface           $context
  * @param string                              $group
  */
 public function __construct($subject, ConstraintValidatorFactoryInterface $constraintValidatorFactory, ExecutionContextInterface $context, $group)
 {
     $this->subject = $subject;
     $this->context = $context;
     $this->group = $group;
     $this->constraintValidatorFactory = $constraintValidatorFactory;
     $this->current = '';
     $this->basePropertyPath = $this->context->getPropertyPath();
 }
コード例 #2
0
ファイル: ErrorElement.php プロジェクト: LamaDelRay/test_symf
 /**
  * @param mixed                                                     $subject
  * @param ConstraintValidatorFactoryInterface                       $constraintValidatorFactory
  * @param LegacyExecutionContextInterface|ExecutionContextInterface $context
  * @param string                                                    $group
  */
 public function __construct($subject, ConstraintValidatorFactoryInterface $constraintValidatorFactory, $context, $group)
 {
     if (!$context instanceof LegacyExecutionContextInterface && !$context instanceof ExecutionContextInterface) {
         throw new \InvalidArgumentException(sprintf('Argument 3 passed to %s::__construct() must be an instance of Symfony\\Component\\Validator\\ExecutionContextInterface or Symfony\\Component\\Validator\\Context\\ExecutionContextInterface.', get_class($this)));
     }
     $this->subject = $subject;
     $this->context = $context;
     $this->group = $group;
     $this->constraintValidatorFactory = $constraintValidatorFactory;
     $this->current = '';
     $this->basePropertyPath = $this->context->getPropertyPath();
 }
コード例 #3
0
ファイル: Vote.php プロジェクト: saberyounis/Sonata-Project
 /**
  * {@inheritdoc}
  */
 public function isVoteValid(ExecutionContextInterface $context)
 {
     if (!$this->checkValue($this->value)) {
         $message = 'A vote cannot have a 0 value';
         $propertyPath = $context->getPropertyPath() . '.value';
         $context->addViolationAt($propertyPath, $message);
     }
 }
コード例 #4
0
 function let(ProductManager $productManager, ExecutionContextInterface $context, Form $form, ProductInterface $product, ProductValueInterface $value)
 {
     $this->beConstructedWith($productManager);
     $product->getValue('sku')->willReturn($value);
     $form->getData()->willReturn($product);
     $context->getPropertyPath()->willReturn(self::PROPERTY_PATH);
     $context->getRoot()->willReturn($form);
     $this->initialize($context);
 }
コード例 #5
0
 function let(ProductRepositoryInterface $productRepository, UniqueValuesSet $uniqueValuesSet, ExecutionContextInterface $context, Form $form, ProductInterface $product, ProductValueInterface $value)
 {
     $this->beConstructedWith($productRepository, $uniqueValuesSet);
     $product->getValue('unique_attribute')->willReturn($value);
     $form->getData()->willReturn($product);
     $context->getPropertyPath()->willReturn(self::PROPERTY_PATH);
     $context->getRoot()->willReturn($form);
     $this->initialize($context);
 }
コード例 #6
0
ファイル: Vote.php プロジェクト: NonoXyde/FOSCommentBundle
 /**
  * {@inheritdoc}
  */
 public function isVoteValid(ExecutionContextInterface $context)
 {
     if (!$this->checkValue($this->value)) {
         $message = 'A vote cannot have a 0 value';
         $propertyPath = $context->getPropertyPath() . '.value';
         if ($context instanceof \Symfony\Component\Validator\Context\ExecutionContextInterface) {
             // Validator 2.5 API
             $context->buildViolation($message)->atPath($propertyPath)->addViolation();
         } else {
             $context->addViolationAt($propertyPath, $message);
         }
     }
 }
コード例 #7
0
 private function getRowData(ExecutionContextInterface $context)
 {
     $propertyPath = $context->getPropertyPath();
     $data = $this->getRowData($context);
 }