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

_setDefaults() protected method

Sets defaults for configs.
protected _setDefaults ( ) : void
return void
    protected function _setDefaults()
    {
        $defaults = ['authenticate' => ['Form'], 'flash' => ['element' => 'default', 'key' => 'auth', 'params' => ['class' => 'error']], 'loginAction' => ['controller' => 'Users', 'action' => 'login', 'plugin' => null], 'logoutRedirect' => $this->_config['loginAction'], 'authError' => __d('cake', 'You are not authorized to access that location.')];
        $config = $this->config();
        foreach ($config as $key => $value) {
            if ($value !== null) {
                unset($defaults[$key]);
            }
        }
        $this->config($defaults);
    }

Usage Example

 /**
  * Sets defaults for configs.
  *
  * @return void
  */
 protected function _setDefaults()
 {
     parent::_setDefaults();
     if ($this->config('verifyAction') === null) {
         $this->config('verifyAction', ['controller' => 'TwoFactorAuth', 'action' => 'verify', 'plugin' => 'TwoFactorAuth', 'prefix' => false]);
     }
 }