当前位置: 首页>>代码示例>>PHP>>正文


PHP Router::getRequest方法代码示例

本文整理汇总了PHP中Router::getRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::getRequest方法的具体用法?PHP Router::getRequest怎么用?PHP Router::getRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Router的用法示例。


在下文中一共展示了Router::getRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: check_if_valid

 public function check_if_valid($controller)
 {
     //First we will ensure there is a token in the request
     $request = Router::getRequest();
     $token = false;
     if (isset($request->data['token'])) {
         $token = $request->data['token'];
     } elseif (isset($request->query['token'])) {
         $token = $request->query['token'];
     }
     if ($token != false) {
         if (strlen($token) != 36) {
             $result = array('success' => false, 'message' => array('message' => __('Token in wrong format')));
         } else {
             //Find the owner of the token
             $result = $this->find_token_owner($token);
         }
     } else {
         $result = array('success' => false, 'message' => array('message' => __('Token missing')));
     }
     //If it failed - set the controller up
     if ($result['success'] == false) {
         $controller->set(array('success' => $result['success'], 'message' => $result['message'], '_serialize' => array('success', 'message')));
         return false;
     } else {
         return $result['user'];
         //Return the user detail
     }
 }
开发者ID:smartwifi,项目名称:stores-rd,代码行数:29,代码来源:TokenAuthComponent.php

示例2: _getRequest

 /**
  * 指定されたURLに対応しRouterパース済のCakeRequestのインスタンスを返す
  *
  * @param string $url URL
  * @return CakeRequest
  */
 protected function _getRequest($url)
 {
     Router::$initialized = false;
     Router::reload();
     $request = new CakeRequest($url);
     // コンソールからのテストの場合、requestのパラメーターが想定外のものとなってしまうので調整
     if (isConsole()) {
         $baseUrl = Configure::read('App.baseUrl');
         if ($request->url === false) {
             $request->here = $baseUrl . '/';
         } elseif (preg_match('/^' . preg_quote($request->webroot, '/') . '/', $request->here)) {
             $request->here = $baseUrl . '/' . preg_replace('/^' . preg_quote($request->webroot, '/') . '/', '', $request->here);
         }
         if ($baseUrl) {
             if (preg_match('/^\\//', $baseUrl)) {
                 $request->base = $baseUrl;
             } else {
                 $request->base = '/' . $baseUrl;
             }
             $request->webroot = $baseUrl;
         } else {
             $request->base = '';
             $request->webroot = '/';
         }
     }
     Router::setRequestInfo($request);
     $params = Router::parse($request->url);
     unset($params['?']);
     $request = Router::getRequest(true);
     $request->addParams($params);
     return $request;
 }
开发者ID:baserproject,项目名称:basercms,代码行数:38,代码来源:BaserTestCase.php

示例3: __getLoginName

 /**
  * @author thientd
  */
 private function __getLoginName()
 {
     // in batch section.
     if (php_sapi_name() == 'cli') {
         return Configure::read('CONSOLE_MODIFIER_NAME');
     }
     $user = AuthComponent::user();
     // web, register section
     if (!$user) {
         return 'Register';
     }
     // web, login section
     $loginName = '';
     $request = Router::getRequest();
     if (isset($request->params['admin'])) {
         $loginName = Configure::read('ADMIN_MODIFIER_NAME');
     } elseif (isset($request->params['advisor'])) {
         if (isset($user['AdvisorProfile']['fullname'])) {
             $loginName = $user['AdvisorProfile']['fullname'];
         }
     } else {
         if (isset($user['UserProfile']['fullname'])) {
             $loginName = $user['UserProfile']['fullname'];
         }
     }
     if (mb_strlen($loginName) > 50) {
         $loginName = mb_substr($loginName, 0, 50);
     }
     return $loginName;
 }
开发者ID:sonnt1991,项目名称:Goikenban,代码行数:33,代码来源:AppModel.php

