class Color extends DestinationBase implements ContainerFactoryPluginInterface (View source)

Persist color data to the config system.

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 bool $supportsRollback

Indicates whether the destination can be rolled back.

from  DestinationBase
protected int $rollbackAction

The rollback action to be saved for the last imported item.

from  DestinationBase
protected MigrationInterface $migration

The migration.

from  DestinationBase
protected ConfigFactoryInterface $configFactory

The configuration factory.

Methods

__construct(array $configuration, string $plugin_id, mixed $plugin_definition, MigrationInterface $migration, ConfigFactoryInterface $config_factory)

Constructs a Color object.

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.

int
rollbackAction()

The rollback action for the last imported item.

checkRequirements()

Checks if requirements for this plugin are OK.

rollback(array $destination_identifier)

Delete the specified destination object from the target Drupal.

bool
supportsRollback()

Whether the destination can be rolled back or not.

setRollbackAction(array $id_map, int $update_action = MigrateIdMapInterface::ROLLBACK_PRESERVE)

For a destination item being updated, set the appropriate rollback action.

string|null
getDestinationModule()

Gets the destination module handling the destination data.

create(ContainerInterface $container, array $configuration, string $plugin_id, mixed $plugin_definition, MigrationInterface $migration = NULL)

Creates an instance of the plugin.

array|bool
import(Row $row, array $old_destination_id_values = [])

Import the row.

array[]
getIds()

Gets the destination IDs.

array
fields()

Returns an array of destination fields.

Details

__construct(array $configuration, string $plugin_id, mixed $plugin_definition, MigrationInterface $migration, ConfigFactoryInterface $config_factory)

Constructs a Color object.

Parameters

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.

MigrationInterface $migration

The migration.

ConfigFactoryInterface $config_factory

The configuration factory.

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.

int rollbackAction()

The rollback action for the last imported item.

Return Value

int

The MigrateIdMapInterface::ROLLBACK_ constant indicating how an imported item should be handled on rollback.

checkRequirements()

Checks if requirements for this plugin are OK.

rollback(array $destination_identifier)

Delete the specified destination object from the target Drupal.

Parameters

array $destination_identifier

The ID of the destination object to delete.

bool supportsRollback()

Whether the destination can be rolled back or not.

Return Value

bool

TRUE if rollback is supported, FALSE if not.

protected setRollbackAction(array $id_map, int $update_action = MigrateIdMapInterface::ROLLBACK_PRESERVE)

For a destination item being updated, set the appropriate rollback action.

Parameters

array $id_map

The map row data for the item.

int $update_action

The rollback action to take if we are updating an existing item.

string|null getDestinationModule()

Gets the destination module handling the destination data.

Return Value

string|null

The destination module or NULL if not found.

static ContainerFactoryPluginInterface create(ContainerInterface $container, array $configuration, string $plugin_id, mixed $plugin_definition, MigrationInterface $migration = NULL)

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.

MigrationInterface $migration

Return Value

ContainerFactoryPluginInterface

Returns an instance of this plugin.

array|bool import(Row $row, array $old_destination_id_values = [])

Import the row.

Derived classes must implement import(), to construct one new object (pre-populated) using ID mappings in the Migration.

Parameters

Row $row

The row object.

array $old_destination_id_values

(optional) The old destination IDs. Defaults to an empty array.

Return Value

array|bool

An indexed array of destination IDs in the same order as defined in the plugin's getIds() method if the plugin wants to save the IDs to the ID map, TRUE to indicate success without saving IDs to the ID map, or FALSE to indicate a failure.

array[] getIds()

Gets the destination IDs.

To support MigrateIdMap maps, derived destination classes should return field definition(s) corresponding to the primary key of the destination being implemented. These are used to construct the destination key fields of the map table for a migration using this destination.

Return Value

array[]

An associative array of field definitions keyed by field ID. Values are associative arrays with a structure that contains the field type ('type' key). The other keys are the field storage settings as they are returned by FieldStorageDefinitionInterface::getSettings(). As an example, for a composite destination primary key that is defined by an integer and a string, the returned value might look like: @code return [ 'id' => [ 'type' => 'integer', 'unsigned' => FALSE, 'size' => 'big', ], 'version' => [ 'type' => 'string', 'max_length' => 64, 'is_ascii' => TRUE, ], ]; @endcode If 'type' points to a field plugin with multiple columns and needs to refer to a column different than 'value', the key of that column will be appended as a suffix to the plugin name, separated by dot ('.'). Example: @code return [ 'format' => [ 'type' => 'text.format', ], ]; @endcode Additional custom keys/values, that are not part of field storage definition, can be passed in definitions: @code return [ 'nid' => [ 'type' => 'integer', 'custom_setting' => 'some_value', ], ]; @endcode

array fields()

Returns an array of destination fields.

Derived classes must implement fields(), returning a list of available destination fields.

Return Value

array
  • Keys: machine names of the fields
  • Values: Human-friendly descriptions of the fields.