class ConfigEntityMapper extends ConfigNamesMapper (View source)

Configuration mapper for configuration entities.

Traits

Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.

Provides dependency injection friendly methods for serialization.

Provides a trait for the messenger service.

Constants

DERIVATIVE_SEPARATOR

A string which is used to separate base plugin IDs from the derivative ID.

Properties

protected string $pluginId

The plugin_id.

from  PluginBase
protected array $pluginDefinition

The plugin implementation definition.

from  PluginBase
protected array $configuration

Configuration information passed into the plugin.

from  PluginBase
protected TranslationInterface $stringTranslation

The string translation service.

from  StringTranslationTrait
protected array $_serviceIds

An array of service IDs keyed by property name used for serialization.

from  DependencySerializationTrait
protected array $_entityStorages

An array of entity type IDs keyed by the property name of their storages.

from  DependencySerializationTrait
protected MessengerInterface $messenger

The messenger.

from  MessengerTrait
protected ConfigFactoryInterface $configFactory

The configuration factory.

from  ConfigNamesMapper
protected TypedConfigManagerInterface $typedConfigManager

The typed config manager.

from  ConfigNamesMapper
protected LocaleConfigManager $localeConfigManager

The typed configuration manager.

from  ConfigNamesMapper
protected ConfigMapperManagerInterface $configMapperManager

The mapper plugin discovery service.

from  ConfigNamesMapper
protected RouteProviderInterface $routeProvider

The route provider.

from  ConfigNamesMapper
protected Route $baseRoute

The base route object that the mapper is attached to.

from  ConfigNamesMapper
protected RouteCollection $routeCollection

The available routes.

from  ConfigNamesMapper
protected string|null $langcode

The language code of the language this mapper, if any.

from  ConfigNamesMapper
protected LanguageManagerInterface $languageManager

The language manager.

from  ConfigNamesMapper
protected EventDispatcherInterface $eventDispatcher

The event dispatcher.

from  ConfigNamesMapper
protected EntityTypeManagerInterface $entityTypeManager

The entity type manager.

protected string $entityType

Configuration entity type name.

protected ConfigEntityInterface $entity

Loaded entity instance to help produce the translation interface.

protected string $typeLabel

The label for the entity type.

Methods

__construct(string $plugin_id, mixed $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $translation_manager, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, EventDispatcherInterface $event_dispatcher = NULL)

Constructs a ConfigEntityMapper.

string
getPluginId()

Gets the plugin_id of the plugin instance.

string
getBaseId()

Gets the base_plugin_id of the plugin instance.

string|null
getDerivativeId()

Gets the derivative_id of the plugin instance.

array
getPluginDefinition()

Gets the definition of the plugin implementation.

bool
isConfigurable()

Determines if the plugin is configurable.

t(string $string, array $args = [], array $options = [])

Translates a string to the current language or to a given language.

formatPlural($count, $singular, $plural, array $args = [], array $options = [])

Formats a string containing a count of items.

getNumberOfPlurals($langcode = NULL)

Returns the number of plurals supported by a given language.

getStringTranslation()

Gets the string translation service.

$this
setStringTranslation(TranslationInterface $translation)

Sets the string translation service to use.

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

setMessenger(MessengerInterface $messenger)

Sets the messenger.

messenger()

Gets the messenger.

create(ContainerInterface $container, array $configuration, string $plugin_id, mixed $plugin_definition)

Creates an instance of the plugin.

setRouteCollection(RouteCollection $collection)

Sets the route collection.

string
getTitle()

Returns title of this translation page.

string
getBaseRouteName()

Returns the name of the base route the mapper is attached to.

array
getBaseRouteParameters()

Returns the route parameters for the base route the mapper is attached to.

Route
getBaseRoute()

Returns the base route object the mapper is attached to.

processRoute(Route $route)

Allows to process all config translation routes.

string
getBasePath()

Returns a processed path for the base route the mapper is attached to.

string
getOverviewRouteName()

