abstract class MediaMigrationFieldInstanceSettingsProcessPluginBase in Media Migration 8
Base class for Media Migration's field instance settings plugins.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\migrate\ProcessPluginBase implements MigrateProcessInterface
- class \Drupal\media_migration\Plugin\migrate\process\MediaMigrationFieldInstanceSettingsProcessPluginBase implements ContainerFactoryPluginInterface uses MigrationDeriverTrait
- class \Drupal\migrate\ProcessPluginBase implements MigrateProcessInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of MediaMigrationFieldInstanceSettingsProcessPluginBase
File
- src/
Plugin/ migrate/ process/ MediaMigrationFieldInstanceSettingsProcessPluginBase.php, line 18
Namespace
Drupal\media_migration\Plugin\migrate\processView source
abstract class MediaMigrationFieldInstanceSettingsProcessPluginBase extends ProcessPluginBase implements ContainerFactoryPluginInterface {
use MigrationDeriverTrait;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a new plugin instance.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity_type.manager'));
}
/**
* Returns data of media types which will be available after the migration.
*
* @return array
* Array of the media type's source data, keyed by the media type ID.
*/
protected function getPredictedMediaTypeData() : array {
$media_types = [];
$media_type_file_plain_source = static::getSourcePlugin('d7_file_plain_type');
foreach ($media_type_file_plain_source as $row) {
assert($row instanceof Row);
$media_types[$row
->getSourceProperty('bundle')] = $row
->getSource();
}
$media_type_file_entity_source = static::getSourcePlugin('d7_file_entity_type');
try {
foreach ($media_type_file_entity_source as $row) {
assert($row instanceof Row);
$media_types[$row
->getSourceProperty('bundle')] = $media_types[$row
->getSourceProperty('bundle')] ?? $row
->getSource();
}
} catch (DatabaseExceptionWrapper $e) {
// File entity source requirements are not always fulfilled.
}
return $media_types;
}
/**
* Returns data about the already existing media types.
*
* @return array
* Array of some media type data, keyed by the media type ID.
*/
protected function getExistingMediaTypeData() {
$existing_media_types = $this->entityTypeManager
->getStorage('media_type')
->loadMultiple();
return array_reduce($existing_media_types, function (array $carry, MediaTypeInterface $media_type) {
if (!$media_type
->status()) {
return $carry;
}
$media_type_id = $media_type
->id();
$source_plugin = $media_type
->getSource();
$source_field_definition = $source_plugin
->getSourceFieldDefinition($media_type);
if (!$source_field_definition instanceof FieldDefinitionInterface) {
return $carry;
}
$source_field_storage_definition = $source_field_definition
->getFieldStorageDefinition();
$carry[$media_type_id] = [
'bundle' => $media_type_id,
'source_plugin_id' => $source_plugin
->getPluginId(),
'scheme' => $source_field_storage_definition
->getSettings()['uri_scheme'] ?? NULL,
];
return $carry;
}, []);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
MediaMigrationFieldInstanceSettingsProcessPluginBase:: |
protected | property | The entity type manager. | |
MediaMigrationFieldInstanceSettingsProcessPluginBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
MediaMigrationFieldInstanceSettingsProcessPluginBase:: |
protected | function | Returns data about the already existing media types. | |
MediaMigrationFieldInstanceSettingsProcessPluginBase:: |
protected | function | Returns data of media types which will be available after the migration. | |
MediaMigrationFieldInstanceSettingsProcessPluginBase:: |
public | function |
Constructs a new plugin instance. Overrides PluginBase:: |
|
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
MigrationDeriverTrait:: |
public static | function | Returns a fully initialized instance of a source plugin. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
ProcessPluginBase:: |
public | function |
Indicates whether the returned value requires multiple handling. Overrides MigrateProcessInterface:: |
3 |
ProcessPluginBase:: |
public | function |
Performs the associated process. Overrides MigrateProcessInterface:: |
70 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |