Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / lib / Drupal / Core / Entity / Plugin / DataType / Deriver / EntityDeriver.php
index 5114c40f8ea08f54b53949a6cad01355f07d9841..38ac960cc17a375b8adfe854d4a3ea06175cfbab 100644 (file)
@@ -2,8 +2,11 @@
 
 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;
 
@@ -86,7 +89,9 @@ class EntityDeriver implements ContainerDeriverInterface {
     $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(),
@@ -96,8 +101,9 @@ class EntityDeriver implements ContainerDeriverInterface {
       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;
         }
       }