Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / block / tests / modules / block_test / src / ContextProvider / MultipleStaticContext.php
index 9ca81329036986fb1d22a40f5a7fe792097cb259..dc89d5c64965d575b9b37b90156bb98254b7f143 100644 (file)
@@ -4,9 +4,8 @@ namespace Drupal\block_test\ContextProvider;
 
 use Drupal\Core\Cache\CacheableMetadata;
 use Drupal\Core\Entity\EntityManagerInterface;
-use Drupal\Core\Plugin\Context\Context;
-use Drupal\Core\Plugin\Context\ContextDefinition;
 use Drupal\Core\Plugin\Context\ContextProviderInterface;
+use Drupal\Core\Plugin\Context\EntityContext;
 use Drupal\Core\Session\AccountInterface;
 
 /**
@@ -47,9 +46,8 @@ class MultipleStaticContext implements ContextProviderInterface {
   public function getRuntimeContexts(array $unqualified_context_ids) {
     $current_user = $this->userStorage->load($this->account->id());
 
-    $context1 = new Context(new ContextDefinition('entity:user', 'User A'), $current_user);
-
-    $context2 = new Context(new ContextDefinition('entity:user', 'User B'), $current_user);
+    $context1 = EntityContext::fromEntity($current_user, 'User A');
+    $context2 = EntityContext::fromEntity($current_user, 'User B');
 
     $cacheability = new CacheableMetadata();
     $cacheability->setCacheContexts(['user']);