Overview

Namespaces

  • Autarky
    • Config
      • Loaders
    • Console
    • Container
      • Exception
      • Factory
      • Proxy
    • Database
    • Errors
    • Events
    • Files
    • Http
    • Logging
    • Providers
    • Routing
      • Events
    • Testing
    • TwigTemplating
      • Extensions
    • Utils

Classes

  • Configuration
  • Controller
  • DefaultRouteConfigurator
  • Route
  • RoutePathGenerator
  • Router
  • RoutingProvider
  • UrlGenerator

Interfaces

  • InvokerInterface
  • RoutePathGeneratorInterface
  • RouterInterface

Traits

  • ControllerTrait
  • Overview
  • Namespace
  • Class

Class Router

FastRoute implementation of the router.

Autarky\Routing\Router implements Autarky\Routing\RouterInterface
Namespace: Autarky\Routing
Located at Routing/Router.php
Methods summary
public
# __construct( FastRoute\RouteParser $routeParser, Autarky\Routing\InvokerInterface $invoker, Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher = null, string|null $cachePath = null )

Parameters

$routeParser
$invoker
$eventDispatcher
$cachePath
public boolean
# isCaching( )

Returns

boolean
public SplObjectStorage
# getRoutes( )

Returns

SplObjectStorage
public Autarky\Routing\Route
# getCurrentRoute( )

Get the route matched to the current request.

Get the route matched to the current request.

Returns

Autarky\Routing\Route

Implementation of

Autarky\Routing\RouterInterface::getCurrentRoute()
public
# addBeforeHook( string $name, callable $handler, integer $priority = 0 )

Add a "before" event listener.

Add a "before" event listener.

Parameters

$name
$handler
$priority
public
# addAfterHook( string $name, callable $handler, integer $priority = 0 )

Add an "after" event listener.

Add an "after" event listener.

Parameters

$name
$handler
$priority
public
# addGlobalBeforeHook( callable $handler, integer $priority = 0 )

Add a global "before" event listener.

Add a global "before" event listener.

Parameters

$handler
$priority
public
# addGlobalAfterHook( callable $handler, integer $priority = 0 )

Add a global "after" event listener.

Add a global "after" event listener.

Parameters

$handler
$priority
protected
# addEventListener( $name, $handler, $when, $priority )
public
# mount( array $routes, string $path = '/' )

Mount an array config onto the routes.

Mount an array config onto the routes.

Parameters

$routes
$path

Implementation of

Autarky\Routing\RouterInterface::mount()
public
# group( array $flags, Closure $callback )

Define a route group.

Define a route group.

Parameters

$flags
Valid keys are 'before', 'after', 'prefix'
$callback
First argument is the router ($this)

Implementation of

Autarky\Routing\RouterInterface::group()
protected
# getHook( $name )
public
# addRoute( string|array $methods, string $path, string $controller, string $name = null, array $options = [] )

Add a route to the router.

Add a route to the router.

Parameters

$methods
$method HTTP methods the route should respond to
$path
Relative URL the route should respond to. Parameters wrapped in {}
$controller
$handler string of "class:method" or "global_function"
$name
Route name (optional)
$options

Implementation of

Autarky\Routing\RouterInterface::addRoute()
protected
# makePath( $path )
protected
# addNamedRoute( $name, Autarky\Routing\Route $route )
protected
# createRoute( $methods, $path, $controller, $name, array $options )
public Autarky\Routing\Route
# getRoute( string $name )

Given a route name, get the route object.

Given a route name, get the route object.

Parameters

$name

Returns

Autarky\Routing\Route

Throws

InvalidArgumentException
if route with the name does not exist

Implementation of

Autarky\Routing\RouterInterface::getRoute()
public Symfony\Component\HttpFoundation\Response
# dispatch( Symfony\Component\HttpFoundation\Request $request )

Dispatch a request in the router.

Dispatch a request in the router.

Parameters

$request

Returns

Symfony\Component\HttpFoundation\Response

Implementation of

Autarky\Routing\RouterInterface::dispatch()
public Autarky\Routing\Route
# getRouteForRequest( Symfony\Component\HttpFoundation\Request $request )

Get the Route object corresponding to a given request.

Get the Route object corresponding to a given request.

Parameters

$request

Returns

Autarky\Routing\Route

Throws

Symfony\Component\HttpKernel\Exception\NotFoundHttpException
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
protected
# matchRoute( Autarky\Routing\Route $route, array $params, Symfony\Component\HttpFoundation\Request $request )
protected
# getResponse( Symfony\Component\HttpFoundation\Request $request, Autarky\Routing\Route $route, array $params )
protected
# getContainerParams( Autarky\Routing\Route $route, array $routeParams, Symfony\Component\HttpFoundation\Request $request )
protected
# getDispatcher( )
protected
# generateDispatchData( )
Properties summary
protected Autarky\Routing\InvokerInterface $invoker
#
protected Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher
#
protected FastRoute\RouteCollector $routeCollector
#
protected FastRoute\RouteParser $routeParser
#
protected mixed $dispatchData
#
protected string|null $cachePath
#
protected Autarky\Routing\Route $currentRoute
#
protected array $currentHooks

The hooks that are currently applied to every route being added.

The hooks that are currently applied to every route being added.

# []
protected string $currentPrefix

The URL prefix that is currently applied to every route being added.

The URL prefix that is currently applied to every route being added.

# ''
protected array $hooks
# []
protected SplObjectStorage $routes
#
protected array $namedRoutes
# []
Autarky Framework API documentation generated by ApiGen