protected function checkPrivacyIntegrity(SaleItemInterface $item, SaleItem $constraint)
    {
        $parent = $item->getParent();

        if ($item->isPrivate()) {
            if (null === $parent) {
                // Level zero items must be public
                $this
                    ->context
                    ->buildViolation($constraint->root_item_cant_be_private)
                    ->atPath('private')
                    ->addViolation();

                throw new ValidationFailedException();
            } elseif ($item->getTaxGroup() !== $parent->getTaxGroup()) {
                // Tax group must match parent's one
                $this
                    ->context
                    ->buildViolation($constraint->tax_group_integrity)
                    ->atPath('taxGroup')
                    ->addViolation();

                throw new ValidationFailedException();
            }
        } elseif (null !== $parent && $parent->isPrivate()) {
            // Item with private parent must be private
            $this
                ->context
                ->buildViolation($constraint->privacy_integrity)
                ->atPath('private')
                ->addViolation();

            throw new ValidationFailedException();
        }
    }
protected function checkPrivacyIntegrity(SaleItemInterface $item, SaleItem $constraint)
    {
        $parent = $item->getParent();

        if ($item->isPrivate()) {
            if (null === $parent) {
                // Level zero items must be public
                $this
                    ->context
                    ->buildViolation($constraint->root_item_cant_be_private)
                    ->atPath('private')
                    ->addViolation();

                throw new ValidationFailedException();
            } elseif ($item->getTaxGroup() !== $parent->getTaxGroup()) {
                // Tax group must match parent's one
                $this
                    ->context
                    ->buildViolation($constraint->tax_group_integrity)
                    ->atPath('taxGroup')
                    ->addViolation();

                throw new ValidationFailedException();
            }
        } elseif (null !== $parent && $parent->isPrivate()) {
            // Item with private parent must be private
            $this
                ->context
                ->buildViolation($constraint->privacy_integrity)
                ->atPath('private')
                ->addViolation();

            throw new ValidationFailedException();
        }
    }
protected function checkPrivacyIntegrity ( SaleItemInterface $ item , SaleItem $ constraint ) { $ parent = $ item -> getParent ( ) ; if ( $ item -> isPrivate ( ) ) { if ( null === $ parent ) { // Level zero items must be public $ this -> context -> buildViolation ( $ constraint -> root_item_cant_be_private ) -> atPath ( 'private' ) -> addViolation ( ) ; throw new ValidationFailedException ( ) ; } elseif ( $ item -> getTaxGroup ( ) !== $ parent -> getTaxGroup ( ) ) { // Tax group must match parent's one $ this -> context -> buildViolation ( $ constraint -> tax_group_integrity ) -> atPath ( 'taxGroup' ) -> addViolation ( ) ; throw new ValidationFailedException ( ) ; } } elseif ( null !== $ parent && $ parent -> isPrivate ( ) ) { // Item with private parent must be private $ this -> context -> buildViolation ( $ constraint -> privacy_integrity ) -> atPath ( 'private' ) -> addViolation ( ) ; throw new ValidationFailedException ( ) ; } }
Checks the sale item privacy integrity.

@param SaleItemInterface $item
@param SaleItem          $constraint

@throws ValidationFailedException
Checks the sale item privacy integrity .