getBaseRoute example


  public function getOverviewRouteParameters() {
    return $this->getBaseRouteParameters();
  }

  /** * {@inheritdoc} */
  public function getOverviewRoute() {
    $route = new Route(
      $this->getBaseRoute()->getPath() . '/translate',
      [
        '_controller' => '\Drupal\config_translation\Controller\ConfigTranslationController::itemPage',
        'plugin_id' => $this->getPluginId(),
      ],
      ['_config_translation_overview_access' => 'TRUE']
    );
    $this->processRoute($route);
    return $route;
  }

  /** * {@inheritdoc} */
/** * {@inheritdoc} */
  public function permissions() {
    return [];
  }

  /** * {@inheritdoc} */
  protected function getBaseRoute($canonical_path$method) {
    $route = parent::getBaseRoute($canonical_path$method);

    switch ($method) {
      case 'GET':
        $route->setRequirement('_entity_access', $this->entityType->id() . '.view');
        break;

      case 'POST':
        $route->setRequirement('_entity_create_any_access', $this->entityType->id());
        $route->setOption('_ignore_create_bundle_access', TRUE);
        break;

      
$definition = $this->getPluginDefinition();
    $canonical_path = $definition['uri_paths']['canonical'] ?? '/' . strtr($this->pluginId, ':', '/') . '/{id}';
    $create_path = $definition['uri_paths']['create'] ?? '/' . strtr($this->pluginId, ':', '/');

    $route_name = strtr($this->pluginId, ':', '.');

    $methods = $this->availableMethods();
    foreach ($methods as $method) {
      $path = $method === 'POST'
        ? $create_path
        : $canonical_path;
      $route = $this->getBaseRoute($path$method);

      // Note that '_format' and '_content_type_format' route requirements are       // added in ResourceRoutes::getRoutesForResourceConfig().       $collection->add("$route_name.$method", $route);
    }

    return $collection;
  }

  /** * Provides predefined HTTP request methods. * * Plugins can override this method to provide additional custom request * methods. * * @return array * The list of allowed HTTP request method strings. */

  public function testGetBaseRouteParameters() {
    $result = $this->configNamesMapper->getBaseRouteParameters();
    $this->assertSame([]$result);
  }

  /** * Tests ConfigNamesMapper::getBaseRoute(). */
  public function testGetBaseRoute() {
    $result = $this->configNamesMapper->getBaseRoute();
    $this->assertSame($this->baseRoute, $result);
  }

  /** * Tests ConfigNamesMapper::getBasePath(). */
  public function testGetBasePath() {
    $this->urlGenerator->expects($this->once())
      ->method('getPathFromRoute')
      ->with('system.site_information_settings', [])
      ->willReturn('/admin/config/system/site-information');
    
Home | Imprint | This part of the site doesn't use cookies.