protected function RulesUiRouteSubscriber::registerRoutes in Rules 8.3
Registers the routes as needed for the UI.
Parameters
\Drupal\rules\Ui\RulesUiDefinition $ui_definition: The definition of the RulesUI for which to register the routes.
\Symfony\Component\Routing\RouteCollection $collection: The route collection to which to add the routes.
1 call to RulesUiRouteSubscriber::registerRoutes()
- RulesUiRouteSubscriber::alterRoutes in src/
Routing/ RulesUiRouteSubscriber.php - Alters existing routes for a specific collection.
File
- src/
Routing/ RulesUiRouteSubscriber.php, line 63
Class
- RulesUiRouteSubscriber
- Adds routes generated by the rules UI handlers.
Namespace
Drupal\rules\RoutingCode
protected function registerRoutes(RulesUiDefinition $ui_definition, RouteCollection $collection) {
$base_route = $collection
->get($ui_definition->base_route);
$options = [
'parameters' => $base_route
->getOption('parameters') ?: [],
'_admin_route' => $base_route
->getOption('_admin_route') ?: FALSE,
'_rules_ui' => $ui_definition->id,
];
$requirements = [
'_permission' => $ui_definition->permissions ?: $base_route
->getRequirement('_permission'),
];
$route = (new Route($base_route
->getPath() . '/add/{expression_id}'))
->addDefaults([
'_form' => '\\Drupal\\rules\\Form\\AddExpressionForm',
'_title_callback' => '\\Drupal\\rules\\Form\\AddExpressionForm::getTitle',
])
->addOptions($options)
->addRequirements($requirements);
$collection
->add($ui_definition->base_route . '.expression.add', $route);
// Route for editing expressions in a Rule.
$route = (new Route($base_route
->getPath() . '/edit/{uuid}'))
->addDefaults([
'_form' => '\\Drupal\\rules\\Form\\EditExpressionForm',
'_title_callback' => '\\Drupal\\rules\\Form\\EditExpressionForm::getTitle',
])
->addOptions($options)
->addRequirements($requirements);
$collection
->add($ui_definition->base_route . '.expression.edit', $route);
// Route for deleting expressions from a Rule.
$route = (new Route($base_route
->getPath() . '/delete/{uuid}'))
->addDefaults([
'_form' => '\\Drupal\\rules\\Form\\DeleteExpressionForm',
'_title' => 'Delete expression',
])
->addOptions($options)
->addRequirements($requirements);
$collection
->add($ui_definition->base_route . '.expression.delete', $route);
// Route to break the lock of an edited rule.
$route = (new Route($base_route
->getPath() . '/break-lock'))
->addDefaults([
'_form' => '\\Drupal\\rules\\Form\\BreakLockForm',
'_title' => 'Break lock',
])
->addOptions($options)
->addRequirements($requirements);
$collection
->add($ui_definition->base_route . '.break_lock', $route);
// Route for data selector autocomplete.
$route = (new Route($base_route
->getPath() . '/autocomplete/{uuid}'))
->addDefaults([
'_controller' => '\\Drupal\\rules\\Controller\\AutocompleteController::autocomplete',
'uuid' => '',
])
->addOptions($options)
->addRequirements($requirements);
$collection
->add($ui_definition->base_route . '.autocomplete', $route);
}