class ConfigEntity
Drupal configuration source from database.
Available configuration keys:
- collections: (optional) The collection of configuration storage to retrieve from the source - can be a string or an array. If omitted, configuration objects of all available collections are retrieved.
- names: (optional) Names of configuration objects to retrieve from the source - can be a string or an array. If omitted, all available configuration objects are retrieved.
Examples:
source:
plugin: config_entity
names:
- node.type.article
- node.type.page
In this example configuration objects of article and page content types are retrieved from the source database.
source:
plugin: config_entity
collections: language.fr
names:
- node.type.article
- node.type.page
In this example configuration objects are filtered by language.fr collection. As a result, French versions of specified configuration objects are retrieved from the source database.
For additional configuration keys, refer to the parent classes.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
- class \Drupal\migrate\Plugin\migrate\source\SourcePluginBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\migrate\Plugin\MigrateSourceInterface, \Drupal\migrate\Event\RollbackAwareInterface
- class \Drupal\migrate\Plugin\migrate\source\SqlBase extends \Drupal\migrate\Plugin\migrate\source\SourcePluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\migrate\Plugin\RequirementsInterface
- class \Drupal\migrate\Plugin\migrate\source\ConfigEntity extends \Drupal\migrate\Plugin\migrate\source\SqlBase
- class \Drupal\migrate\Plugin\migrate\source\SqlBase extends \Drupal\migrate\Plugin\migrate\source\SourcePluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\migrate\Plugin\RequirementsInterface
- class \Drupal\migrate\Plugin\migrate\source\SourcePluginBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\migrate\Plugin\MigrateSourceInterface, \Drupal\migrate\Event\RollbackAwareInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
Expanded class hierarchy of ConfigEntity
See also
\Drupal\migrate\Plugin\migrate\source\SqlBase
\Drupal\migrate\Plugin\migrate\source\SourcePluginBase
File
-
core/
modules/ migrate/ src/ Plugin/ migrate/ source/ ConfigEntity.php, line 52
Namespace
Drupal\migrate\Plugin\migrate\sourceView source
class ConfigEntity extends SqlBase {
/**
* {@inheritdoc}
*/
public function query() {
$query = $this->select('config', 'c')
->fields('c', [
'collection',
'name',
'data',
]);
if (!empty($this->configuration['collections'])) {
$query->condition('collection', (array) $this->configuration['collections'], 'IN');
}
if (!empty($this->configuration['names'])) {
$query->condition('name', (array) $this->configuration['names'], 'IN');
}
return $query;
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
$row->setSourceProperty('data', unserialize($row->getSourceProperty('data')));
return parent::prepareRow($row);
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'collection' => $this->t('The config object collection.'),
'name' => $this->t('The config object name.'),
'data' => $this->t('Serialized configuration object data.'),
];
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['collection']['type'] = 'string';
$ids['name']['type'] = 'string';
return $ids;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.