コード例 #1
0
ファイル: Result.php プロジェクト: phossa/phossa-route
 /**
  * constructor
  *
  * @param  RequestInterface $request
  * @access public
  * @api
  */
 public function __construct(RequestInterface $request)
 {
     $this->request = $request;
     $this->setParameter((array) $request->getRequestInfo());
 }
コード例 #2
0
ファイル: Collector.php プロジェクト: phossa/phossa-route
 /**
  * Filtering in route
  *
  * @param  RouteInterface $route
  * @param  RequestInterface $request
  * @return bool
  * @access protected
  */
 protected function filtering(RouteInterface $route, RequestInterface $request)
 {
     foreach ($route->getFilters() as $field => $filter) {
         list($grpName, $keyName) = explode('.', $field, 2);
         switch ($grpName) {
             case 'session':
                 $against = isset($_SESSION[$keyName]) ? $_SESSION[$keyName] : '';
                 break;
             case 'cookie':
                 $against = isset($_COOKIE[$keyName]) ? $_COOKIE[$keyName] : '';
                 break;
             case 'request':
                 $against = $request->getRequestInfo($keyName);
                 break;
             default:
                 $against = $request->getServerInfo($keyName);
                 break;
         }
         if (is_callable($filter)) {
             return $filter((string) $against);
         } elseif (!preg_match('~' . $filter . '~x', (string) $against)) {
             return false;
         }
     }
     return true;
 }