validateLimitations() публичный Метод

Validates an array of Limitations.
public validateLimitations ( array $limitations ) : ValidationError[][]
$limitations array
Результат eZ\Publish\Core\FieldType\ValidationError[][]
Пример #1
0
 /**
  * Validates Policy context: Limitations on a module and function.
  *
  * @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException If the same limitation is repeated or if
  *                                                                   limitation is not allowed on module/function
  *
  * @param string $module
  * @param string $function
  * @param \eZ\Publish\API\Repository\Values\User\Limitation[] $limitations
  *
  * @return \eZ\Publish\Core\FieldType\ValidationError[][]
  */
 protected function validatePolicy($module, $function, array $limitations)
 {
     if ($module !== '*' && $function !== '*' && !empty($limitations)) {
         $limitationSet = array();
         foreach ($limitations as $limitation) {
             if (isset($limitationSet[$limitation->getIdentifier()])) {
                 throw new InvalidArgumentException('limitations', "'{$limitation->getIdentifier()}' was found several times among the limitations");
             }
             if (!isset($this->settings['policyMap'][$module][$function][$limitation->getIdentifier()])) {
                 throw new InvalidArgumentException('policy', "The limitation '{$limitation->getIdentifier()}' is not applicable on '{$module}/{$function}'");
             }
             $limitationSet[$limitation->getIdentifier()] = true;
         }
     }
     return $this->limitationService->validateLimitations($limitations);
 }