eZ\Publish\Core\Limitation\ParentDepthLimitationType::evaluateForContentCreateStruct PHP Method

evaluateForContentCreateStruct() protected method

Evaluate permissions for ContentCreateStruct against LocationCreateStruct placements.
protected evaluateForContentCreateStruct ( eZ\Publish\API\Repository\Values\User\Limitation $value, array $targets = null ) : boolean
$value eZ\Publish\API\Repository\Values\User\Limitation
$targets array
return boolean
    protected function evaluateForContentCreateStruct(APILimitationValue $value, array $targets = null)
    {
        // If targets is empty/null return false as user does not have access
        // to content w/o location with this limitation
        if (empty($targets)) {
            return false;
        }
        foreach ($targets as $target) {
            if (!$target instanceof LocationCreateStruct) {
                throw new InvalidArgumentException('$targets', 'If $object is ContentCreateStruct must contain objects of type: LocationCreateStruct');
            }
            $depth = $this->persistence->locationHandler()->load($target->parentLocationId)->depth;
            // All placements must match
            if (!in_array($depth, $value->limitationValues)) {
                return false;
            }
        }
        return true;
    }