getBaseRouteName example


  public function getBaseRouteParameters() {
    return [];
  }

  /** * {@inheritdoc} */
  public function getBaseRoute() {
    if ($this->routeCollection) {
      return $this->routeCollection->get($this->getBaseRouteName());
    }
    else {
      return $this->routeProvider->getRouteByName($this->getBaseRouteName());
    }
  }

  /** * Allows to process all config translation routes. * * @param \Symfony\Component\Routing\Route $route * The route object to process. */

  }

  /** * {@inheritdoc} */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $mappers = $this->mapperManager->getMappers();
    foreach ($mappers as $plugin_id => $mapper) {
      /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */
      $route_name = $mapper->getOverviewRouteName();
      $base_route = $mapper->getBaseRouteName();
      if (!empty($base_route)) {
        $this->derivatives[$route_name] = $base_plugin_definition;
        $this->derivatives[$route_name]['config_translation_plugin_id'] = $plugin_id;
        $this->derivatives[$route_name]['class'] = '\Drupal\config_translation\Plugin\Menu\LocalTask\ConfigTranslationLocalTask';
        $this->derivatives[$route_name]['route_name'] = $route_name;
        $this->derivatives[$route_name]['base_route'] = $base_route;
      }
    }
    return parent::getDerivativeDefinitions($base_plugin_definition);
  }

}

  }

  /** * Reacts to the populating of a configuration mapper. * * @param \Drupal\config_translation\Event\ConfigMapperPopulateEvent $event * The configuration mapper event. */
  public function addConfigNames(ConfigMapperPopulateEvent $event) {
    $mapper = $event->getMapper();
    if ($mapper->getBaseRouteName() === 'system.site_information_settings' && $mapper->getLangcode() === 'en') {
      $mapper->addConfigName('config_translation_test.content');
    }
  }

}
      $fake_route_match = RouteMatch::createFromRequest($fake_request);
      $mapper->populateFromRouteMatch($fake_route_match);
      $mapper->setLangcode($langcode);

      // Prepare the language name and the operations depending on whether this       // is the original language or not.       if ($langcode == $original_langcode) {
        $language_name = '<strong>' . $this->t('@language (original)', ['@language' => $language->getName()]) . '</strong>';

        // Check access for the path/route for editing, so we can decide to         // include a link to edit or not.         $edit_access = $this->accessManager->checkNamedRoute($mapper->getBaseRouteName()$route_match->getRawParameters()->all()$this->account);

        // Build list of operations.         $operations = [];
        if ($edit_access) {
          $operations['edit'] = [
            'title' => $this->t('Edit'),
            'url' => Url::fromRoute($mapper->getBaseRouteName()$mapper->getBaseRouteParameters()['query' => ['destination' => $mapper->getOverviewPath()]]),
          ];
        }
      }
      else {
        

  public function testGetTitle() {
    $result = $this->configNamesMapper->getTitle();
    $this->assertSame($this->pluginDefinition['title'](string) $result);
  }

  /** * Tests ConfigNamesMapper::getBaseRouteName(). */
  public function testGetBaseRouteName() {
    $result = $this->configNamesMapper->getBaseRouteName();
    $this->assertSame($this->pluginDefinition['base_route_name']$result);
  }

  /** * Tests ConfigNamesMapper::getBaseRouteParameters(). */
  public function testGetBaseRouteParameters() {
    $result = $this->configNamesMapper->getBaseRouteParameters();
    $this->assertSame([]$result);
  }

  
Home | Imprint | This part of the site doesn't use cookies.