[英]Lithium Auth adapter, how to reach the Controller / Request?
I'm trying to build a Facebook
Auth adapter.我正在尝试构建一个Facebook
Auth 适配器。 Inside it, i need to get my hand on the Request
object to retreive request query parameters.在其中,我需要使用Request
object 来检索请求查询参数。
I've added this in my plugin bootstrap:我在我的插件引导程序中添加了这个:
<?php
use lithium\action\Dispatcher;
use facebook\extensions\adapter\security\auth\Facebook;
Dispatcher::applyFilter('_callable', function($self, $params, $chain) {
//debug(compact('self', 'params', 'chain'));
Facebook::$request = $params['request'];
// Always make sure to keep the filter chain going.
$response = $chain->next($self, $params, $chain);
return $response;
});
Then i have access to the $request in my Facebook class (under check()
for instance) using self::$request
.然后我可以使用self::$request
访问我的 Facebook class (例如在check()
下)中的 $request 。 But it seems wrong somehow.但这似乎是错误的。
Same situation when i try to redirect my user, i can't see how i can access a Controller & lithium\action\Controller::redirect()
is not static.同样的情况,当我尝试重定向我的用户时,我看不到如何访问 Controller 和lithium\action\Controller::redirect()
不是 static。
I'm new to this whole filter thing, can someone tell me that this is the correct implementation?我是整个过滤器的新手,有人可以告诉我这是正确的实现吗?
Quite simple finally, i just passed $this->request
as a parameter of the Auth::check, does the trick.最后很简单,我只是将$this->request
作为 Auth::check 的参数传递,就可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.