src/Zicht/Bundle/PageBundle/Validator/Constraints/ContentItemMatrixValidator.php
public function validate($value, Constraint $constraint)
    {
        /** @var \Zicht\Bundle\PageBundle\Model\ContentItemMatrix $matrix */
        $matrix = $value->getContentItemMatrix();

        if (null !== $matrix) {
            /**
             * @var int $i
             * @var ContentItem $contentItem
             */
            foreach ($value->getContentItems() as $i => $contentItem) {
                $type = get_class($contentItem);

                if (!in_array($contentItem->getRegion(), $matrix->getRegions($type))) {
                    $message = $this->translator->trans('content_item.invalid.region_type_combination', ['%region%' => $contentItem->getRegion(), '%type%' => $type], 'validators');
                    $this->context->buildViolation($message)
                        ->atPath(sprintf('contentItems[%d]', $i))
                        ->addViolation();
                }
            }
        }
    }
public function validate($value, Constraint $constraint)
    {
        /** @var \Zicht\Bundle\PageBundle\Model\ContentItemMatrix $matrix */
        $matrix = $value->getContentItemMatrix();

        if (null !== $matrix) {
            /**
             * @var int $i
             * @var ContentItem $contentItem
             */
            foreach ($value->getContentItems() as $i => $contentItem) {
                $type = get_class($contentItem);

                if (!in_array($contentItem->getRegion(), $matrix->getRegions($type))) {
                    $message = $this->translator->trans('content_item.invalid.region_type_combination', ['%region%' => $contentItem->getRegion(), '%type%' => $type], 'validators');
                    $this->context->buildViolation($message)
                        ->atPath(sprintf('contentItems[%d]', $i))
                        ->addViolation();
                }
            }
        }
    }
public function validate ( $ value , Constraint $ constraint ) { /** @var \Zicht\Bundle\PageBundle\Model\ContentItemMatrix $matrix */ $ matrix = $ value -> getContentItemMatrix ( ) ; if ( null !== $ matrix ) { /**
             * @var int $i
             * @var ContentItem $contentItem
             */ foreach ( $ value -> getContentItems ( ) as $ i => $ contentItem ) { $ type = get_class ( $ contentItem ) ; if ( ! in_array ( $ contentItem -> getRegion ( ) , $ matrix -> getRegions ( $ type ) ) ) { $ message = $ this -> translator -> trans ( 'content_item.invalid.region_type_combination' , [ '%region%' => $ contentItem -> getRegion ( ) , '%type%' => $ type ] , 'validators' ) ; $ this -> context -> buildViolation ( $ message ) -> atPath ( sprintf ( 'contentItems[%d]' , $ i ) ) -> addViolation ( ) ; } } } }
Validate

@param mixed $value
@param Constraint $constraint
Validate