예제 #1
0
파일: Config.php 프로젝트: techart/tao
 /**
  * Выполняет обработку запроса
  *
  * @param WS_Environment $env
  *
  * @return mixed
  */
 public function run(WS_Environment $env)
 {
     $config = Config::all();
     $env->assign_if(array('config' => $config));
     Events::call('ws.config', $config);
     return $this->application->run($env);
 }
예제 #2
0
파일: OpenId.php 프로젝트: techart/tao
 /**
  * Выполняет обработку запроса
  *
  * @param WS_Environment $env
  *
  * @return mixed
  */
 public function run(WS_Environment $env)
 {
     $this->env = $env;
     if (!isset($env->openid)) {
         $env->openid(new stdClass());
     }
     $request = $env->request;
     $this->client = $this->client instanceof Core_Call ? $this->client->invoke() : $this->client;
     $this->client->request($request);
     $env->openid->client = $this->client;
     $ident = null;
     if (preg_match(WS_Middleware_OpenId::option('provider_pattern'), $request->path, $m)) {
         $ident = $m[1];
     } else {
         $ident = isset($request[WS_Middleware_OpenId::option('id_name')]);
     }
     switch (true) {
         case !empty($ident):
             try {
                 $env->request->session()->set('query', $env->request->query);
                 return $this->client->redirect($this->create_redirect_url($ident));
             } catch (OpenId_Exception $e) {
                 $env->openid->error = $e;
                 return $this->application->run($env);
             }
         case $request['openid_mode'] == 'id_res':
             $env->openid->is_valid = $this->client->validate();
             if ($this->client->is_valid) {
                 $env->openid->params = $this->client->retrieve_params();
                 $env->openid->claimed_id = $this->client->claimed_id;
                 $env->request->query($env->request->session()->get('query'));
                 $env->request->session()->remove('query');
             }
         default:
             return $this->application->run($env);
     }
 }
예제 #3
0
파일: Middleware.php 프로젝트: techart/tao
 /**
  * Выполняет обработку запроса
  *
  * @param WS_Environment $env
  *
  * @return mixed
  */
 public function run(WS_Environment $env)
 {
     $this->config();
     if (!isset($env->oauth)) {
         $env->oauth(new stdClass());
     }
     foreach ($this->config as $name => $c) {
         $env->oauth->{$name} = (object) $c;
         if ($c['client']->is_logged_in() && !empty($c['is_login_callback']) && $c['is_login_callback'] instanceof Core_InvokeInterface) {
             $c['is_login_callback']->invoke(array($name, $env));
         }
         $url = sprintf('%s%s/', Service_OAuth_Middleware::option('prefix'), $name);
         switch ($env->request->path) {
             case $url:
                 return $this->login_redirect($env, $c, $url);
             case $url . Service_OAuth_Middleware::option('callback'):
                 return $this->login_confirm($env, $c);
         }
     }
     return $this->application->run($env);
 }
예제 #4
0
파일: REST.php 프로젝트: techart/tao
 /**
  * @param WS_Environment $env
  *
  * @return mixed
  */
 public function run(WS_Environment $env)
 {
     $this->before_run($env->app($this));
     $this->find($env);
     return $this->is_match() ? $this->create_response($env) : Net_HTTP::Response(Net_HTTP::NOT_FOUND);
 }