Skip to content
Artem Khitsenko edited this page Jan 30, 2021 · 3 revisions

Class: Router

Namespace: Afoslt\Core

Parent: -

Modifiers: final

Afoslt router. Router can read client's request and search matching route in application's routes array.


Fields

$routes

Modifiers: private

Associative array of avaible routes for this instance of Router.

$controllerName

Modifiers: private

Name of controller that this router requesting.

$actionName

Modifiers: private

Name of controller's action that this router requesting.

$layoutName

Modifiers: private

Name of controller's action that this router requesting.

Properties

GetRoutes (): array

Modifiers: public final

Getter for $routes.

AddRoutes (string $route, array $routeParams): void

Modifiers: private

Add for $routes.

Adds new route to routes array, where $route is key and $routeParams is associative array with default keys controller & action.

GetControllerName (): string

Modifiers: public final

Getter for $controllerName.

GetActionName (): string

Modifiers: public final

Getter for $actionName.

SetLayoutName (?string $actionName): void

Modifiers: private

Setter for $actionName.

GetLayoutName (): ?string

Modifiers: public final

Getter for $actionName.

Methods

__construct (array $routes)

Modifiers: public

Afoslt router. Router can read client's request and search matching route in application's routes array.

Gets associative arrays of routes as a parameter.

ReadRoutesArray (array $routes): void

Modifiers: private

Formatting all routes from parameters so that Router would work with them.

Gets associative arrays of routes as a parameter.

ReadRequest (?string $requesURI): bool

Modifiers: public final

Read client's request to server.

Gets request URI as a parameter.

Returns true if requests matches with any of router's routes.