Skip to content

Latest commit

 

History

History
86 lines (68 loc) · 17.4 KB

File metadata and controls

86 lines (68 loc) · 17.4 KB

Table of contents


Class: Rudra\Router\Router

Visibility Function
public set(array $route): void
Sets the route, parsing HTTP methods (if multiple are specified via |).
Registers a route handler for each method.
-------------------------
Устанавливает маршрут, разбирая HTTP-методы (если указано несколько через |).
Для каждого метода регистрирует обработчик маршрута.
private handleRequestUri(array $route): void
Processes the incoming URI request and checks if it matches the current route.
-------------------------
Обрабатывает входящий URI-запрос и проверяет его совпадение с текущим маршрутом.
private handleRequestMethod(): void
Processes the HTTP request method, including spoofing via _method (for PUT/PATCH/DELETE)
-------------------------
Обрабатывает HTTP-метод запроса, включая spoofing через _method (для PUT/PATCH/DELETE)
private handlePattern(array $route, array $request): array
Matches the URI from the route with the actual request, processing parameters of the form :param and :regexp.
This method is used to extract dynamic segments from a URI pattern:
-------------------------
Сопоставляет URI из маршрута с фактическим запросом, обрабатывая параметры вида :param и :regexp.
Метод извлекает динамические сегменты из URL-шаблона:
private setCallable(array $route, ?array $params): void
Calls the controller associated with the route — either a Closure or a controller method.
-------------------------
Вызывает контроллер, связанный с маршрутом — либо Closure, либо метод контроллера.
public directCall(array $route, ?array $params): void
Calls the controller and its method directly, performing the full lifecycle:
This method is used to fully dispatch a route after matching it with the current request.
-------------------------
Вызывает контроллер и его метод напрямую, выполняя полный жизненный цикл:
Метод используется для полной диспетчеризации маршрута после его совпадения с текущим запросом.
private callActionThroughReflection(?array $params, string $action, object $controller): void
Calls the controller method using Reflection, performing automatic parameter injection based on type hints.
This method is typically used when the zend.exception_ignore_args setting is enabled,
allowing for more flexible and type-safe dependency resolution.
-------------------------
Вызывает метод контроллера с помощью Reflection, выполняя автоматическое внедрение параметров на основе типизации.
Этот метод обычно используется, когда включена настройка zend.exception_ignore_args,
что позволяет более гибко и безопасно разрешать зависимости по типам.
private callActionThroughException(?array $params, string $action, object $controller): void
Calls the specified controller method directly.
If the argument type or number does not match — tries to automatically inject required dependencies.
This is a fallback mechanism for cases where Reflection-based injection is disabled or unavailable.
Handles two types of errors during invocation:
- \ArgumentCountError — thrown when the number of arguments doesn't match the method signature.
- \TypeError — thrown when an argument is not compatible with the expected type.
In both cases, Rudra's autowire system attempts to resolve and inject the correct dependencies.
-------------------------
Вызывает указанный метод контроллера напрямую.
Если тип или количество аргументов не совпадает — пытается автоматически внедрить нужные зависимости.
Это механизм отката, используемый, когда недоступен вызов через Reflection.
Обрабатываются следующие ошибки:
- \ArgumentCountError — выбрасывается, если количество аргументов не совпадает с ожидаемым.
- \TypeError — выбрасывается, если тип аргумента не соответствует ожидаемому.
В обоих случаях система автовайринга Rudra пытается разрешить и внедрить правильные зависимости.
public handleMiddleware(array $chain): void
Executes a chain of middleware, recursively calling each element.
Middleware can be specified in one of the supported formats:
- 'MiddlewareClass' (string) — a simple class name to call without parameters.
- ['MiddlewareClass'] (array with class name) — same as above, allows for future extensions.
- ['MiddlewareClass', $parameter] (array with class and parameter) — passes the parameter to the middleware.
Each middleware must implement the __invoke() method to be callable.
--------------------
Выполняет цепочку middleware, рекурсивно вызывая каждый элемент.
Middleware может быть указан в одном из поддерживаемых форматов:
- 'MiddlewareClass' (строка) — простое имя класса без параметров.
- ['MiddlewareClass'] (массив с именем класса) — аналогично предыдущему, удобно для расширения.
- ['MiddlewareClass', $parameter] (массив с классом и параметром) — передаёт параметр в middleware.
Каждый middleware должен реализовывать метод __invoke(), чтобы быть вызываемым.
public annotationCollector(array $controllers, bool $getter, bool $attributes): ?array
Collects and processes annotations from the specified controllers.
This method scans each controller class for Routing and Middleware annotations,
builds route definitions based on those annotations, and either:
- Registers them directly via set() (if $getter = false), or
- Returns them as an array (if $getter = true).
--------------------
Собирает и обрабатывает аннотации указанных контроллеров.
Метод сканирует каждый контроллер на наличие аннотаций Routing и Middleware,
формирует определения маршрутов и либо:
- Регистрирует их напрямую через set() (если $getter = false),
- Возвращает как массив (если $getter = true).
protected handleAnnotationMiddleware(array $annotation): array
Processes middleware annotations into a valid middleware format.
--------------------
Обрабатывает аннотации middleware в поддерживаемый формат.
#[Middleware(name: "Auth", params: "admin")]
в:
['Auth', 'admin']
public __construct(Rudra\Container\Interfaces\RudraInterface $rudra)
public rudra(): Rudra\Container\Interfaces\RudraInterface
public get(string $pattern, callable|array $target, array $middleware): void
Registers a route with the GET HTTP method.
--------------------
Регистрирует маршрут с использованием метода GET.
public post(string $pattern, callable|array $target, array $middleware): void
Registers a route with the POST HTTP method.
--------------------
Регистрирует маршрут с использованием метода POST.
public put(string $pattern, callable|array $target, array $middleware): void
Registers a route with the PUT HTTP method.
--------------------
Регистрирует маршрут с использованием метода PUT.
public patch(string $pattern, callable|array $target, array $middleware): void
Registers a route with the PATCH HTTP method.
--------------------
Регистрирует маршрут с использованием метода PATCH.
public delete(string $pattern, callable|array $target, array $middleware): void
Registers a route with the DELETE HTTP method.
--------------------
Регистрирует маршрут с использованием метода DELETE.
public any(string $pattern, callable|array $target, array $middleware): void
Registers a route that supports all HTTP methods.
Sets the method to a pipe-separated string ('GET|POST|PUT|PATCH|DELETE'),
allowing the same route to handle multiple request types.
--------------------
Регистрирует маршрут, поддерживающий все HTTP-методы.
Устанавливает метод как строку с разделителем | ('GET|POST|PUT|PATCH|DELETE'),
что позволяет использовать один маршрут для нескольких типов запросов.
public resource(string $pattern, string $controller, array $actions): void
Registers a resource route, mapping standard actions to controller methods.
Supports common CRUD operations by default:
- GET=> read
- POST => create
- PUT=> update
- DELETE => delete
Can be customized with an optional $actions array.
--------------------
Регистрирует ресурсный маршрут, связывая стандартные действия с методами контроллера.
По умолчанию поддерживает CRUD-операции:
- GET=> read
- POST => create
- PUT=> update
- DELETE => delete
Может быть переопределён с помощью массива $actions.
protected setRoute(string $pattern, $target, string $httpMethod, array $middleware): void
The method constructs a route definition and passes it to the set() method for registration.
--------------------
Метод формирует определение маршрута и передает его в метод set() для регистрации.

