RouteLoader
in package
Fluent route definition for AHG plugins.
Modernizes route registration — plugins define routes in PHP with a clean API, and RouteLoader handles Symfony sfRouting registration.
Usage: public function configureRouting(sfEvent $event) { $router = new RouteLoader('donorAgreement'); $router->get('donor_dashboard', '/donor/dashboard', 'dashboard'); $router->get('donor_browse', '/donor/browse', 'browse'); $router->any('donor_delete', '/donor/:id/delete', 'delete', ['id' => '\d+']); $router->register($event->getSubject()); }
Table of Contents
Methods
- __construct() : mixed
- any() : self
- Register a route for any HTTP method.
- get() : self
- Register a GET route.
- getRoutes() : array<string|int, mixed>
- Get defined routes (for inspection/testing).
- post() : self
- Register a POST route.
- register() : void
- Register all defined routes with the Symfony routing system.
- registerController() : void
- Register routes for a direct AhgController (WP2).
- registerLaravel() : void
- Register all defined routes with the Laravel router.
Methods
__construct()
public
__construct(string $module) : mixed
Parameters
- $module : string
any()
Register a route for any HTTP method.
public
any(string $name, string $url, string $action[, array<string|int, mixed> $requirements = [] ][, array<string|int, mixed> $defaults = [] ]) : self
Parameters
- $name : string
- $url : string
- $action : string
- $requirements : array<string|int, mixed> = []
- $defaults : array<string|int, mixed> = []
Return values
selfget()
Register a GET route.
public
get(string $name, string $url, string $action[, array<string|int, mixed> $requirements = [] ][, array<string|int, mixed> $defaults = [] ]) : self
Parameters
- $name : string
- $url : string
- $action : string
- $requirements : array<string|int, mixed> = []
- $defaults : array<string|int, mixed> = []
Return values
selfgetRoutes()
Get defined routes (for inspection/testing).
public
getRoutes() : array<string|int, mixed>
Return values
array<string|int, mixed>post()
Register a POST route.
public
post(string $name, string $url, string $action[, array<string|int, mixed> $requirements = [] ][, array<string|int, mixed> $defaults = [] ]) : self
Parameters
- $name : string
- $url : string
- $action : string
- $requirements : array<string|int, mixed> = []
- $defaults : array<string|int, mixed> = []
Return values
selfregister()
Register all defined routes with the Symfony routing system.
public
register(sfRouting $routing) : void
Parameters
- $routing : sfRouting
registerController()
Register routes for a direct AhgController (WP2).
public
registerController(Router $router, string $controllerClass) : void
Maps route definitions directly to controller methods without ActionBridge. The controller class must extend AhgController and have execute{Action}() methods.
Parameters
- $router : Router
-
Laravel router
- $controllerClass : string
-
Fully qualified class name
registerLaravel()
Register all defined routes with the Laravel router.
public
registerLaravel(Router $router[, string $bridgeClass = null ]) : void
Converts Symfony-style URL patterns (:param) to Laravel-style ({param}) and registers them with the Illuminate Router. The ActionBridge handles dispatch to the actual plugin action classes.
Parameters
- $router : Router
- $bridgeClass : string = null