You are here

protected function RouteSubscriber::alterRoutes in Paragraphs frontend ui 8.2

Alters existing routes for a specific collection.

Parameters

\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.

Overrides RouteSubscriberBase::alterRoutes

File

src/Routing/RouteSubscriber.php, line 19

Class

RouteSubscriber
Class RouteSubscriber.

Namespace

Drupal\paragraphs_frontend_ui\Routing

Code

protected function alterRoutes(RouteCollection $collection) {
  if ($route = $collection
    ->get('paragraphs_edit.edit_form')) {
    $config = \Drupal::config(SettingsForm::SETTINGS_NAME);
    $route
      ->addDefaults([
      '_entity_form' => $config
        ->get('pfui_edit_content_form_mode'),
    ]);
    $route
      ->addRequirements([
      '_custom_access' => '\\Drupal\\paragraphs_frontend_ui\\Controller\\ParagraphsFrontendUIController::accessEditContent',
    ]);
  }
  if ($route = $collection
    ->get('paragraphs_edit.delete_form')) {
    $route
      ->addRequirements([
      '_custom_access' => '\\Drupal\\paragraphs_frontend_ui\\Controller\\ParagraphsFrontendUIController::accessLibraryItem',
    ]);
  }
}