parse route file and put data in an array
@access protected
@param $src string
@param $controller string
@param $annotation array
@since 3.0
@package Gcs\Framework\Core\Config
1945
protected function _parseAnnotationRoute($src, $controller, $annotation) {
        foreach ($annotation['methods'] as $action => $annotationMethods) {
            $data = [];

            foreach ($annotationMethods as $annotationMethod) {
                if ($annotationMethod['annotation'] == 'Routing') {
                    /** @var \Gcs\Framework\Core\Annotation\Annotations\Router\Routing $annotation */
                    $annotation = $annotationMethod['instance'];

                    $data['name'] = $annotation->name;
                    $data['url'] = $annotation->url;
                    $data['vars'] = $annotation->vars;
                    $data['method'] = $annotation->method;
                    $data['access'] = $annotation->access;
                    $data['cache'] = $annotation->cache;
                    $data['logged'] = $annotation->logged;
                    $data['action'] = lcfirst(basename($controller, '.php')) . '.' . lcfirst(str_replace('action', '', $action));
                }

                $this->config['route'][$src][$data['name']] = $data;
            }
        }
    }
1267831
public function build($controller, array $vars = array())
    {
        $template = $this->mapManager->getUrlTemplateByController($controller);

        if ($template !== false) {
            if ($this->hasVar($template)) {
                return $this->prepare($controller, $template, $vars);
            } else {
                return $template;
            }

        } else {
            // Wrong controller, so nothing to return there
            return null;
        }
    }
75071
private void parseControllerMethod(JaxrsApplicationParser.Result result, JaxrsApplicationParser.ResourceContext context, Class<?> controllerClass, Method method) {
        final RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class);
        if (requestMapping != null) {

            // subContext
            context = context.subPath(requestMapping.path().length == 0 ? "" : requestMapping.path()[0]);
            final Map<String, Type> pathParamTypes = new LinkedHashMap<>();
            for (Parameter parameter : method.getParameters()) {
                final PathVariable pathVariableAnnotation = parameter.getAnnotation(PathVariable.class);
                if (pathVariableAnnotation != null) {
                    pathParamTypes.put(pathVariableAnnotation.value(), parameter.getParameterizedType());
                }
            }
            context = context.subPathParamTypes(pathParamTypes);
            final RequestMethod httpMethod = requestMapping.method().length == 0 ? RequestMethod.GET : requestMapping.method()[0];

            // path parameters
            final PathTemplate pathTemplate = PathTemplate.parse(context.path);
            final Map<String, Type> contextPathParamTypes = context.pathParamTypes;
            final List<MethodParameterModel> pathParams = pathTemplate.getParts().stream()
                    .filter(PathTemplate.Parameter.class::isInstance)
                    .map(PathTemplate.Parameter.class::cast)
                    .map(parameter -> {
                        final Type type = contextPathParamTypes.get(parameter.getOriginalName());
                        final Type paramType = type != null ? type : String.class;
                        foundType(result, paramType, controllerClass, method.getName());
                        return new MethodParameterModel(parameter.getValidName(), paramType);
                    })
                    .collect(Collectors.toList());

            // query parameters
            final List<RestQueryParam> queryParams = new ArrayList<>();
            for (Parameter param : method.getParameters()) {
                final RequestParam requestParamAnnotation = param.getAnnotation(RequestParam.class);
                if (requestParamAnnotation != null) {
                    queryParams.add(new RestQueryParam.Single(new MethodParameterModel(requestParamAnnotation.value(), param.getParameterizedType())));
                    foundType(result, param.getParameterizedType(), controllerClass, method.getName());
                }
            }

            // entity parameter
            final MethodParameterModel entityParameter = getEntityParameter(method);
            if (entityParameter != null) {
                foundType(result, entityParameter.getType(), controllerClass, method.getName());
            }

            // return Type
            final Class<?> returnType = method.getReturnType();
            final Type genericReturnType = method.getGenericReturnType();
            final Type modelReturnType;
            if (genericReturnType instanceof ParameterizedType && returnType == ResponseEntity.class) {
                final ParameterizedType parameterizedReturnType = (ParameterizedType) genericReturnType;
                modelReturnType = parameterizedReturnType.getActualTypeArguments()[0];
                foundType(result, modelReturnType, controllerClass, method.getName());
            } else {
                modelReturnType = genericReturnType;
                foundType(result, modelReturnType, controllerClass, method.getName());
            }

            model.getMethods().add(new RestMethodModel(controllerClass, method.getName(), modelReturnType,
                    controllerClass, httpMethod.name(), context.path, pathParams, queryParams, entityParameter, null));
        }
    }