Returns route name for the translation overview route.

array
getOverviewRouteParameters()

Returns the route parameters for the translation overview route.

Route
getOverviewRoute()

Returns the route object for a translation overview route.

string
getOverviewPath()

Returns a processed path for the translation overview route.

string
getAddRouteName()

Returns route name for the translation add form route.

array
getAddRouteParameters()

Returns the route parameters for the translation add form route.

Route
getAddRoute()

Returns the route object for a translation add form route.

string
getEditRouteName()

Returns route name for the translation edit form route.

array
getEditRouteParameters()

Returns the route parameters for the translation edit form route.

Route
getEditRoute()

Returns the route object for a translation edit form route.

string
getDeleteRouteName()

Returns route name for the translation deletion route.

array
getDeleteRouteParameters()

Returns the route parameters for the translation deletion route.

Route
getDeleteRoute()

Returns the route object for the translation deletion route.

array
getConfigNames()

Returns an array of configuration names for the mapper.

addConfigName(string $name)

Adds the given configuration name to the list of names.

int
getWeight()

Returns the weight of the mapper.

populateFromRouteMatch(RouteMatchInterface $route_match)

Populate the config mapper with route match data.

string
getTypeLabel()

Returns the label of the type of data the mapper encapsulates.

getLangcode()

Returns the original language code of the configuration.

string
getLangcodeFromConfig(string $config_name)

Returns the language code of a configuration object given its name.

$this
setLangcode(string $langcode)

Sets the original language code.

array
getConfigData()

Returns an array with all configuration data.

bool
hasSchema()

Checks that all pieces of this configuration mapper have a schema.

bool
hasTranslatable()

Checks if pieces of this configuration mapper have translatables.

bool
hasTranslation(LanguageInterface $language)

Checks whether there is already a translation for this mapper.

string
getTypeName()

Returns the name of the type of data the mapper encapsulates.

array
getOperations()

Provides an array of information to build a list of operation links.

string|null
getContextualLinkGroup()

Returns the name of the contextual link group to add contextual links to.

getEntity()

Gets the entity instance for this mapper.

bool
setEntity(ConfigEntityInterface $entity)

Sets the entity instance for this mapper.

bool
setType(string $entity_type)

Set entity type for this mapper.

string
getType()

Gets the entity type from this mapper.

Details

__construct(string $plugin_id, mixed $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $translation_manager, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, EventDispatcherInterface $event_dispatcher = NULL)

Constructs a ConfigEntityMapper.

Parameters

string $plugin_id

The plugin_id for the plugin instance.

mixed $plugin_definition

The plugin implementation definition.

ConfigFactoryInterface $config_factory

The configuration factory.

TypedConfigManagerInterface $typed_config

The typed configuration manager.

LocaleConfigManager $locale_config_manager

The locale configuration manager.

ConfigMapperManagerInterface $config_mapper_manager

The mapper plugin discovery service.

RouteProviderInterface $route_provider

The route provider.

TranslationInterface $translation_manager

The string translation manager.

EntityTypeManagerInterface $entity_type_manager

The entity type manager.

LanguageManagerInterface $language_manager

The language manager.

EventDispatcherInterface $event_dispatcher

(optional) The event dispatcher.

string getPluginId()

Gets the plugin_id of the plugin instance.

Return Value

string

The plugin_id of the plugin instance.

string getBaseId()

Gets the base_plugin_id of the plugin instance.

Return Value

string

The base_plugin_id of the plugin instance.

string|null getDerivativeId()

Gets the derivative_id of the plugin instance.

Return Value

string|null

The derivative_id of the plugin instance NULL otherwise.

array getPluginDefinition()

Gets the definition of the plugin implementation.

Return Value

array

The plugin definition, as returned by the discovery object used by the plugin manager.

bool isConfigurable()

Determines if the plugin is configurable.

Return Value

bool

A boolean indicating whether the plugin is configurable.

protected TranslatableMarkup t(string $string, array $args = [], array $options = [])