示例4: _getController

 /**
  * Overriding _getController to use MPResponse instead of default one
  *
  * @see ExceptionRenderer::_getController
  * @param Exception $exception
  * @return CakeErrorController|Controller
  */
 protected function _getController($exception)
 {
     App::uses('AppController', 'Controller');
     App::uses('CakeErrorController', 'Controller');
     if (!($request = Router::getRequest(true))) {
         $request = new CakeRequest();
     }
     $response = new MPResponse();
     if (method_exists($exception, 'responseHeader')) {
         $response->header($exception->responseHeader());
     }
     if (class_exists('AppController')) {
         try {
             $controller = new CakeErrorController($request, $response);
             $controller->startupProcess();
         } catch (Exception $e) {
             if (!empty($controller) && $controller->Components->enabled('RequestHandler')) {
                 $controller->RequestHandler->startup($controller);
             }
         }
     }
     if (empty($controller)) {
         $controller = new Controller($request, $response);
         $controller->viewPath = 'Errors';
     }
     return $controller;
 }
开发者ID:slachiewicz,项目名称:_mojePanstwo-API-Server,代码行数:34,代码来源:MPExceptionRenderer.php

示例5: getHtml

 public static function getHtml($message, $file, $line, $context = null)
 {
     $params = Router::getRequest();
     $trace = Debugger::trace(array('start' => 2, 'format' => 'base'));
     $session = isset($_SESSION) ? $_SESSION : array();
     $msg = array('<p><strong>', $message, '</strong></p>', '<p>', $file . '(' . $line . ')', '</p>', '', '<h2>', 'Backtrace:', '</h2>', '', '<pre>', trim($trace), '</pre>', '', '<h2>', 'Request:', '</h2>', '', '<h3>URL</h3>', self::getUrl(), '<h3>Client IP</h3>', self::getClientIp(), '<h3>Referer</h3>', env('HTTP_REFERER'), '<h3>Parameters</h3>', self::dumper($params), '<h3>Cake root</h3>', APP, '', '<h2>', 'Environment:', '</h2>', '', self::dumper($_SERVER), '', '<h2>', 'Session:', '</h2>', '', self::dumper($session), '', '<h2>', 'Cookie:', '</h2>', '', self::dumper($_COOKIE), '', '<h2>', 'Context:', '</h2>', '', self::dumper($context), '');
     return join("\n", $msg);
 }
开发者ID:k1low,项目名称:exception,代码行数:8,代码来源:ExceptionText.php

示例6: __construct

 /**
  * __construct
  *
  * @access public
  * @return void
  */
 function __construct()
 {
     parent::__construct();
     $this->_set(Router::getPaths());
     $this->request = Router::getRequest(false);
     $this->constructClasses();
     $this->Components->trigger('initialize', array(&$this));
     $this->_set(array('cacheAction' => false, 'viewPath' => 'errors'));
 }
开发者ID:no2key,项目名称:Web-Framework-Benchmark,代码行数:15,代码来源:cake_error_controller.php

示例7: _getController

 /**
  * Get a custom InfinitasErrorController instance
  * 
  * This instance tries to load up the very minimum to display the error
  * page. If anything goes wrong it falls back to the default CakeErrorController
  *
  * @param Exception $exception The exception to get a controller for.
  * 
  * @return Controller
  */
 protected function _getController($exception)
 {
     App::uses('InfinitasErrorController', 'Controller');
     if (!($request = Router::getRequest(true))) {
         $request = new CakeRequest();
     }
     $response = new CakeResponse(array('charset' => Configure::read('App.encoding')));
     try {
         return new InfinitasErrorController($request, $response);
     } catch (Exception $e) {
         return parent::_getController($exception);
     }
 }
开发者ID:nani8124,项目名称:infinitas,代码行数:23,代码来源:InfinitasExceptionRenderer.php

示例8: isAdminSystem

 /**
  * 管理システムかチェック
  * 
  * 《注意》by ryuring
  * 処理の内容にCakeRequest や、Router::parse() を使おうとしたが、
  * Router::parse() を利用すると、Routing情報が書き換えられてしまうので利用できない。
  * Router::reload() や、Router::setRequestInfo() で調整しようとしたがうまくいかなかった。
  * 
  * @return boolean
  */
 public static function isAdminSystem($url = null)
 {
     if (!$url) {
         $request = Router::getRequest(true);
         if ($request) {
             $url = $request->url;
         } else {
             return false;
         }
     }
     $adminPrefix = Configure::read('Routing.prefixes.0');
     return (bool) (preg_match('/^(|\\/)' . $adminPrefix . '\\//', $url) || preg_match('/^(|\\/)' . $adminPrefix . '$/', $url));
 }
开发者ID:baserproject,项目名称:basercms,代码行数:23,代码来源:BcUtil.php