601100
private static function bind($url, $controller, array $definition, array $where)
    {
        $path = '/'.trim($url.$definition['url'], '/');

        // Launch of the route mapping method.
        $route = static::$application->{$definition['method']}(
            $path,
            sprintf("%s@%s", $controller, $definition['call'])
        );

        // Add name on the road
        $name = str_replace('/', '.', $url).'.'.$definition['call'];

        $route->name($name);

        // Association of defined criteria
        if (isset($where[$definition['call']])) {
            $route->where((array) $where[$definition['call']]);
        } else {
            $route->where((array) $where);
        }
    }
1354466
protected function loadAnnotationRoute($pathinfo)
    {
        @list($empty, $pack, $controller, $method) = explode('/', $pathinfo);

        if (!isset($this->packs[$pack])) {
            return;
        }

        if (isset($this->map[$controller])) {
            $controller = $this->map[$controller];
        }

        $controller = $this->underscoreToCamelCase($controller, true);

        $fullClassName = $this->packs[$pack]->getNameSpace().'\\Controller\\'.$controller;

        if (class_exists($fullClassName)) {
            $this->resolver->resolveController($fullClassName, $this->packs[$pack]);
        }
    }
979574
protected function namespace(String & $controller, String & $namespace = NULL)
    {
        if( ! empty($this->settings['namespace']) )
        {
            $namespace   = $this->settings['namespace'];
            $controller .= "namespace ".$namespace.";".EOL.EOL;
        }
    }
556099
protected function configureController(Controller $controller)
    {
        parent::configureController($controller);
        $controller[] = new Entity($this->entityName);
    }
843951
public function runController($controller, $method, Array $params) {
    $transactional = $controller instanceof \Psc\CMS\Controller\TransactionalController;
    
    try {
      try {
        $this->logf('running Controller: %s::%s(%s)', Code::getClass($controller), $method, implode(', ',array_map(function ($param) { return Code::varInfo($param); }, $params)));
        $cb = new Callback($controller, $method);
        $controllerResponse = $cb->call($params);
        
        $this->log('Converting Controller Response');
        $this->setResponseFromControllerResponse($controllerResponse);
        $this->log('Response Format: '.($this->response->getFormat() ?: 'null'));
        $this->log('successful run');
        
        $this->log('überprüfe ResponseMetadataController');
        if ($controller instanceof \Psc\CMS\Controller\ResponseMetadataController && ($meta = $controller->getResponseMetadata()) != NULL) {
          $this->response->setMetadata($meta);
          $this->log('Metadaten übertragen');
        }
        
      /* PDO Exceptions */
      } catch (\PDOException  $e) {
        throw \Psc\Doctrine\Exception::convertPDOException($e);
      }

    } catch (\Exception $e) {
      if ($transactional && $controller->hasActiveTransaction())
        $controller->rollbackTransaction();
      
      $this->handleException($e);
    }
  }
880595
public function addMap($pattern, $controller = null)
    {
        if (!is_string($controller)) {
            throw new \InvalidArgumentException(
                'Please give me controller name string. ' . ucfirst(gettype($controller)) . ' given.'
            );
        }

        if ($pattern instanceof Route) {
            throw new \LogicException('Do not use Route object in ' . get_called_class());
        }

        return parent::addRoute(null, $pattern, ['_controller' => $controller]);
    }
1158008
private function invalidArrayParameterException(\ReflectionFunctionAbstract $controller, RequestParam $annotation) : HttpBadRequestException
    {
        return new HttpBadRequestException(sprintf(
            '%s() expects an array for %s parameter "%s" (bound to $%s), string given.',
            $this->reflectionTools->getFunctionName($controller),
            $annotation->getParameterType(),
            $annotation->getName(),
            $annotation->getBindTo()
        ));
    }
