You are here

class ConfigFieldMapper in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config_translation/src/ConfigFieldMapper.php \Drupal\config_translation\ConfigFieldMapper

Configuration mapper for fields.

On top of plugin definition values on ConfigEntityMapper, the plugin definition for field mappers are required to contain the following additional keys:

  • base_entity_type: The name of the entity type the fields are attached to.

Hierarchy

Expanded class hierarchy of ConfigFieldMapper

1 file declares its use of ConfigFieldMapper
ConfigFieldMapperTest.php in core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php
Contains \Drupal\Tests\config_translation\Unit\ConfigFieldMapperTest.

File

core/modules/config_translation/src/ConfigFieldMapper.php, line 20
Contains \Drupal\config_translation\ConfigFieldMapper.

Namespace

Drupal\config_translation
View source
class ConfigFieldMapper extends ConfigEntityMapper {

  /**
   * Loaded entity instance to help produce the translation interface.
   *
   * @var \Drupal\field\FieldConfigInterface
   */
  protected $entity;

  /**
   * {@inheritdoc}
   */
  public function getBaseRouteParameters() {
    $parameters = parent::getBaseRouteParameters();
    $base_entity_info = $this->entityManager
      ->getDefinition($this->pluginDefinition['base_entity_type']);
    $bundle_parameter_key = $base_entity_info
      ->getBundleEntityType() ?: 'bundle';
    $parameters[$bundle_parameter_key] = $this->entity
      ->getTargetBundle();
    return $parameters;
  }

  /**
   * {@inheritdoc}
   */
  public function getOverviewRouteName() {
    return 'entity.field_config.config_translation_overview.' . $this->pluginDefinition['base_entity_type'];
  }

  /**
   * {@inheritdoc}
   */
  public function getTypeLabel() {
    $base_entity_info = $this->entityManager
      ->getDefinition($this->pluginDefinition['base_entity_type']);
    return $this
      ->t('@label fields', array(
      '@label' => $base_entity_info
        ->getLabel(),
    ));
  }

