Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / user / src / ContextProvider / CurrentUserContext.php
index aacc5f774afbeb7ce9f4cc665895bb70cabe3e36..5e1756918ef2890846cec8f4f1a03c4e650ad1fd 100644 (file)
@@ -4,9 +4,8 @@ namespace Drupal\user\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;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
 
@@ -56,7 +55,7 @@ class CurrentUserContext implements ContextProviderInterface {
       $current_user->_skipProtectedUserFieldConstraint = TRUE;
     }
 
-    $context = new Context(new ContextDefinition('entity:user', $this->t('Current user')), $current_user);
+    $context = EntityContext::fromEntity($current_user, $this->t('Current user'));
     $cacheability = new CacheableMetadata();
     $cacheability->setCacheContexts(['user']);
     $context->addCacheableDependency($cacheability);