group-8.x-1.x-dev/modules/gnode/src/Routing/RouteSubscriber.php

modules/gnode/src/Routing/RouteSubscriber.php
<?php

namespace Drupal\gnode\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Subscriber for Group Node routes.
 */
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    if ($route = $collection->get('entity.group_content.create_page')) {
      $copy = clone $route;
      $copy->setPath('group/{group}/node/create');
      $copy->setDefault('base_plugin_id', 'group_node');
      $collection->add('entity.group_content.group_node_create_page', $copy);
    }

    if ($route = $collection->get('entity.group_content.add_page')) {
      $copy = clone $route;
      $copy->setPath('group/{group}/node/add');
      $copy->setDefault('base_plugin_id', 'group_node');
      $collection->add('entity.group_content.group_node_add_page', $copy);
    }
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc