protected evaluateForContentCreateStruct ( eZ\Publish\API\Repository\Values\User\Limitation $value, array $targets ) : boolean | ||
$value | eZ\Publish\API\Repository\Values\User\Limitation | |
$targets | array | |
return | boolean |
protected function evaluateForContentCreateStruct(APILimitationValue $value, array $targets)
{
// 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');
}
$target = $this->persistence->locationHandler()->load($target->parentLocationId);
// For ContentCreateStruct all placements must match
foreach ($value->limitationValues as $limitationPathString) {
if ($target->pathString === $limitationPathString) {
continue 2;
}
if (strpos($target->pathString, $limitationPathString) === 0) {
continue 2;
}
}
return false;
}
return true;
}