Cake\Controller\Component\AuthComponent::constructAuthenticate PHP Method

constructAuthenticate() public method

Loads the configured authentication objects.
public constructAuthenticate ( ) : array | null
return array | null The loaded authorization objects, or null on empty authenticate value.
    public function constructAuthenticate()
    {
        if (empty($this->_config['authenticate'])) {
            return null;
        }
        $this->_authenticateObjects = [];
        $authenticate = Hash::normalize((array) $this->_config['authenticate']);
        $global = [];
        if (isset($authenticate[AuthComponent::ALL])) {
            $global = $authenticate[AuthComponent::ALL];
            unset($authenticate[AuthComponent::ALL]);
        }
        foreach ($authenticate as $alias => $config) {
            if (!empty($config['className'])) {
                $class = $config['className'];
                unset($config['className']);
            } else {
                $class = $alias;
            }
            $className = App::className($class, 'Auth', 'Authenticate');
            if (!class_exists($className)) {
                throw new Exception(sprintf('Authentication adapter "%s" was not found.', $class));
            }
            if (!method_exists($className, 'authenticate')) {
                throw new Exception('Authentication objects must implement an authenticate() method.');
            }
            $config = array_merge($global, (array) $config);
            $this->_authenticateObjects[$alias] = new $className($this->_registry, $config);
            $this->eventManager()->on($this->_authenticateObjects[$alias]);
        }
        return $this->_authenticateObjects;
    }