示例9: __construct

 public function __construct($id = false, $table = null, $ds = null)
 {
     // Auto set recursive to -1
     $this->recursive = -1;
     // Auto attach containable behaviour
     $this->actsAs[] = 'Containable';
     // Fetch language
     $this->language = Configure::read('Config.language');
     // Never use NOW() in MySQL queries, since it depends on the MySQL server timezone
     $this->MysqlNow = date("Y-m-d H:i:s");
     // Set db already slugged models and fields to avoid recursive slug to get in there
     $this->dbSlugged = array();
     $this->request = Router::getRequest();
     $this->isAdmin = isset($this->request->params['admin']);
     parent::__construct($id, $table, $ds);
     // Remove all relationship conditions if in admin mode
     if ($this->isAdmin) {
         foreach ($this->belongsTo as &$belongsTo) {
             $belongsTo['conditions'] = array();
         }
         foreach ($this->hasOne as &$hasOne) {
             $hasOne['conditions'] = array();
         }
         foreach ($this->hasMany as &$hasMany) {
             $hasMany['conditions'] = array();
         }
         foreach ($this->hasAndBelongsToMany as &$hasAndBelongsToMany) {
             $hasAndBelongsToMany['conditions'] = array();
         }
     } else {
         // Automatically add slug field to model with name fields and no slug field
         if (!in_array($this->alias, $this->dbSlugged)) {
             if ($this->hasField('name_fr') && $this->hasField('name_en')) {
                 $this->virtualFields['slug'] = sprintf('%s.name_%s', $this->alias, $this->language);
                 // Add localized name field
                 if (!$this->hasField('name')) {
                     $this->virtualFields['name'] = sprintf('%s.name_%s', $this->alias, $this->language);
                 }
             }
             // Title fields
             if ($this->hasField('title')) {
                 $this->virtualFields['slug'] = sprintf('%s.title', $this->alias);
             }
         }
     }
     // Global use of number helper
     App::uses('CakeNumber', 'Utility');
 }
开发者ID:mathg,项目名称:skinsound,代码行数:48,代码来源:AppModel.php

示例10: _getController

 /**
  * Get the controller instance to handle the exception.
  * Override this method in subclasses to customize the controller used.
  * This method returns the built in `CakeErrorController` normally, or if an error is repeated
  * a bare controller will be used.
  *
  * @param Exception $exception The exception to get a controller for.
  * @return Controller
  */
 protected function _getController($exception)
 {
     if (!($request = Router::getRequest(true))) {
         $request = new CakeRequest();
     }
     // If outside of plugin, use default handling
     if ($request->params['plugin'] !== 'forum') {
         return parent::_getController($exception);
     }
     $response = new CakeResponse(array('charset' => Configure::read('App.encoding')));
     $controller = new ForumAppController($request, $response);
     $controller->viewPath = 'Errors';
     $controller->constructClasses();
     $controller->startupProcess();
     return $controller;
 }
开发者ID:alescx,项目名称:forum,代码行数:25,代码来源:ForumExceptionRenderer.php

示例11: _getController

 protected function _getController($exception)
 {
     App::uses('TestAppsErrorController', 'Controller');
     if (!($request = Router::getRequest(true))) {
         $request = new CakeRequest();
     }
     $response = new CakeResponse(array('charset' => Configure::read('App.encoding')));
     try {
         $controller = new TestAppsErrorController($request, $response);
         $controller->layout = 'banana';
     } catch (Exception $e) {
         $controller = new Controller($request, $response);
         $controller->viewPath = 'Errors';
     }
     return $controller;
 }
开发者ID:pritten,项目名称:SmartCitizen.me,代码行数:16,代码来源:TestAppsExceptionRenderer.php