Class: Rudra\Router\RouterFacade

Visibility Function
public static __callStatic(string $method, array $parameters): ?mixed

Class: Rudra\Router\RouterInterface

Visibility Function
abstract public set(array $route): void
Sets the route, parsing HTTP methods (if multiple are specified via |).
Registers a route handler for each method.
-------------------------
Устанавливает маршрут, разбирая HTTP-методы (если указано несколько через |).
Для каждого метода регистрирует обработчик маршрута.
abstract public directCall(array $route, ?array $params): void
Calls the controller and its method directly, performing the full lifecycle:
This method is used to fully dispatch a route after matching it with the current request.
-------------------------
Вызывает контроллер и его метод напрямую, выполняя полный жизненный цикл:
Метод используется для полной диспетчеризации маршрута после его совпадения с текущим запросом.

Class: Rudra\Router\Routing

Visibility Function

Class: Rudra\Router\Traits\RouterAnnotationTrait

Visibility Function
public annotationCollector(array $controllers, bool $getter, bool $attributes): ?array
Collects and processes annotations from the specified controllers.
This method scans each controller class for Routing and Middleware annotations,
builds route definitions based on those annotations, and either:
- Registers them directly via set() (if $getter = false), or
- Returns them as an array (if $getter = true).
--------------------
Собирает и обрабатывает аннотации указанных контроллеров.
Метод сканирует каждый контроллер на наличие аннотаций Routing и Middleware,
формирует определения маршрутов и либо:
- Регистрирует их напрямую через set() (если $getter = false),
- Возвращает как массив (если $getter = true).
protected handleAnnotationMiddleware(array $annotation): array
Processes middleware annotations into a valid middleware format.
--------------------
Обрабатывает аннотации middleware в поддерживаемый формат.
#[Middleware(name: "Auth", params: "admin")]
в:
['Auth', 'admin']