Translates a string to the current language or to a given language.

See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for important security information and usage guidelines.

In order for strings to be localized, make them available in one of the ways supported by the

Parameters

string $string

A string containing the English text to translate.

array $args

(optional) An associative array of replacements to make after translation. Based on the first character of the key, the value is escaped and/or themed. See \Drupal\Component\Render\FormattableMarkup::placeholderFormat() for details.

array $options

(optional) An associative array of additional options, with the following elements:

  • 'langcode' (defaults to the current language): A language code, to translate to a language other than what is used to display the page.
  • 'context' (defaults to the empty context): The context the source string belongs to. See the @link i18n Internationalization topic @endlink for more information about string contexts.

Return Value

TranslatableMarkup

An object that, when cast to a string, returns the translated string.

See also

FormattableMarkup::placeholderFormat
TranslatableMarkup::__construct

protected formatPlural($count, $singular, $plural, array $args = [], array $options = [])

Formats a string containing a count of items.

Parameters

$count
$singular
$plural
array $args
array $options

See also

TranslationInterface::formatPlural

protected getNumberOfPlurals($langcode = NULL)

Returns the number of plurals supported by a given language.

Parameters

$langcode

See also

PluralFormulaInterface::getNumberOfPlurals

protected TranslationInterface getStringTranslation()

Gets the string translation service.

Return Value

TranslationInterface

The string translation service.

$this setStringTranslation(TranslationInterface $translation)

Sets the string translation service to use.

Parameters

TranslationInterface $translation

The string translation service.

Return Value

$this

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

setMessenger(MessengerInterface $messenger)

Sets the messenger.

Parameters

MessengerInterface $messenger

The messenger.

MessengerInterface messenger()

Gets the messenger.

Return Value

MessengerInterface

The messenger.

static ContainerFactoryPluginInterface create(ContainerInterface $container, array $configuration, string $plugin_id, mixed $plugin_definition)

Creates an instance of the plugin.

Parameters

ContainerInterface $container

The container to pull out services used in the plugin.

array $configuration

A configuration array containing information about the plugin instance.

string $plugin_id

The plugin ID for the plugin instance.

mixed $plugin_definition

The plugin implementation definition.

Return Value

ContainerFactoryPluginInterface

Returns an instance of this plugin.

setRouteCollection(RouteCollection $collection)

Sets the route collection.

Parameters

RouteCollection $collection

The route collection.

string getTitle()

Returns title of this translation page.

Return Value

string

The page title.

string getBaseRouteName()

Returns the name of the base route the mapper is attached to.

Return Value

string

The name of the base route the mapper is attached to.

array getBaseRouteParameters()

Returns the route parameters for the base route the mapper is attached to.

Return Value

array

Route getBaseRoute()

Returns the base route object the mapper is attached to.

Return Value

Route

The base route object the mapper is attached to.

protected processRoute(Route $route)

Allows to process all config translation routes.

Parameters

Route $route

The route object to process.

string getBasePath()

Returns a processed path for the base route the mapper is attached to.

Return Value

string

Processed path with placeholders replaced.

string getOverviewRouteName()

Returns route name for the translation overview route.

Return Value

string

Route name for the mapper.

array getOverviewRouteParameters()

Returns the route parameters for the translation overview route.

Return Value

array

Route getOverviewRoute()

Returns the route object for a translation overview route.

Return Value

Route

The route object for the translation page.

string getOverviewPath()

Returns a processed path for the translation overview route.

Return Value

string

Processed path with placeholders replaced.

string getAddRouteName()

Returns route name for the translation add form route.

Return Value

string

Route name for the mapper.

array getAddRouteParameters()

Returns the route parameters for the translation add form route.

Return Value

array

Route getAddRoute()

Returns the route object for a translation add form route.

Return Value

Route

The route object for the translation page.

string getEditRouteName()

Returns route name for the translation edit form route.

Return Value

string

Route name for the mapper.

