namespace Drupal\Core\Entity\Plugin\DataType\Deriver;
+use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
+use Drupal\Core\Entity\Plugin\DataType\ConfigEntityAdapter;
+use Drupal\Core\Entity\Plugin\DataType\EntityAdapter;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
$this->derivatives[''] = $base_plugin_definition;
// Add definitions for each entity type and bundle.
foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
+ $class = $entity_type->entityClassImplements(ConfigEntityInterface::class) ? ConfigEntityAdapter::class : EntityAdapter::class;
$this->derivatives[$entity_type_id] = [
+ 'class' => $class,
'label' => $entity_type->getLabel(),
'constraints' => $entity_type->getConstraints(),
'internal' => $entity_type->isInternal(),
foreach ($this->bundleInfoService->getBundleInfo($entity_type_id) as $bundle => $bundle_info) {
if ($bundle !== $entity_type_id) {
$this->derivatives[$entity_type_id . ':' . $bundle] = [
+ 'class' => $class,
'label' => $bundle_info['label'],
- 'constraints' => $this->derivatives[$entity_type_id]['constraints']
+ 'constraints' => $this->derivatives[$entity_type_id]['constraints'],
] + $base_plugin_definition;
}
}