332357
private function addMergerAnnotations(Application $container)
    {
        if (!isset($container['serializer.annotations'])) {
            throw new \RuntimeException(
                'The configuration service provider depends on the JmsSerializer Service Provider but the '
                . '"serializer.annotations" key could not be found in the container.'
            );
        }

        $annotations = $container['serializer.annotations'];
        $annotations[] = array(
            'namespace' => 'phpDocumentor\Configuration\Merger\Annotation',
            'path' => __DIR__ . '/../../'
        );
        $container['serializer.annotations'] = $annotations;
    }
730889
protected function parseRoutes($uri)
    {
        if (Container::get('config')->get('url_route_annotation')) {
            $finder = new Finder();
            $finder
                ->in(Container::get('config')->get('app_full_path') . '/controllers')
                ->name('*.php');
            $controllerNamespaces = [];
            foreach ($finder as $file) {
                array_push($controllerNamespaces, '\\' . Container::get('config')->get('namespace_prefix') . 'controllers\\' . $file->getBasename('.' . $file->getExtension()));
            }

            foreach ($controllerNamespaces as $namespace) {
                $classReflector = new ReflectionClass($namespace);
                $classAnnotations = new Annotations($classReflector);

                foreach ($classReflector->getMethods() as $methodReflector) {
                    $methodAnnotations = new Annotations($methodReflector);
                    if (!isset($methodAnnotations['route'])) {
                        continue;
                    } else {
                        $routeAnnotations = $methodAnnotations['route'];
                        if (!isset($routeAnnotations['uri'])) {
                            throw new ConfigException('Route annotations error');
                        }

                        $controllerName = $classReflector->getShortName();
                        $actionName = $methodReflector->getName();
                        $route = $controllerName . '/' . $actionName;
                        if (isset($routeAnnotations['params'])) {
                            $route .= '/' . $routeAnnotations['params'];
                        }

                        if (!isset($routeAnnotations['method'])) {
                            $this->routes[$routeAnnotations['uri']] = $route;
                        } else {
                            $this->routes[$routeAnnotations['uri']][$routeAnnotations['method']] = $route;
                        }

                        unset($route);
                    }
                }
            }
        } else {
            $this->routes = Container::get('config')->get('url_route');
        }

        $hostName = Container::get('request')->getHostName();

        if (isset($this->routes[$hostName])) {
            $this->routes = $this->routes[$hostName];
        }

        // Get HTTP verb
        $httpVerb = isset($_SERVER['REQUEST_METHOD']) ? strtolower($_SERVER['REQUEST_METHOD']) : 'cli';

        if (null != $this->routes) {
            foreach ($this->routes as $key => $val) {
                // Check if route format is using HTTP verbs
                if (is_array($val)) {
                    $val = array_change_key_case($val, CASE_LOWER);
                    if (isset($val[$httpVerb])) {
                        $val = $val[$httpVerb];
                    } else {
                        continue;
                    }
                }

                // Does the RegEx match?
                if (preg_match('#^' . $key . '$#', $uri, $matches)) {
                    // Are we using callbacks to process back-references?
                    if (!is_string($val) && is_callable($val)) {
                        // Remove the original string from the matches array.
                        array_shift($matches);

                        // Execute the callback using the values in matches as its parameters.
                        $val = call_user_func_array($val, $matches);
                    } // Are we using the default routing method for back-references?
                    elseif (strpos($val, '$') !== false && strpos($key, '(') !== false) {
                        $val = preg_replace('#^' . $key . '$#', $val, $uri);
                    }

                    return $val;
                }
            }
        }
    }
336614
@Bind(aggregate = true, optional = true)
    public synchronized void bindController(Controller controller) {
        LOGGER.info("Adding routes from " + controller);

        List<Route> newRoutes = new ArrayList<>();
        try {

            List<Route> annotatedNewRoutes = RouteUtils.collectRouteFromControllerAnnotations(controller);
            newRoutes.addAll(annotatedNewRoutes);
            newRoutes.addAll(controller.routes());

            //check if these new routes don't pre-exist
            ensureNoConflicts(newRoutes);

        } catch (RoutingException e) {
            LOGGER.error("The controller {} declares routes conflicting with existing routes, " +
                    "the controller is ignored, reason: {}", controller, e.getMessage(), e);
            // remove all new routes as one has failed
            routes.removeAll(newRoutes);  //NOSONAR
        } catch (Exception e) {
            LOGGER.error("The controller {} declares invalid routes, " +
                    "the controller is ignored, reason: {}", controller, e.getMessage(), e);
            // remove all new routes as one has failed
            routes.removeAll(newRoutes); //NOSONAR
        }
    }
