Ejemplo n.º 1
0
 /**
  * Método que añade nuevas rutas al array de referencia
  *
  * @param string $namespace
  * @param array $routing
  *
  * @return array
  * @throws ConfigException
  */
 private function addRouting($namespace, &$routing)
 {
     if (self::exists($namespace)) {
         $reflection = new \ReflectionClass($namespace);
         if (FALSE === $reflection->isAbstract() && FALSE === $reflection->isInterface()) {
             $this->extractDomain($reflection);
             $classComments = $reflection->getDocComment();
             preg_match('/@api\\ (.*)\\n/im', $classComments, $apiPath);
             $api = '';
             if (count($apiPath)) {
                 $api = array_key_exists(1, $apiPath) ? $apiPath[1] : $api;
             }
             foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
                 list($route, $info) = RouterHelper::extractRouteInfo($method, $api);
                 if (null !== $route && null !== $info) {
                     $info['class'] = $namespace;
                     $routing[$route] = $info;
                 }
             }
         }
     }
     return $routing;
 }