class MetatagFieldDeriver in Metatag 8
@todo.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\metatag\Plugin\migrate\source\d7\MetatagFieldDeriver implements ContainerDeriverInterface uses StringTranslationTrait, MigrationDeriverTrait, MigrationConfigurationTrait
Expanded class hierarchy of MetatagFieldDeriver
1 string reference to 'MetatagFieldDeriver'
- d7_metatag_field.yml in migrations/
d7_metatag_field.yml - migrations/d7_metatag_field.yml
File
- src/
Plugin/ migrate/ source/ d7/ MetatagFieldDeriver.php, line 20
Namespace
Drupal\metatag\Plugin\migrate\source\d7View source
class MetatagFieldDeriver extends DeriverBase implements ContainerDeriverInterface {
use MigrationDeriverTrait;
use MigrationConfigurationTrait;
use StringTranslationTrait;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a MetatagFieldDeriver instance.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('entity_type.manager'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$source = $this
->getSourcePlugin('d7_metatag_field');
assert($source instanceof DrupalSqlBase);
try {
$source
->checkRequirements();
} catch (RequirementsException $e) {
// If the source plugin requirements failed, that means we do not have a
// Drupal source database configured - return nothing.
return $this->derivatives;
}
$entity_type_ids = $source
->getDatabase()
->select('metatag', 'm')
->fields('m', [
'entity_type',
])
->distinct()
->execute()
->fetchAllKeyed(0, 0);
foreach ($entity_type_ids as $entity_type_id) {
// Skip if the entity type is missing.
if (!($entity_type_definition = $this->entityTypeManager
->getDefinition($entity_type_id, FALSE))) {
continue;
}
$this->derivatives[$entity_type_id] = $base_plugin_definition;
$this->derivatives[$entity_type_id]['source']['entity_type'] = $entity_type_id;
$this->derivatives[$entity_type_id]['source']['entity_type_id'] = $entity_type_id;
$this->derivatives[$entity_type_id]['label'] = $this
->t('@label of @type', [
'@label' => $base_plugin_definition['label'],
'@type' => $this->entityTypeManager
->getDefinition($entity_type_id)
->getPluralLabel(),
]);
}
return $this->derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
MetatagFieldDeriver:: |
protected | property | The entity type manager. | |
MetatagFieldDeriver:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
MetatagFieldDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
MetatagFieldDeriver:: |
public | function | Constructs a MetatagFieldDeriver instance. | |
MigrationConfigurationTrait:: |
protected | property | The config factory service. | |
MigrationConfigurationTrait:: |
protected | property | The follow-up migration tags. | |
MigrationConfigurationTrait:: |
protected | property | The migration plugin manager service. | |
MigrationConfigurationTrait:: |
protected | property | The state service. | |
MigrationConfigurationTrait:: |
protected | function | Creates the necessary state entries for SqlBase::getDatabase() to work. | |
MigrationConfigurationTrait:: |
protected | function | Gets the config factory service. | |
MigrationConfigurationTrait:: |
protected | function | Gets the database connection for the source Drupal database. | |
MigrationConfigurationTrait:: |
protected | function | Returns the follow-up migration tags. | |
MigrationConfigurationTrait:: |
public static | function | Determines what version of Drupal the source database contains. | |
MigrationConfigurationTrait:: |
protected | function | Gets the migration plugin manager service. | |
MigrationConfigurationTrait:: |
protected | function | Gets the migrations for import. | |
MigrationConfigurationTrait:: |
protected | function | Gets the state service. | |
MigrationConfigurationTrait:: |
protected | function | Gets the system data from the system table of the source Drupal database. | |
MigrationDeriverTrait:: |
public static | function | Returns a fully initialized instance of a source plugin. | |
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. |