diff --git a/src/Entity/PageViewBuilder.php b/src/Entity/PageViewBuilder.php index 23963c5..32e2e4f 100644 --- a/src/Entity/PageViewBuilder.php +++ b/src/Entity/PageViewBuilder.php @@ -63,11 +63,12 @@ public static function createInstance(ContainerInterface $container, EntityTypeI */ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) { /** @var \Drupal\page_manager\PageInterface $entity */ - if ($variant_plugin = $entity->getExecutable()->getRuntimeVariant($this->routeMatch->getParameter('variant_id'))) { - if ($variant_plugin instanceof RefinableCacheableDependencyInterface) { - $variant_plugin->addCacheableDependency($entity); + if ($variant_entity = $entity->getExecutable()->getRuntimeVariant($this->routeMatch->getParameter('variant_id'))) { + // @todo Should this be the entity or plugin? + if ($variant_entity instanceof RefinableCacheableDependencyInterface) { + $variant_entity->addCacheableDependency($entity); } - return $variant_plugin->build(); + return $variant_entity->getVariantPlugin()->build(); } else { throw new HttpException(404); diff --git a/src/PageExecutableInterface.php b/src/PageExecutableInterface.php index b1d1bd4..1174a5c 100644 --- a/src/PageExecutableInterface.php +++ b/src/PageExecutableInterface.php @@ -52,7 +52,7 @@ public function addContext($name, ContextInterface $value); * @param string $variant_id * The variant ID. * - * @return \Drupal\page_manager\Entity\PageVariant + * @return \Drupal\page_manager\PageVariantInterface * The page variant entity. */ public function getRuntimeVariant($variant_id);