diff --git a/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php b/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php index 752f6027..857285f4 100644 --- a/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php +++ b/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php @@ -230,6 +230,18 @@ final class Events */ 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. * diff --git a/src/mibew/libs/classes/Mibew/Routing/RouteCollectionLoader.php b/src/mibew/libs/classes/Mibew/Routing/RouteCollectionLoader.php index d3885a33..626c6c90 100644 --- a/src/mibew/libs/classes/Mibew/Routing/RouteCollectionLoader.php +++ b/src/mibew/libs/classes/Mibew/Routing/RouteCollectionLoader.php @@ -21,6 +21,7 @@ namespace Mibew\Routing; use Mibew\Plugin\Manager as PluginManager; use Mibew\EventDispatcher\EventDispatcher; +use Mibew\EventDispatcher\Events; use Symfony\Component\Routing\Loader\YamlFileLoader; use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Config\FileLocatorInterface; @@ -91,7 +92,7 @@ class RouteCollectionLoader // Add an ability for plugins to alter routes list $arguments = array('routes' => $collection); - EventDispatcher::getInstance()->triggerEvent('routesAlter', $arguments); + EventDispatcher::getInstance()->triggerEvent(Events::ROUTES_ALTER, $arguments); return $arguments['routes']; }