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

storage() public method

Get/set user record storage object.
public storage ( Cake\Auth\Storage\StorageInterface $storage = null ) : Cake\Auth\Storage\StorageInterface | null
$storage Cake\Auth\Storage\StorageInterface Sets provided object as storage or if null returns configured storage object.
return Cake\Auth\Storage\StorageInterface | null
    public function storage(StorageInterface $storage = null)
    {
        if ($storage !== null) {
            $this->_storage = $storage;
            return null;
        }
        if ($this->_storage) {
            return $this->_storage;
        }
        $config = $this->_config['storage'];
        if (is_string($config)) {
            $class = $config;
            $config = [];
        } else {
            $class = $config['className'];
            unset($config['className']);
        }
        $className = App::className($class, 'Auth/Storage', 'Storage');
        if (!class_exists($className)) {
            throw new Exception(sprintf('Auth storage adapter "%s" was not found.', $class));
        }
        $this->_storage = new $className($this->request, $this->response, $config);
        return $this->_storage;
    }