array getEditRouteParameters()

Returns the route parameters for the translation edit form route.

Return Value

array

Route getEditRoute()

Returns the route object for a translation edit form route.

Return Value

Route

The route object for the translation page.

string getDeleteRouteName()

Returns route name for the translation deletion route.

Return Value

string

Route name for the mapper.

array getDeleteRouteParameters()

Returns the route parameters for the translation deletion route.

Return Value

array

Route getDeleteRoute()

Returns the route object for the translation deletion route.

Return Value

Route

The route object for the translation page.

array getConfigNames()

Returns an array of configuration names for the mapper.

Return Value

array

An array of configuration names for the mapper.

addConfigName(string $name)

Adds the given configuration name to the list of names.

Note that it is the responsibility of the calling code to ensure that the configuration exists.

Parameters

string $name

Configuration name.

int getWeight()

Returns the weight of the mapper.

Return Value

int

The weight of the mapper.

populateFromRouteMatch(RouteMatchInterface $route_match)

Populate the config mapper with route match data.

Parameters

RouteMatchInterface $route_match

The route match.

string getTypeLabel()

Returns the label of the type of data the mapper encapsulates.

Return Value

string

The label of the type of data the mapper encapsulates.

getLangcode()

Returns the original language code of the configuration.

Exceptions

RuntimeException

string getLangcodeFromConfig(string $config_name)

Returns the language code of a configuration object given its name.

Parameters

string $config_name

The name of the configuration object.

Return Value

string

The language code of the configuration object.

$this setLangcode(string $langcode)

Sets the original language code.

Parameters

string $langcode

The langcode.

Return Value

$this

array getConfigData()

Returns an array with all configuration data.

Return Value

array

Configuration data keyed by configuration names.

bool hasSchema()

Checks that all pieces of this configuration mapper have a schema.

Return Value

bool

TRUE if all of the elements have schema, FALSE otherwise.

bool hasTranslatable()

Checks if pieces of this configuration mapper have translatables.

Return Value

bool

TRUE if at least one of the configuration elements has translatables, FALSE otherwise.

bool hasTranslation(LanguageInterface $language)

Checks whether there is already a translation for this mapper.

Parameters

LanguageInterface $language

A language object.

Return Value

bool

TRUE if any of the configuration elements have a translation in the given language, FALSE otherwise.

string getTypeName()

Returns the name of the type of data the mapper encapsulates.

Return Value

string

The name of the type of data the mapper encapsulates.

array getOperations()

Provides an array of information to build a list of operation links.

Return Value

array

An associative array of operation link data for this list, keyed by operation name, containing the following key-value pairs:

  • title: The localized title of the operation.
  • href: The path for the operation.
  • options: An array of URL options for the path.
  • weight: The weight of this operation.

string|null getContextualLinkGroup()

Returns the name of the contextual link group to add contextual links to.

Return Value

string|null

A contextual link group name or null if no link should be added.

ConfigEntityInterface getEntity()

Gets the entity instance for this mapper.

Return Value

ConfigEntityInterface

The configuration entity.

bool setEntity(ConfigEntityInterface $entity)

Sets the entity instance for this mapper.

This method can only be invoked when the concrete entity is known, that is in a request for an entity translation path. After this method is called, the mapper is fully populated with the proper display title and configuration names to use to check permissions or display a translation screen.

Parameters

ConfigEntityInterface $entity

The configuration entity to set.

Return Value

bool

TRUE, if the entity was set successfully; FALSE otherwise.

bool setType(string $entity_type)

Set entity type for this mapper.

This should be set in initialization. A mapper that knows its type but not yet its names is still useful for router item and tab generation. The concrete entity only turns out later with actual controller invocations, when the setEntity() method is invoked before the rest of the methods are used.

Parameters

string $entity_type

The entity type to set.

Return Value

bool

TRUE if the entity type was set correctly; FALSE otherwise.

string getType()

Gets the entity type from this mapper.

Return Value

string