getMappers example


  public function __construct(array $mappers) {
    $this->mappers = $mappers;
  }

  /** * {@inheritdoc} */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('plugin.manager.config_translation.mapper')->getMappers()
    );
  }

  /** * Builds the mappers as a renderable array for table.html.twig. * * @return array * Renderable array with config translation mappers. */
  public function render() {
    $build = [
      
'config_translation_test',
    'language',
    'locale',
    'system',
  ];

  /** * Tests adding config names to mapper. */
  public function testAddingConfigNames() {
    // Get a config names mapper.     $mappers = \Drupal::service('plugin.manager.config_translation.mapper')->getMappers();
    $mapper = $mappers['system.site_information_settings'];

    // Test that it doesn't contain a config name from config_translation_test.     $config_names = $mapper->getConfigNames();
    $this->assertNotContains('config_translation_test.content', $config_names);

    // Call populateFromRouteMatch() to dispatch the "config mapper populate"     // event.     $mapper->populateFromRouteMatch(new RouteMatch('test', new Route('/')));

    // Test that it contains the new config name from config_translation_test.
public static function create(ContainerInterface $container$base_plugin_id) {
    return new static(
      $base_plugin_id,
      $container->get('plugin.manager.config_translation.mapper')
    );
  }

  /** * {@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;
      }
    }

  public function __construct(ConfigMapperManagerInterface $mapper_manager) {
    $this->mapperManager = $mapper_manager;
  }

  /** * {@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 create(ContainerInterface $container$base_plugin_id) {
    return new static(
      $container->get('plugin.manager.config_translation.mapper')
    );
  }

  /** * {@inheritdoc} */
  public function getDerivativeDefinitions($base_plugin_definition) {
    // Create contextual links for all mappers.     $mappers = $this->mapperManager->getMappers();
    foreach ($mappers as $plugin_id => $mapper) {
      // @todo Contextual groups do not map to entity types in a predictable       // way. See https://www.drupal.org/node/2134841 to make them       // predictable.       $group_name = $mapper->getContextualLinkGroup();
      if (empty($group_name)) {
        continue;
      }

      /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */
      $route_name = $mapper->getOverviewRouteName();
      
Home | Imprint | This part of the site doesn't use cookies.