3 namespace Drupal\devel\Form;
5 use Drupal\Core\Form\ConfirmFormBase;
6 use Drupal\Core\Form\FormStateInterface;
7 use Drupal\Core\Routing\RouteBuilderInterface;
9 use Symfony\Component\DependencyInjection\ContainerInterface;
12 * Provides confirmation form for rebuilding the routes.
14 class RouterRebuildConfirmForm extends ConfirmFormBase {
17 * The route builder service.
19 * @var \Drupal\Core\Routing\RouteBuilderInterface
21 protected $routeBuilder;
24 * Constructs a new RouterRebuildConfirmForm object.
26 * @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder
27 * The route builder service.
29 public function __construct(RouteBuilderInterface $route_builder) {
30 $this->routeBuilder = $route_builder;
36 public static function create(ContainerInterface $container) {
38 $container->get('router.builder')
45 public function getFormId() {
46 return 'devel_menu_rebuild';
52 public function getQuestion() {
53 return $this->t('Are you sure you want to rebuild the router?');
59 public function getCancelUrl() {
60 return new Url('<front>');
66 public function getDescription() {
67 return $this->t('Rebuilds the routes information gathering all routing data from .routing.yml files and from classes which subscribe to the route build events. This action cannot be undone.');
73 public function getConfirmText() {
74 return $this->t('Rebuild');
80 public function submitForm(array &$form, FormStateInterface $form_state) {
81 $this->routeBuilder->rebuild();
82 drupal_set_message($this->t('The router has been rebuilt.'));
83 $form_state->setRedirect('<front>');