我如何在 class 中加载一个扩展 CakePHP 中的 BaseAuthenticate 的组件?

How do I load a component inside a class that extends BaseAuthenticate in CakePHP?

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

class OauthAuthenticate extends BaseAuthenticate

我想在 OauthAuthenticate class.

中使用自定义组件(从 Component 扩展而来)

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

public $components = array('OauthAuthenticate');

不起作用 - 组件未加载。

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

private $utilComponent = null;

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