Adds all given middleware to the current route if they exist
@param App $cdl CDL Application instance
@param array $settings Route settings
@param \Slim\Route $route Route Object
490616
private static function applyMiddleware(App $cdl, array $settings, \Slim\Route $route): void{
        if (isset($settings['middleware']) && !empty($settings['middleware'])) {
            foreach ($settings['middleware'] as $middleware) {
                if ($cdl->hasMiddleware($middleware)) {
                    /* @var $middleware Middleware */
                    $middleware = $cdl->getMiddleware($middleware);
                    $route->add($middleware::getInstance());
                }
            }
        }
    }
1154666
public function addRoute($method, $route, $callback)
    {
        return $this->routes[] = new Route(strtoupper($method), $route, $callback);
    }
979626
public function gatherRouteMiddlewares( Route $route )
	{
		return Collection::make( $route->middleware() )->map( function ( $name )
		{
			return Collection::make( $this->resolveMiddlewareClassName( $name ) );
		} )->flatten()->all();
	}
1062085
public function addRoute(Route $route, array $parameterIndexNameMap)
    {
        if ($route->allowsAnyHttpMethod()) {
            $this->defaultRouteData = MatchedRouteData::from($parameterIndexNameMap, $route);
        } else {
            $this->httpMethodRouteDataMap[] = [$route->getHttpMethods(), MatchedRouteData::from($parameterIndexNameMap, $route)];
        }
    }
711660
protected function configureSettings($settings, $path = '')
    {
        foreach ($settings as $key => $node) {
            if (is_array($node)) {
                $this->configureSettings($node, $path . $key . '.');
            } else {
                $this->configureSetting($path . $key, $node);
            }
        }
    }
1054500
public function addRoute(RouteInterface $route)
    {
        foreach ($this->middlewares as $m) {
            $route->addMiddleware($m);
        }
        $this->routes[] = $route;
        return $this;
    }
485250
protected function storeRoute(array $methods, array $route)
    {
        $this->callbacks[] = (object)$route;
        $index             = count($this->callbacks) - 1;

        if (!isset($this->routes[$route['pattern']])) {
            $this->routes[$route['pattern']] = [];
        }

        if ($route['name']) {
            $this->names[$route['name']] = $index;
        }

        foreach ($methods as $method) {
            $this->routes[$route['pattern']][strtoupper($method)] = $index;
        }
    }
16779
public function add($path, $middleware = null)
    {
        if (!isset($middleware)) {
            $middleware = $path;
            $path = null;
        }

        if (!empty($path) && !ctype_digit($path) && $path[0] !== '/') {
            trigger_error("Middleware path '$path' doesn't start with a '/'", E_USER_NOTICE);
        }
        
        if (!is_callable($middleware)) {
            throw new \InvalidArgumentException("Middleware should be callable");
        }

        if (!empty($path)) {
            $middleware = $this->wrapMiddleware($path, $middleware);
        }
        
        $this->middlewares[] = $middleware;
        
        return $this;
    }
261045
public function applyCalculators(App $cdl): void{
        $settings = $this->getTypeSettings();
        foreach ($settings['fields'] as $field) {
            if (!isset($field['calculations'])) {
                continue;
            }
            foreach ($field['calculations'] as $key => $calculation) {
                $data = self::buildPluginData($key, $calculation);
                if ($cdl->hasCalculator($data['name'])) {
                    $calcObject = $cdl->getCalculator($data['name']);
                    /* @var $calc Calculator */
                    $calc = new $calcObject($this, $field['name'], $data['attributes']);
                    $calc->apply();
                }
            }
        }
    }
647261
protected function addLookups(Route $route)
    {
        $action = $route->getAction();

        if (isset($action['as'])) {
            $this->names[$action['as']] = $route;
        }

        if (isset($action['controller'])) {
            $this->actions[$action['controller']] = $route;
        }
    }
433932
private static function runRouteMiddleware($route)
    {
        $routeMiddleware = Filter::$routeMiddleware;

        if (!is_null($route->getMiddleware())) {
            // if ($route->getMiddleware()['type'] == 'route' && ! is_null($route->getMiddleware()['middlewares'])) {
            foreach ($route->getMiddleware() as $middleware) {
                //Check if the routes middlewares are in filter class
                exception_if(!array_has($routeMiddleware, $middleware), RouteMiddlewareNotFoundException::class, $middleware);

                $middleware = instance($routeMiddleware[$middleware]);

                $middleware->handle(new Request());
            }
        }

        return true;
    }
695529
public function add(Route $route)
    {
        $this->addRoute($route->methods(), $route->uri(), $route->handler(), $route->name());
    }
483824
public function gatherRouteMiddleware(Route $route)
    {
        $middleware = collect($route->gatherMiddleware())->map(function ($name) {
            return (array) MiddlewareNameResolver::resolve($name, $this->middleware, $this->middlewareGroups);
        })->flatten();

        return $this->sortMiddleware($middleware);
    }
473816
protected function addLinkRoute(ItemInterface $menu, $label, $route, $routeParameters = array())
    {
        $item = $menu->addChild($label, array('route' => $route, 'routeParameters' => $routeParameters, 'routeAbsolute' => UrlGeneratorInterface::ABSOLUTE_PATH));
        $item->setExtra('translation_domain', $this->translation_domain);

        if ($this->isCurrentUri($item->getUri())) {
            $this->setActive($item);
        }

        return $item;
    }
1140329
public function addRoute(array $methods, array $versions, $uri, $action)
    {
        $this->createRouteCollections($versions);

        $route = new Route($methods, $uri, $action);
        $route->where($action['where']);

        foreach ($versions as $version) {
            $this->routes[$version]->add($route);
        }

        return $route;
    }
747072
static public function serve(array $route) {
        if (!isset($route['path']) || !isset($route['callback']) || 
            (isset($route['method']) && is_string($route['method']))) {
            throw new \Lollipop\Exception\HTTP\Router('Invalid route');
        }
        
        // Default path to '/'
        $path = Utils::fuse($route['path'], '');
        $path = trim($path, '/');

        if (!isset($route['method'])) {
            $route['method'] = [];
        }
        
        if (!isset($route['middlewares'])) {
            $route['middlewares'] = [];
        }
        
        if (!isset($route['arguments'])) {
            $route['arguments'] = [];
        }
        
        // Report duplicated path
        // if (isset(self::$_stored_routes[$path])) {
        //     throw new \Lollipop\Exception\HTTP\Router("Duplicate path: $path");
        // }

        // if (isset($route['name']) && isset(self::$_stored_names[$route['name']])) {
        //     throw new \Lollipop\Exception\HTTP\Router('Duplicate name: ' . $route['name']);
        // }

        // Store route
        foreach ($route['method'] as $method) {
            self::$_stored_routes[$method][$path] = $route;
        }

        if (isset($route['name'])) {
            self::$_stored_names[$route['name']] = $path;
        }

        // Register dispatcher once this function was called
        self::_registerDispatch();
    }
1315684
public function addMiddleware($middleware, array $properties = array())
    {
        if($this->route)
        {
            $this->route->addMiddleware($middleware, $properties);
        }
        else
        {
            $this->middlewares[] = array($middleware, $properties);
        }

        return $this;
    }