0
我写了一个组件,如下所示。调用控制器中的组件构造函数
class GoogleApiComponent extends Component {
function __construct($approval_prompt) {
$this->client = new apiClient();
$this->client->setApprovalPrompt(Configure::read('approvalPrompt'));
}
}
我在AppController的$ components变量中调用它。 然后我写了UsersController如下。
class UsersController extends AppController {
public function oauth_call_back() {
}
}
所以在oauth_call_back行动我想创建GoogleApiComponent的对象,也称带参数的构造。 如何在CakePHP 2.1中做到这一点?