Extract the resource identifier from the given path.

@param Route $route
@param       $path

@return mixed resource identifier
541145
public function getResourceFromPath(Route $route, $path) {
        // Explode it.
        $chunks = explode("/", $path);
        return $route->resourceOffset ? $chunks[$route->resourceOffset ] : null;
    }
962882
private function mapRoute2IndexKey($route)
    {
        $route = rtrim($route, "/");

        if (key_exists($route, $this->index)) {
            return $route;
        } elseif (empty($route) && key_exists("index", $this->index)) {
            return "index";
        } elseif (key_exists($route . "/index", $this->index)) {
            return "$route/index";
        }

        return false;
    }
1091548
function extractParams(route, path) {
    var vals = route.regex.exec(path).slice(1), params = {}, i, n;

    for (i = 0, n = route.names.length; i < n; i++) {
      params[route.names[i]] = vals[i];
    }

    return params;
  }
213165
public function inflect(Route $route)
    {
        $arguments = $this->extractAttributes($route);
        return $this->createDispatch($arguments);
    }
970717
protected static function dynamic($route)
    {
        $parms = [];
        $param = '';
        $open = false;
        //
        for ($i = 0; $i < Strings::length($route); $i++) {
            if ($open && $route[$i] != '}') {
                $param .= $route[$i];
            }
            //
            if ($route[$i] == '{' && !$open) {
                $open = true;
            } //
            elseif ($route[$i] == '}' && $open) {
                $open = !true;
                $parms[] = $param;
                $param = '';
            }
        }
        //
        return $parms;
    }
943022
protected function matches(Route $route, string $path): bool
	{
		if(preg_match($route->getRegex(), $path, $parameters) > 0)
		{
			$filtered = [];

			foreach($parameters as $key => $value)
			{
				if(is_string($key))
				{
					$filtered[$key] = $value;
				}
			}

			$route->setParameters($filtered);

			return true;
		}

		return false;
	}
1011716
private function extractVariableRouteParts(string $route) : array
    {
        $matches = [];
        preg_match_all(
            self::VARIABLE_REGEX,
            $route,
            $matches,
            PREG_OFFSET_CAPTURE | PREG_SET_ORDER
        );

        return $matches;
    }
