getEditRouteName example



  /** * {@inheritdoc} */
  protected function alterRoutes(RouteCollection $collection) {
    $mappers = $this->mapperManager->getMappers($collection);

    foreach ($mappers as $mapper) {
      $collection->add($mapper->getOverviewRouteName()$mapper->getOverviewRoute());
      $collection->add($mapper->getAddRouteName()$mapper->getAddRoute());
      $collection->add($mapper->getEditRouteName()$mapper->getEditRoute());
      $collection->add($mapper->getDeleteRouteName()$mapper->getDeleteRoute());
    }
  }

  /** * {@inheritdoc} */
  public static function getSubscribedEvents(): array {
    // Come after field_ui.     $events[RoutingEvents::ALTER] = ['onAlterRoutes', -110];
    return $events;
  }
'_config_translation_form_access' => 'TRUE',
      ]
    );
    $result = $this->configNamesMapper->getAddRoute();
    $this->assertSame(serialize($expected)serialize($result));
  }

  /** * Tests ConfigNamesMapper::getEditRouteName(). */
  public function testGetEditRouteName() {
    $result = $this->configNamesMapper->getEditRouteName();
    $expected = 'config_translation.item.edit.' . $this->pluginDefinition['base_route_name'];
    $this->assertSame($expected$result);
  }

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

    
// 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'),
            'url' => Url::fromRoute($mapper->getDeleteRouteName()$mapper->getDeleteRouteParameters()),
          ];
        }
      }

      $page['languages'][$langcode]['language'] = [
        '#markup' => $language_name,
      ];
Home | Imprint | This part of the site doesn't use cookies.