837190
public function extractRouteFromController(\ReflectionClass $reflectionController)
    {
        $classAnnotations = $this->extractorFactory->extract($reflectionController, Extractor::CLASS_ANNOTATION);
        foreach ($classAnnotations as $annotation) {
            if ($annotation instanceof Route) {
                return $annotation;
            }
        }

        throw new RuntimeException(sprintf('Class "%s" does not has any Route annotation', $reflectionController->getName()));
    }
1234231
public function resolve($annotation, $reflectionClass, $pack)
    {
        $app = $this->app;


        $snakeClass = implode('_',preg_split('/(?=[A-Z])/', $reflectionClass->getShortName(), -1, PREG_SPLIT_NO_EMPTY));
        $controllerKey = implode('.',[$pack->getPackName(),'controller', strtolower($snakeClass)]);
        $controller = $reflectionClass->getShortName();

        $app[$controllerKey] = function () use ($app, $reflectionClass, $pack) {
            $class = $reflectionClass->getName();

            return new $class($app, $pack);
        };

        $$controller = $app['controllers_factory'];

        $this->registerControllerFilters($$controller, $controllerKey,  $annotation->filters);
        $this->registerRoutes($$controller, $controllerKey, $reflectionClass);

        $routePattern = ($annotation->mount != '')  ? $pack->getPackName().'/'.$annotation->mount : $pack->getPackName().'/'.strtolower($snakeClass);

        $this->app['controllers']->mount($routePattern, $$controller);

    }
324073
protected function addMultisiteRoute(RouteCollection $collection, $annot, $globals, \ReflectionClass $class, \ReflectionMethod $method)
    {
        $paths = $this->siteContext->normalizePaths($annot->getPaths());

        foreach ($paths as $branding => $locales) {
            foreach ($locales as $locale => $path) {

                // this block of code is copied from Symfony\Component\Routing\Loader\AnnotationFileLoader
                $name = $annot->getName();
                if (null === $name) {
                    $name = $this->getDefaultRouteName($class, $method);
                }
                $name = MultisiteRouter::ROUTE_PREFIX.'_'.$branding.'_'.$locale.'__'.$name;

                $defaults = array_replace($globals['defaults'], $annot->getDefaults());
                foreach ($method->getParameters() as $param) {
                    if (!isset($defaults[$param->getName()]) && $param->isOptional()) {
                        $defaults[$param->getName()] = $param->getDefaultValue();
                    }
                }

                // +2 lines
                $defaults['_branding'] = $branding;
                $defaults['_locale']   = $locale;

                $requirements = array_replace($globals['requirements'], $annot->getRequirements());
                $options = array_replace($globals['options'], $annot->getOptions());
                $schemes = array_replace($globals['schemes'], $annot->getSchemes());
                $methods = array_replace($globals['methods'], $annot->getMethods());

                $host = $annot->getHost();
                if (null === $host) {
                    $host = $globals['host'];
                }

                // +3 lines
                if (!$host) {
                    $host = $this->siteContext->getBranding($branding)->getHost($locale);
                }

                $condition = $annot->getCondition();
                if (null === $condition) {
                    $condition = $globals['condition'];
                }

                $route = new Route($globals['path'].$path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition);
                $this->configureRoute($route, $class, $method, $annot);

                $collection->add($name, $route);
            }
        }

        // cache will refresh when file is modified
        $collection->addResource(new FileResource($class->getFileName()));

        return $collection;
    }
201026
public static function createRouteFile(string $slug, $controller = 'PostController')
    {
        $stub =  File::get(stubPath('PostType'));
        $route = str_replace('DummySlug', cleanPostTypeSlug($slug), $stub);
        $route = str_replace('DummyController', $controller, $route);
        $bytes_written = File::put(base_path().'/routes/'.$slug.'.php', $route);
        if ($bytes_written === false) {
            die("Error writing to new route file");
        }
        return $route;
    }