Authentication 如何在CakePHP中扩展BaseAuthenticate的类中加载组件?

Authentication 如何在CakePHP中扩展BaseAuthenticate的类中加载组件?,authentication,cakephp,components,cakephp-2.x,cakephp-2.7,Authentication,Cakephp,Components,Cakephp 2.x,Cakephp 2.7,我创建了自己的身份验证器,用于处理OAuth 2: class OauthAuthenticate extends BaseAuthenticate 我想在我的OauthAuthenticate类中使用自定义组件(从组件扩展而来) 如何在那里加载我的组件?传统的 public $components = array('OauthAuthenticate'); 不工作-未加载组件。BaseAuthenticate类无法像在控制器中一样通过$components数组加载组件,但可以在构造函数中加

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

class OauthAuthenticate extends BaseAuthenticate
我想在我的
OauthAuthenticate
类中使用自定义组件(从
组件扩展而来)

如何在那里加载我的组件?传统的

public $components = array('OauthAuthenticate');

不工作-未加载组件。

BaseAuthenticate
类无法像在控制器中一样通过
$components
数组加载组件,但可以在构造函数中加载组件:

private $utilComponent = null;

    public function __construct(ComponentCollection $collection, array $settings)
    {
        $this->utilComponent = $collection->load('Util');
    }

例如,组件可以在另一个组件中使用。让downvoter解释此解决方案的错误。请参阅CakePHP文档-