示例12: _getController

 protected function _getController($exception)
 {
     App::uses('TestAppsErrorController', 'Controller');
     if (!($request = Router::getRequest(TRUE))) {
         $request = new CakeRequest();
     }
     $response = new CakeResponse();
     try {
         $controller = new TestAppsErrorController($request, $response);
         $controller->layout = 'banana';
     } catch (Exception $e) {
         $controller = new Controller($request, $response);
         $controller->viewPath = 'Errors';
     }
     return $controller;
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:16,代码来源:TestAppsExceptionRenderer.php

示例13: _getController

 protected function _getController($exception)
 {
     if (Configure::read('debug') > 0) {
         if (get_class($exception) == 'MissingTableException') {
             // had to put this in because debugger would fix the error and you'd never see it
             debug($exception->getMessage());
         } elseif (get_class($exception) == 'PDOException') {
             // had to put this in because debugger would fix the error and you'd never see it
             debug($exception->getMessage());
         }
     }
     App::uses('AppErrorController', 'Controller');
     if (!($request = Router::getRequest(false))) {
         $request = new CakeRequest();
     }
     $response = new CakeResponse(array('charset' => Configure::read('App.encoding')));
     $Controller = new AppErrorController($request, $response);
     //Needed to add this check to allow errors from testing to be displayed WHY DIDN'T WE COMMENT THE REMOVAL OF IT THEN!!!
     //if(!defined('APP_TEST_CASES')) {
     if (get_class($exception) == 'MissingPluginException') {
         try {
             $Controller->handleMissingPlugin($request, $exception);
         } catch (Exception $e) {
             debug($e->getMessage());
             exit;
         }
     } else {
         try {
             $Controller->handleAlias($request, $exception);
             // checks for alias match
         } catch (Exception $e) {
             try {
                 $Controller->handleNotFound($request, $response, $e, $exception);
             } catch (Exception $e) {
                 $Controller = new Controller($request, $response);
                 $Controller->viewPath = 'Errors';
             }
         }
     }
     //}
     return $Controller;
 }
开发者ID:ayaou,项目名称:Zuha,代码行数:42,代码来源:AppExceptionRenderer.php

示例14: has

 /**
  * Check wither the routing table has a specific route
  * @param Router $router
  * @return bool
  */
 public function has(Router $router)
 {
     $found = false;
     foreach ($this->_routingTable as $routeID => $routeDetails) {
         if (preg_match("/^" . str_replace('/', '\\/', $routeDetails['_url_']) . "\$/i", $router->getFinalRequestedId()) && in_array($router->getRequest()->getMethod(), $this->_routingTable[$routeID]['_method_'])) {
             $found = true;
             break;
         }
     }
     $router->setController($this->_routingTable[$routeID]['_controller_']);
     $router->setAction($this->_routingTable[$routeID]['_action_']);
     if (!empty($router->getParams())) {
         $index = 0;
         $parameters = array();
         $routerFetchedParameters = $router->getParams();
         foreach ($this->_routingTable[$routeID]['_params_'] as $parameter) {
             $parameters[$parameter] = $routerFetchedParameters[$index++];
         }
         $router->setParams($parameters);
     }
     return $found;
 }
开发者ID:firefoxrebo,项目名称:Lily,代码行数:27,代码来源:routingtable.php

示例15: beforeFind

 public function beforeFind($queryData)
 {
     if (isset(Router::getRequest()->query['Search'])) {
         $search = Router::getRequest()->query['Search'];
         if (isset($search['Table']) && $search['Table'] == $this->alias) {
             unset($search['Table']);
             foreach ($search as $key => $val_parent) {
                 foreach ($val_parent as $key_child => $val) {
                     if (is_array($val) && !empty($val)) {
                         if (isset($val['from']) && $val['from'] != '') {
                             $queryData['conditions'][$key . '.' . $key_child . '  >=  '] = $val['from'];
                         }
                         if (isset($val['from_date']) && $val['from_date'] != '') {
                             $queryData['conditions'][$key . '.' . $key_child . '  >=  '] = sqlFormatDate($val['from_date']);
                         }
                         if (isset($val['to']) && $val['to'] != '') {
                             $queryData['conditions'][$key . '.' . $key_child . '  <=  '] = $val['to'];
                         }
                         if (isset($val['to_date']) && $val['to_date'] != '') {
                             $queryData['conditions'][$key . '.' . $key_child . '  <=  '] = sqlFormatDate($val['to_date']);
                         }
                     } else {
                         if ($val != '') {
                             if ($key_child == 'id') {
                                 $queryData['conditions'][$key . '.' . $key_child . ' = '] = $val;
                             } else {
                                 $queryData['conditions'][$key . '.' . $key_child . ' LIKE '] = '%' . $val . '%';
                             }
                         }
                     }
                 }
             }
             //print_r($queryData);die;
             return $queryData;
         }
     }
 }
开发者ID:a0108393,项目名称:cms-system,代码行数:37,代码来源:AppModel.php


注:本文中的Router::getRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。