1344458
private function parseRoute($route)
    {
        if (is_string($route) || is_numeric($route) || $route instanceof UriInterface) {
            $route = array_merge(
                $this->defaultRedirect,
                [ 'route' => $route ]
            );
        } else {
            if (!is_array($route)) {
                throw new InvalidArgumentException(
                    'The new path must be a string (%s) or an array structure; received %s',
                    'URI, \Psr\Http\Message\UriInterface, or the name of a \Slim\Route',
                    (is_object($route) ? get_class($route) : gettype($route))
                );
            }

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

            if (!isset($route['route_type'])) {
                $route['route_type'] = null;
            }

            if (!isset($route['data_key'])) {
                $route['data_key'] = null;
            }

            if (isset($route['template_route'])) {
                $route['route']         = $route['template_route'];
                $route['methods']       = [ 'GET' ];
                $route['data_key']      = 'template_data';
                $route['route_type']    = 'templates';
                $route['template_data'] = [];
                unset($route['template_route']);
            } elseif (isset($route['action_route'])) {
                $route['route']       = $route['action_route'];
                $route['methods']     = [ 'POST' ];
                $route['data_key']    = 'action_data';
                $route['route_type']  = 'actions';
                $route['action_data'] = [];
                unset($route['action_route']);
            } elseif (isset($route['script_route'])) {
                $route['route']       = $route['script_route'];
                $route['methods']     = [ 'GET' ];
                $route['data_key']    = 'script_data';
                $route['route_type']  = 'scripts';
                $route['script_data'] = [];
                unset($route['script_route']);
            } else {
                if (isset($route['route_type'])) {
                    switch ($route['route_type']) {
                        case 'templates':
                            $route['data_key'] = 'template_data';
                            $route['methods']  = [ 'GET' ];
                            break;

                        case 'actions':
                            $route['data_key'] = 'action_data';
                            $route['methods']  = [ 'POST' ];
                            break;

                        case 'scripts':
                            $route['data_key'] = 'script_data';
                            $route['methods']  = [ 'GET' ];
                            break;

                        case 'template':
                        case 'action':
                        case 'script':
                            $route['data_key']    = $route['route_type'] . '_data';
                            $route['route_type'] .= 's';
                            $route['methods'] = ($route['route_type'] === 'actions') ? [ 'POST' ] : [ 'GET' ];
                            break;

                        default:
                            $route['data_key']   = null;
                            $route['route_type'] = null;
                    }
                }

                if (!isset($route[$route['data_key']])) {
                    $route[$route['data_key']] = [];
                }
            }

            $found = false;
            if ($route['route_type'] && isset($route['route'])) {
                $container = $this->app()->getContainer();
                $routeName = $route['route'];
                $routeType = $route['route_type'];
                $appRoutes = $container['config']['routes'];

                if (isset($appRoutes[$routeType])) {
                    $appRoutes = $appRoutes[$routeType];

                    if (isset($appRoutes[$routeName])) {
                        $route = array_merge($route, $appRoutes[$routeName]);
                        $found = true;
                    } else {
                        foreach ($appRoutes as $targetRoute) {
                            if (isset($targetRoute['ident']) && $targetRoute['ident'] === $routeName) {
                                $route = array_merge($route, $targetRoute);
                                $found = true;
                            }
                        }
                    }
                }
            }

            if ($found === false) {
                if (!isset($route['route'])) {
                    $route['route'] = $this->defaultRedirect['route'];
                }

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

        return $route;
    }
161976
protected function getRouteInformation(Route $route)
	{
		$uri = head($route->methods()).' '.$route->uri();

		return $this->filterRoute(array(
			'host'   => $route->domain(),
			'uri'    => $uri,
			'name'   => $route->getName(),
			'action' => $route->getActionName(),
			'before' => $this->getBeforeFilters($route),
			'after'  => $this->getAfterFilters($route)
		));
	}
789252
public function gatherRouteMiddlewares(LaravelRoute $route)
    {
        $middlewares = [];

        foreach ($route->middleware() as $name) {
            $middlewares[] = $this->resolveMiddlewareClassName($name);
        }
        return Arr::flatten($middlewares);
    }
831675
public function getLink($route)
    {
        $token = 'token';
        $secure = true;
        return $this->url->link($route, $token . '=' . $this->session->data[$token], $secure);
    }
1062324
private function stripRouteFromPath(Http\Request $request, $route)
    {
        $this->removed = $route;

        $uri  = $request->getUri();
        $path = $this->getTruncatedPath($route, $uri->getPath());
        $new  = $uri->withPath($path);

        // Root path of route is treated differently
        if ($path === '/' && '/' === substr($uri->getPath(), -1)) {
            $this->removed .= '/';
        }

        return $request->withUri($new);
    }
842230
public function gatherRouteMiddlewares($route)
    {
        if (method_exists($this->router, 'gatherRouteMiddleware')) {
            return $this->router->gatherRouteMiddleware($route);
        }

        return $this->router->gatherRouteMiddlewares($route);
    }
127276
public static function getHandlerByPath($path)
    {
        $result = null;
        $path   = self::prepareRoute('/'.trim($path, " /"));

        foreach (static::$routes as $key => $handler) {
            $matches = [];
            if (preg_match('#'.$key.'$#i', $path, $matches)) {
                foreach ($matches as $key => $val) {
                    if (!is_numeric($key)) {
                        $_GET[$key] = $val;
                    }
                }
                $result = $handler[1];
                break;
            }
        }
        return $result;
    }
817239
protected static function funcGet($route)
    {
        $params = self::dynamic($route);
        //
        if (count($params) > 0) {
            return 'get(\''.$route.'\',function('.self::formatParams($params).')';
        } else {
            return 'get(\''.$route.'\',function()';
        }
    }
1357003
private function extractPermissionFrom(Route $route)
    {
        $parameters = $route->getAction();

        if (isset($parameters['permission']))
        {
            return $parameters['permission'];
        }

        return null;
    }
861046
private function getMethods(Route $route)
    {
        $methods = $route->getMethods();
        sort($methods);

        return implode('|', $methods) ?: 'ANY';
    }