Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / system / tests / modules / plugin_test / src / Plugin / MockBlockManager.php
index 443ab5d04090ca8f1e96cd672910b03f2ce49f21..de9fc3364d8e7ba461fa80eda63f10e04105b939 100644 (file)
@@ -7,11 +7,13 @@ use Drupal\Component\Plugin\Discovery\StaticDiscovery;
 use Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator;
 use Drupal\Component\Plugin\Factory\ReflectionFactory;
 use Drupal\Core\Plugin\Context\ContextDefinition;
+use Drupal\Core\Plugin\Context\EntityContextDefinition;
 
 /**
  * Defines a plugin manager used by Plugin API derivative unit tests.
  */
 class MockBlockManager extends PluginManagerBase {
+
   public function __construct() {
 
     // Create the object that can be used to return definitions for all the
@@ -139,7 +141,11 @@ class MockBlockManager extends PluginManagerBase {
     // a TranslatableMarkup and we will do assertEqual() checks on arrays that
     // include ContextDefinition objects, and var_export() has problems
     // printing TranslatableMarkup objects.
-    return new ContextDefinition($data_type, (string) $label, $required);
+    $class = ContextDefinition::class;
+    if (strpos($data_type, 'entity:') === 0) {
+      $class = EntityContextDefinition::class;
+    }
+    return new $class($data_type, (string) $label, $required);
   }
 
 }