Describe "routesAlter" event in Events class

This commit is contained in:
Dmitriy Simushev 2014-10-21 12:37:07 +00:00
parent 7eea7c09d4
commit c2f0fb24c3
2 changed files with 14 additions and 1 deletions

View File

@ -230,6 +230,18 @@ final class Events
*/ */
const RESOURCE_NOT_FOUND = 'resourceNotFound'; const RESOURCE_NOT_FOUND = 'resourceNotFound';
/**
* Routes collection is loaded and ready to use.
*
* This event is triggered after all routes are loaded. It provides an
* ability for plugins to alter routes collection before it will be used. An
* associative array with the following items is passed to the event
* handlers:
* - "routes" an instance of
* {@link Symfony\Component\Routing\RouteCollection} class.
*/
const ROUTES_ALTER = 'routesAlter';
/** /**
* Thread is updated. * Thread is updated.
* *

View File

@ -21,6 +21,7 @@ namespace Mibew\Routing;
use Mibew\Plugin\Manager as PluginManager; use Mibew\Plugin\Manager as PluginManager;
use Mibew\EventDispatcher\EventDispatcher; use Mibew\EventDispatcher\EventDispatcher;
use Mibew\EventDispatcher\Events;
use Symfony\Component\Routing\Loader\YamlFileLoader; use Symfony\Component\Routing\Loader\YamlFileLoader;
use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Config\FileLocatorInterface; use Symfony\Component\Config\FileLocatorInterface;
@ -91,7 +92,7 @@ class RouteCollectionLoader
// Add an ability for plugins to alter routes list // Add an ability for plugins to alter routes list
$arguments = array('routes' => $collection); $arguments = array('routes' => $collection);
EventDispatcher::getInstance()->triggerEvent('routesAlter', $arguments); EventDispatcher::getInstance()->triggerEvent(Events::ROUTES_ALTER, $arguments);
return $arguments['routes']; return $arguments['routes'];
} }