getAddRouteParameters example


        }
      }
      else {
        $language_name = $language->getName();

        $operations = [];
        // If no translation exists for this language, link to add one.         if (!$mapper->hasTranslation($language)) {
          $operations['add'] = [
            'title' => $this->t('Add'),
            'url' => Url::fromRoute($mapper->getAddRouteName()$mapper->getAddRouteParameters()),
          ];
        }
        else {
          // Otherwise, link to edit the existing translation.           $operations['edit'] = [
            'title' => $this->t('Edit'),
            'url' => Url::fromRoute($mapper->getEditRouteName()$mapper->getEditRouteParameters()),
          ];

          $operations['delete'] = [
            'title' => $this->t('Delete'),
            
/** * {@inheritdoc} */
  public function getEditRouteName() {
    return 'config_translation.item.edit.' . $this->getBaseRouteName();
  }

  /** * {@inheritdoc} */
  public function getEditRouteParameters() {
    return $this->getAddRouteParameters();
  }

  /** * {@inheritdoc} */
  public function getEditRoute() {
    $route = new Route(
      $this->getBaseRoute()->getPath() . '/translate/{langcode}/edit',
      [
        '_form' => '\Drupal\config_translation\Form\ConfigTranslationEditForm',
        'plugin_id' => $this->getPluginId(),
      ],
$this->assertSame($expected$result);
  }

  /** * Tests ConfigNamesMapper::getAddRouteParameters(). */
  public function testGetAddRouteParameters() {
    $route_match = new RouteMatch('example', new Route('/test/{langcode}')['langcode' => 'xx']);
    $this->configNamesMapper->populateFromRouteMatch($route_match);

    $expected = ['langcode' => 'xx'];
    $result = $this->configNamesMapper->getAddRouteParameters();
    $this->assertSame($expected$result);
  }

  /** * Tests ConfigNamesMapper::getAddRoute(). */
  public function testGetAddRoute() {
    $expected = new Route('/admin/config/system/site-information/translate/{langcode}/add',
      [
        '_form' => '\Drupal\config_translation\Form\ConfigTranslationAddForm',
        'plugin_id' => 'system.site_information_settings',
      ],
Home | Imprint | This part of the site doesn't use cookies.