Cake\Controller\Component\AuthComponent::constructAuthorize PHP Метод

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

Loads the authorization objects configured.
public constructAuthorize ( ) : array | null
Результат array | null The loaded authorization objects, or null when authorize is empty.
    public function constructAuthorize()
    {
        if (empty($this->_config['authorize'])) {
            return null;
        }
        $this->_authorizeObjects = [];
        $authorize = Hash::normalize((array) $this->_config['authorize']);
        $global = [];
        if (isset($authorize[AuthComponent::ALL])) {
            $global = $authorize[AuthComponent::ALL];
            unset($authorize[AuthComponent::ALL]);
        }
        foreach ($authorize as $alias => $config) {
            if (!empty($config['className'])) {
                $class = $config['className'];
                unset($config['className']);
            } else {
                $class = $alias;
            }
            $className = App::className($class, 'Auth', 'Authorize');
            if (!class_exists($className)) {
                throw new Exception(sprintf('Authorization adapter "%s" was not found.', $class));
            }
            if (!method_exists($className, 'authorize')) {
                throw new Exception('Authorization objects must implement an authorize() method.');
            }
            $config = (array) $config + $global;
            $this->_authorizeObjects[$alias] = new $className($this->_registry, $config);
        }
        return $this->_authorizeObjects;
    }