mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-12-11 04:43:15 +00:00
Resolve "Documentation: utiliser mkdocs (avec l'extension mkdocs-material) plutôt que Sphinx"
This commit is contained in:
53
docs/source/development/routing.md
Normal file
53
docs/source/development/routing.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Routing
|
||||
|
||||
Our goal is to ease the installation of the different bundles. Users should not have to dive into complicated config files to install bundles.
|
||||
|
||||
## A routing loader is available for all bundles
|
||||
|
||||
A Chill bundle may rely on the Routing Loader defined in ChillMain.
|
||||
|
||||
The loader will load `yml` or `xml` files. You simply have to add them into `chill_main` config
|
||||
|
||||
```yaml
|
||||
chill_main:
|
||||
# ... other stuff here
|
||||
routing:
|
||||
resources:
|
||||
- @ChillMyBundle/Resources/config/routing.yml
|
||||
```
|
||||
|
||||
### Load routes automatically
|
||||
|
||||
But this forces users to modify config files. To avoid this, you may prepend config implementing the `PrependExtensionInterface` in the `YourBundleExtension` class. This is an example from **chill main** bundle :
|
||||
|
||||
```php
|
||||
namespace Chill\MainBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
|
||||
class ChillMainExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
// ...
|
||||
}
|
||||
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
|
||||
//add current route to chill main
|
||||
//this is where the resource is added automatically in the config
|
||||
$container->prependExtensionConfig('chill_main', array(
|
||||
'routing' => array(
|
||||
'resources' => array(
|
||||
'@ChillMainBundle/Resources/config/routing.yml'
|
||||
)
|
||||
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user