addConfigName example


  public function addConfigNames(ConfigMapperPopulateEvent $event) {
    $mapper = $event->getMapper();
    if ($mapper instanceof ConfigEntityMapper && $mapper->getType() == 'filter_format') {
      $editor_config_name = 'editor.editor.' . $mapper->getEntity()->id();
      // Only add the text editor config if it exists, otherwise we assume no       // editor has been set for this text format.       if (!$this->configFactory->get($editor_config_name)->isNew()) {
        $mapper->addConfigName($editor_config_name);
      }
    }
  }

}


    $this->entity = $entity;

    // Add the list of configuration IDs belonging to this entity. We add on a     // possibly existing list of names. This allows modules to alter the entity     // page with more names if form altering added more configuration to an     // entity. This is not a Drupal 8 best practice (ideally the configuration     // would have pluggable components), but this may happen as well.     /** @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type_info */
    $entity_type_info = $this->entityTypeManager->getDefinition($this->entityType);
    $this->addConfigName($entity_type_info->getConfigPrefix() . '.' . $entity->id());

    return TRUE;
  }

  /** * {@inheritdoc} */
  public function getTitle() {
    return $this->entity->label() . ' ' . $this->pluginDefinition['title'];
  }

  


  /** * 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');
    }
  }

}
/** * {@inheritdoc} */
  public function setEntity(ConfigEntityInterface $entity) {
    parent::setEntity($entity);

    // Adds the title label to the translation form.     $node_type = $entity->id();
    $config = $this->configFactory->get("core.base_field_override.node.$node_type.title");
    if (!$config->isNew()) {
      $this->addConfigName($config->getName());
    }
  }

}

  public function setEntity(ConfigEntityInterface $entity) {
    if (parent::setEntity($entity)) {

      // Field storage config can also contain translatable values. Add the name       // of the config as well to the list of configs for this entity.       /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
      $field_storage = $this->entity->getFieldStorageDefinition();
      /** @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type_info */
      $entity_type_info = $this->entityTypeManager->getDefinition($field_storage->getEntityTypeId());
      $this->addConfigName($entity_type_info->getConfigPrefix() . '.' . $field_storage->id());
      return TRUE;
    }
    return FALSE;
  }

}

  public function testGetConfigNames() {
    $result = $this->configNamesMapper->getConfigNames();
    $this->assertSame($this->pluginDefinition['names']$result);
  }

  /** * Tests ConfigNamesMapper::addConfigName(). */
  public function testAddConfigName() {
    $names = $this->configNamesMapper->getConfigNames();
    $this->configNamesMapper->addConfigName('test');
    $names[] = 'test';
    $result = $this->configNamesMapper->getConfigNames();
    $this->assertSame($names$result);
  }

  /** * Tests ConfigNamesMapper::getWeight(). */
  public function testGetWeight() {
    $result = $this->configNamesMapper->getWeight();
    $this->assertSame($this->pluginDefinition['weight']$result);
  }
Home | Imprint | This part of the site doesn't use cookies.