public function authorize($action, $config = array())
    {
        if (is_string($config)) {
            $config = array($action => $config);
        }

        $config = AnConfig::unbox($config);

        $context = $this->_mixer->getRepository()->getCommandContext();

        $context->append($config)->append(array(
            'viewer' => get_viewer(),
            'mixer' => $this->_mixer,
        ));

        $authorizers = $this->_authorizers;
        $result = LibBaseDomainAuthorizerAbstract::AUTH_NOT_IMPLEMENTED;

        foreach ($authorizers as $authorizer) {
            $result = $authorizer->execute($action, $context);
            if ($result !== LibBaseDomainAuthorizerAbstract::AUTH_NOT_IMPLEMENTED) {
                break;
            }
        }

        $context->authorization = $result;

        $method = 'authorize'.ucfirst($action);

        if (method_exists($this->_mixer, $method)) {
            $ret = $this->_mixer->$method($context);

            if (!is_null($ret)) {
                $context->authorization = $ret;
            }
        }

        return $context->authorization;
    }
public function authorize($action, $config = array())
    {
        if (is_string($config)) {
            $config = array($action => $config);
        }

        $config = AnConfig::unbox($config);

        $context = $this->_mixer->getRepository()->getCommandContext();

        $context->append($config)->append(array(
            'viewer' => get_viewer(),
            'mixer' => $this->_mixer,
        ));

        $authorizers = $this->_authorizers;
        $result = LibBaseDomainAuthorizerAbstract::AUTH_NOT_IMPLEMENTED;

        foreach ($authorizers as $authorizer) {
            $result = $authorizer->execute($action, $context);
            if ($result !== LibBaseDomainAuthorizerAbstract::AUTH_NOT_IMPLEMENTED) {
                break;
            }
        }

        $context->authorization = $result;

        $method = 'authorize'.ucfirst($action);

        if (method_exists($this->_mixer, $method)) {
            $ret = $this->_mixer->$method($context);

            if (!is_null($ret)) {
                $context->authorization = $ret;
            }
        }

        return $context->authorization;
    }
public function authorize ( $ action , $ config = array ( ) ) { if ( is_string ( $ config ) ) { $ config = array ( $ action => $ config ) ; } $ config = AnConfig :: unbox ( $ config ) ; $ context = $ this -> _mixer -> getRepository ( ) -> getCommandContext ( ) ; $ context -> append ( $ config ) -> append ( array ( 'viewer' => get_viewer ( ) , 'mixer' => $ this -> _mixer , ) ) ; $ authorizers = $ this -> _authorizers ; $ result = LibBaseDomainAuthorizerAbstract :: AUTH_NOT_IMPLEMENTED ; foreach ( $ authorizers as $ authorizer ) { $ result = $ authorizer -> execute ( $ action , $ context ) ; if ( $ result !== LibBaseDomainAuthorizerAbstract :: AUTH_NOT_IMPLEMENTED ) { break ; } } $ context -> authorization = $ result ; $ method = 'authorize' . ucfirst ( $ action ) ; if ( method_exists ( $ this -> _mixer , $ method ) ) { $ ret = $ this -> _mixer -> $ method ( $ context ) ; if ( ! is_null ( $ ret ) ) { $ context -> authorization = $ ret ; } } return $ context -> authorization ; }
Authorize an action and return true or false.

@param string $action The action name
@param array  $config An array of options to pass to the authorizers

@return bool
Authorize an action and return true or false .