Prado\Security\TAuthManager::init PHP Method

init() public method

This method is required by the IModule interface.
public init ( $config )
    public function init($config)
    {
        if ($this->_userManager === null) {
            throw new TConfigurationException('authmanager_usermanager_required');
        }
        if ($this->_returnUrlVarName === null) {
            $this->_returnUrlVarName = $this->getApplication()->getID() . ':' . self::RETURN_URL_VAR;
        }
        $application = $this->getApplication();
        if (is_string($this->_userManager)) {
            if (($users = $application->getModule($this->_userManager)) === null) {
                throw new TConfigurationException('authmanager_usermanager_inexistent', $this->_userManager);
            }
            if (!$users instanceof IUserManager) {
                throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager);
            }
            $this->_userManager = $users;
        }
        $application->attachEventHandler('OnAuthentication', array($this, 'doAuthentication'));
        $application->attachEventHandler('OnEndRequest', array($this, 'leave'));
        $application->attachEventHandler('OnAuthorization', array($this, 'doAuthorization'));
        $this->_initialized = true;
    }

Usage Example

示例#1
0
 public function testDoAuthentication()
 {
     throw new PHPUnit_Framework_IncompleteTestError();
     // Not yet finished, Session won't start because of headers :( :(
     $authManager = new TAuthManager();
     $authManager->setUserManager('users');
     $authManager->init(null);
     $authManager->setLoginPage('LoginPage');
     self::$app->raiseEvent('onAuthentication', self::$app, null);
 }