class ContentEntityDeriver in Drupal 8
Same name and namespace in other branches
- 9 core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntityDeriver.php \Drupal\migrate_drupal\Plugin\migrate\source\ContentEntityDeriver
- 10 core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntityDeriver.php \Drupal\migrate_drupal\Plugin\migrate\source\ContentEntityDeriver
Deriver for content entity source plugins.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\migrate_drupal\Plugin\migrate\source\ContentEntityDeriver implements ContainerDeriverInterface
Expanded class hierarchy of ContentEntityDeriver
File
- core/
modules/ migrate_drupal/ src/ Plugin/ migrate/ source/ ContentEntityDeriver.php, line 14
Namespace
Drupal\migrate_drupal\Plugin\migrate\sourceView source
class ContentEntityDeriver extends DeriverBase implements ContainerDeriverInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a new ContentEntityDeriver.
*
* @param string $base_plugin_id
* The base plugin ID.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
*/
public function __construct($base_plugin_id, EntityTypeManagerInterface $entityTypeManager) {
$this->entityTypeManager = $entityTypeManager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($base_plugin_id, $container
->get('entity_type.manager'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives = [];
foreach ($this->entityTypeManager
->getDefinitions() as $id => $definition) {
if ($definition instanceof ContentEntityTypeInterface) {
$this->derivatives[$id] = $base_plugin_definition;
// Provide entity_type so the source can be used apart from a deriver.
$this->derivatives[$id]['entity_type'] = $id;
}
}
return parent::getDerivativeDefinitions($base_plugin_definition);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContentEntityDeriver:: |
protected | property | The entity type manager. | |
ContentEntityDeriver:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
ContentEntityDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
ContentEntityDeriver:: |
public | function | Constructs a new ContentEntityDeriver. | |
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |