public function MetatagFieldDeriver::getDerivativeDefinitions in Metatag 8
Gets the definition of all derivatives of a base plugin.
Parameters
array $base_plugin_definition: The definition array of the base plugin.
Return value
array An array of full derivative definitions keyed on derivative id.
Overrides DeriverBase::getDerivativeDefinitions
See also
getDerivativeDefinition()
File
- src/
Plugin/ migrate/ source/ d7/ MetatagFieldDeriver.php, line 55
Class
- MetatagFieldDeriver
- @todo.
Namespace
Drupal\metatag\Plugin\migrate\source\d7Code
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;
}