Example #1
0
 public static function process($mode, $resource, $action, $data, $method)
 {
     $list = array();
     if ($mode == 'after') {
         $list = self::$after;
     } elseif ($mode == 'before') {
         $list = self::$before;
     }
     if (empty($list)) {
         return;
     }
     $resource = Url::trim($resource);
     $matches = false;
     foreach (self::$routes as $route) {
         list($preg, $target) = $route;
         if (preg_match("/^" . $preg . "\$/si", $resource, $matches)) {
             $resource = $target;
             break;
         }
     }
     foreach ($list as $line) {
         if ($line['preg'] == '*' || preg_match("/^" . $line['preg'] . "\$/si", $resource, $matches)) {
             if ($line["actions"] == "*" || is_array($line['actions']) && in_array($action, $line['actions'])) {
                 $result = Request::middleware($line['middleware'], $method, $data);
             }
         }
     }
 }