Create a Writer Object
A RouterRegister Writer object takes the internal representation of the groups and routes and transforms it into a framework specific representation. This section describes the Group and Route objects used internally. It does not describe the output as this is framework specific.
WriterInterface
A Writer object must implement WriterInterface, which defines the following methods:
Method | Parameters | Return Type | Description |
|---|---|---|---|
setPath(string $path) | string $path | self | Sets the filepath for the output files |
write(array $groups) | list<Group> $group | void | Takes the internal router configuration, an array of Group objects, and generates and writes the output files |
Group Object
The Group Object has the following methods:
Method | Return Type | Description |
|---|---|---|
getCors() | ?MiddlewareInterface | The CORS Middleware attribute object if defined, NULL if not Call |
getDisableMiddlewares() | list<MiddlewareInterface> | List of Middleware attribute objects that disable a middleware defined in an ancestor Group Call |
getHosts() | list<Host> | List of Host attribute objects that define the hosts that the Group will respond to Call |
getMiddlewares() | list<Middleware> | List of Middleware attribute objects apply to the Group Call |
getName() | string | The Group name |
getPrefix() | ?string | The Group route prefix if defined, NULL if not |
getRoutes() | list<Group|Route> | Groups and Routes in the Group |
hasCors() | bool |
|
hasHosts() | bool |
|
Route Object
Method | Return Type | Description |
|---|---|---|
getAction() | Middleware | A Middleware attribute object that defines the action to run if the route matches the request Call |
getDefaultValues() | list<DefaultValue> | List of parameter default values Call Call |
getDisableMiddlewares() | list<MiddlewareInterface> | List of Middleware attribute objects that disable a middleware defined in an ancestor Group Call |
getHosts() | list<Host> | List of Host attribute objects that define the hosts that the Route will respond to Call |
getMethods() | array | List of HTTP methods that the route responds to |
getMiddlewares() | list<Middleware> | List of Middleware attribute objects apply to the Route Call |
getName() | string | The route name |
getPattern() | string | The route pattern to match |
getPrefix() | string | |
hasDefaultValues() | bool |
|
hasHosts() | bool |
|
isFallback() | bool |
|
isHoisted() | bool |
|
isOverride() | bool |
|
Attribute Methods
This section list attributes that can be accessed from the Group and Route objects the methods to access the attribute data.
DefaultValue
Method | Return Type | Description |
|---|---|---|
getParameter() | string | The parameter name |
getValue() | string | The parameter value |
Host
Method | Return Type | Description |
|---|---|---|
getHost() | string | The host |
Middleware
Method | Return Type | Description |
|---|---|---|
getMiddleware() | string | The middleware string |