diff core/modules/node/src/ContextProvider/NodeRouteContext.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
line wrap: on
line diff
--- a/core/modules/node/src/ContextProvider/NodeRouteContext.php	Tue Jul 10 15:07:59 2018 +0100
+++ b/core/modules/node/src/ContextProvider/NodeRouteContext.php	Thu Feb 28 13:21:36 2019 +0000
@@ -4,8 +4,9 @@
 
 use Drupal\Core\Cache\CacheableMetadata;
 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\Plugin\Context\EntityContextDefinition;
 use Drupal\Core\Routing\RouteMatchInterface;
 use Drupal\node\Entity\Node;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -39,7 +40,7 @@
    */
   public function getRuntimeContexts(array $unqualified_context_ids) {
     $result = [];
-    $context_definition = new ContextDefinition('entity:node', NULL, FALSE);
+    $context_definition = EntityContextDefinition::create('node')->setRequired(FALSE);
     $value = NULL;
     if (($route_object = $this->routeMatch->getRouteObject()) && ($route_contexts = $route_object->getOption('parameters')) && isset($route_contexts['node'])) {
       if ($node = $this->routeMatch->getParameter('node')) {
@@ -65,7 +66,7 @@
    * {@inheritdoc}
    */
   public function getAvailableContexts() {
-    $context = new Context(new ContextDefinition('entity:node', $this->t('Node from URL')));
+    $context = EntityContext::fromEntityTypeId('node', $this->t('Node from URL'));
     return ['node' => $context];
   }