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');
}
$location = $this->persistence->locationHandler()->load($target->parentLocationId);
$contentTypeId = $this->persistence->contentHandler()->loadContentInfo($location->contentId)->contentTypeId;
if (!in_array($contentTypeId, $value->limitationValues)) {
return false;
}
}
return true;
}