0

我创建了自己的身份验证器来处理 OAuth 2:

class OauthAuthenticate extends BaseAuthenticate

我想Component在我的OauthAuthenticate课堂上使用一个自定义组件(从 扩展)。

我怎样才能在那里加载我的组件?传统的

public $components = array('OauthAuthenticate');

不起作用 - 组件未加载。

4

1 回答 1

0

BaseAuthenticate类不能$components像在控制器中通常那样通过数组加载组件,但可以在构造函数中加载组件:

private $utilComponent = null;

    public function __construct(ComponentCollection $collection, array $settings)
    {
        $this->utilComponent = $collection->load('Util');
    }
于 2016-01-18T20:37:50.753 回答