Download the PHP package secit-pl/route-injector-bundle without Composer
On this page you can find all versions of the php package secit-pl/route-injector-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download secit-pl/route-injector-bundle
More information about secit-pl/route-injector-bundle
Files in secit-pl/route-injector-bundle
Package route-injector-bundle
Short Description Route Injector Symfony Bundle.
License MIT
Homepage http://secit.pl
Informations about the package route-injector-bundle
Route injector annotation
Route injector annotation for Symfony 4.0+.
For Symfony 2.8 and 3.x please use the 1.x releases.
Installation
From the command line run
Usage
The Annotation
To inject route to the variable just add the @InjectRoute annotation to it. The the first argument is the route name. The second and other arguments are the optional configuration options.
Basic Usage
Here is the basic usage example.
The class:
And how to manually run the injector.
Doctrine Entity Usage
This bundle provides the Doctrine integration. So if you use the @InjectRoute annotation in the entity the injectRoutes processor method will be triggered on every (depending on the conditions) load, update and persist action.
Example entity:
When you create a new Example entity instance the $url will be null. But just after persist the route will be automatically injected and accessible.
Materialized Routes
In the previous example the route will be injected on each time we will load, update or store the entity but in some cases we would like to store it in the database. To achieve this simply add the Doctrine @Column annotation to make it a database field.
Configuration options
Here are all possible configuration options:
parametersMapping = array, default empty array
The array of the route parameters mapped to the public class methods from which the parameters values should be taken.
Warning! The route will not be injected if any of the parameters will be null.
absolute = bool, default false
Set to true if you'd like to have the generated URLs with the protocol and hostname prefix.
injectIfNotEmpty = bool, default false
By default the route will be injected only if the current value is empty (null, false, or the empty string). To make it updatable even if it's not empty set this option to true.
All versions of route-injector-bundle with dependencies
symfony/framework-bundle Version ^4.0|^5.0|^6.0
symfony/dependency-injection Version ^4.0|^5.0|^6.0
jms/metadata Version ^2.0