  /**
   * {@inheritdoc}
   */
  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->entityManager
        ->getDefinition($field_storage
        ->getEntityTypeId());
      $this
        ->addConfigName($entity_type_info
        ->getConfigPrefix() . '.' . $field_storage
        ->id());
      return TRUE;
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigEntityMapper::$entityManager protected property The entity manager.
ConfigEntityMapper::$entityType protected property Configuration entity type name.
ConfigEntityMapper::$typeLabel protected property The label for the entity type.
ConfigEntityMapper::create public static function Creates an instance of the plugin. Overrides ConfigNamesMapper::create
ConfigEntityMapper::getContextualLinkGroup public function Returns the name of the contextual link group to add contextual links to. Overrides ConfigNamesMapper::getContextualLinkGroup
ConfigEntityMapper::getEntity public function Gets the entity instance for this mapper.
ConfigEntityMapper::getOperations public function Provides an array of information to build a list of operation links. Overrides ConfigNamesMapper::getOperations
ConfigEntityMapper::getTitle public function Returns title of this translation page. Overrides ConfigNamesMapper::getTitle
ConfigEntityMapper::getType public function Gets the entity type from this mapper.
ConfigEntityMapper::getTypeName public function Returns the name of the type of data the mapper encapsulates. Overrides ConfigNamesMapper::getTypeName
ConfigEntityMapper::populateFromRouteMatch public function Populate the config mapper with request data. Overrides ConfigNamesMapper::populateFromRouteMatch
ConfigEntityMapper::processRoute protected function Allows to process all config translation routes. Overrides ConfigNamesMapper::processRoute
ConfigEntityMapper::setType public function Set entity type for this mapper.
ConfigEntityMapper::__construct public function Constructs a ConfigEntityMapper. Overrides ConfigNamesMapper::__construct
ConfigFieldMapper::$entity protected property Loaded entity instance to help produce the translation interface. Overrides ConfigEntityMapper::$entity
ConfigFieldMapper::getBaseRouteParameters public function Returns the route parameters for the base route the mapper is attached to. Overrides ConfigEntityMapper::getBaseRouteParameters
ConfigFieldMapper::getOverviewRouteName public function Returns route name for the translation overview route. Overrides ConfigEntityMapper::getOverviewRouteName
ConfigFieldMapper::getTypeLabel public function Returns the label of the type of data the mapper encapsulates. Overrides ConfigEntityMapper::getTypeLabel
ConfigFieldMapper::setEntity public function Sets the entity instance for this mapper. Overrides ConfigEntityMapper::setEntity
ConfigNamesMapper::$baseRoute protected property The base route object that the mapper is attached to.
ConfigNamesMapper::$configFactory protected property The configuration factory.
ConfigNamesMapper::$configMapperManager protected property The mapper plugin discovery service.
ConfigNamesMapper::$langcode protected property The language code of the language this mapper, if any.
ConfigNamesMapper::$languageManager protected property The language manager.
ConfigNamesMapper::$localeConfigManager protected property The typed configuration manager.
ConfigNamesMapper::$routeCollection protected property The available routes.
ConfigNamesMapper::$routeProvider protected property The route provider.
ConfigNamesMapper::$typedConfigManager protected property The typed config manager.
ConfigNamesMapper::addConfigName public function Adds the given configuration name to the list of names. Overrides ConfigMapperInterface::addConfigName
ConfigNamesMapper::getAddRoute public function Returns the route object for a translation add form route. Overrides ConfigMapperInterface::getAddRoute
ConfigNamesMapper::getAddRouteName public function Returns route name for the translation add form route. Overrides ConfigMapperInterface::getAddRouteName
ConfigNamesMapper::getAddRouteParameters public function Returns the route parameters for the translation add form route. Overrides ConfigMapperInterface::getAddRouteParameters
ConfigNamesMapper::getBasePath public function Returns a processed path for the base route the mapper is attached to. Overrides ConfigMapperInterface::getBasePath
ConfigNamesMapper::getBaseRoute public function Returns the base route object the mapper is attached to. Overrides ConfigMapperInterface::getBaseRoute
ConfigNamesMapper::getBaseRouteName public function Returns the name of the base route the mapper is attached to. Overrides ConfigMapperInterface::getBaseRouteName
ConfigNamesMapper::getConfigData public function Returns an array with all configuration data. Overrides ConfigMapperInterface::getConfigData
ConfigNamesMapper::getConfigNames public function Returns an array of configuration names for the mapper. Overrides ConfigMapperInterface::getConfigNames
ConfigNamesMapper::getDeleteRoute public function Returns the route object for the translation deletion route. Overrides ConfigMapperInterface::getDeleteRoute
ConfigNamesMapper::getDeleteRouteName public function Returns route name for the translation deletion route. Overrides ConfigMapperInterface::getDeleteRouteName
ConfigNamesMapper::getDeleteRouteParameters public function Returns the route parameters for the translation deletion route. Overrides ConfigMapperInterface::getDeleteRouteParameters
ConfigNamesMapper::getEditRoute public function Returns the route object for a translation edit form route. Overrides ConfigMapperInterface::getEditRoute
ConfigNamesMapper::getEditRouteName public function Returns route name for the translation edit form route. Overrides ConfigMapperInterface::getEditRouteName
ConfigNamesMapper::getEditRouteParameters public function Returns the route parameters for the translation edit form route. Overrides ConfigMapperInterface::getEditRouteParameters
ConfigNamesMapper::getLangcode public function Returns the original language code of the configuration. Overrides ConfigMapperInterface::getLangcode
ConfigNamesMapper::getOverviewPath public function Returns a processed path for the translation overview route. Overrides ConfigMapperInterface::getOverviewPath
ConfigNamesMapper::getOverviewRoute public function Returns the route object for a translation overview route. Overrides ConfigMapperInterface::getOverviewRoute
ConfigNamesMapper::getOverviewRouteParameters public function Returns the route parameters for the translation overview route. Overrides ConfigMapperInterface::getOverviewRouteParameters
ConfigNamesMapper::getWeight public function Returns the weight of the mapper. Overrides ConfigMapperInterface::getWeight
ConfigNamesMapper::hasSchema public function Checks that all pieces of this configuration mapper have a schema. Overrides ConfigMapperInterface::hasSchema
ConfigNamesMapper::hasTranslatable public function Checks if pieces of this configuration mapper have translatables. Overrides ConfigMapperInterface::hasTranslatable
ConfigNamesMapper::hasTranslation public function Checks whether there is already a translation for this mapper. Overrides ConfigMapperInterface::hasTranslation
ConfigNamesMapper::setLangcode public function Sets the original language code. Overrides ConfigMapperInterface::setLangcode
ConfigNamesMapper::setRouteCollection public function Sets the route collection. Overrides ConfigMapperInterface::setRouteCollection
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
PluginBase::$configuration protected property Configuration information passed into the plugin. 2
PluginBase::$pluginDefinition protected property The plugin implementation definition.
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
StringTranslationTrait::$stringTranslation protected property The string translation service.
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.