Class: Rudra\Router\Traits\RouterRequestMethodTrait

Visibility Function
public get(string $pattern, callable|array $target, array $middleware): void
Registers a route with the GET HTTP method.
--------------------
Регистрирует маршрут с использованием метода GET.
public post(string $pattern, callable|array $target, array $middleware): void
Registers a route with the POST HTTP method.
--------------------
Регистрирует маршрут с использованием метода POST.
public put(string $pattern, callable|array $target, array $middleware): void
Registers a route with the PUT HTTP method.
--------------------
Регистрирует маршрут с использованием метода PUT.
public patch(string $pattern, callable|array $target, array $middleware): void
Registers a route with the PATCH HTTP method.
--------------------
Регистрирует маршрут с использованием метода PATCH.
public delete(string $pattern, callable|array $target, array $middleware): void
Registers a route with the DELETE HTTP method.
--------------------
Регистрирует маршрут с использованием метода DELETE.
public any(string $pattern, callable|array $target, array $middleware): void
Registers a route that supports all HTTP methods.
Sets the method to a pipe-separated string ('GET|POST|PUT|PATCH|DELETE'),
allowing the same route to handle multiple request types.
--------------------
Регистрирует маршрут, поддерживающий все HTTP-методы.
Устанавливает метод как строку с разделителем | ('GET|POST|PUT|PATCH|DELETE'),
что позволяет использовать один маршрут для нескольких типов запросов.
public resource(string $pattern, string $controller, array $actions): void
Registers a resource route, mapping standard actions to controller methods.
Supports common CRUD operations by default:
- GET=> read
- POST => create
- PUT=> update
- DELETE => delete
Can be customized with an optional $actions array.
--------------------
Регистрирует ресурсный маршрут, связывая стандартные действия с методами контроллера.
По умолчанию поддерживает CRUD-операции:
- GET=> read
- POST => create
- PUT=> update
- DELETE => delete
Может быть переопределён с помощью массива $actions.
protected setRoute(string $pattern, $target, string $httpMethod, array $middleware): void
The method constructs a route definition and passes it to the set() method for registration.
--------------------
Метод формирует определение маршрута и передает его в метод set() для регистрации.

created with Rudra-Documentation-Collector