diff --git a/src/Plugin/Filter/EntityEmbedFilter.php b/src/Plugin/Filter/EntityEmbedFilter.php index 36bf0b1..965e5c9 100644 --- a/src/Plugin/Filter/EntityEmbedFilter.php +++ b/src/Plugin/Filter/EntityEmbedFilter.php @@ -39,7 +39,7 @@ class EntityEmbedFilter extends FilterBase implements ContainerFactoryPluginInte /** * The renderer service. * - * @var \Drupal\Core\RendererInterface + * @var \Drupal\Core\Render\RendererInterface */ protected $renderer; diff --git a/src/Plugin/entity_embed/EntityEmbedDisplay/FileFieldFormatter.php b/src/Plugin/entity_embed/EntityEmbedDisplay/FileFieldFormatter.php index 4fd9352..47b696f 100644 --- a/src/Plugin/entity_embed/EntityEmbedDisplay/FileFieldFormatter.php +++ b/src/Plugin/entity_embed/EntityEmbedDisplay/FileFieldFormatter.php @@ -62,13 +62,4 @@ class FileFieldFormatter extends EntityReferenceFieldFormatter { return $form; } - /** - * {@inheritdoc} - * - * @return \Drupal\file\FileInterface - */ - public function getEntityFromContext() { - return parent::getEntityFromContext(); - } - } diff --git a/src/Plugin/entity_embed/EntityEmbedDisplay/ImageFieldFormatter.php b/src/Plugin/entity_embed/EntityEmbedDisplay/ImageFieldFormatter.php index b316f44..c1f2736 100644 --- a/src/Plugin/entity_embed/EntityEmbedDisplay/ImageFieldFormatter.php +++ b/src/Plugin/entity_embed/EntityEmbedDisplay/ImageFieldFormatter.php @@ -107,6 +107,7 @@ class ImageFieldFormatter extends FileFieldFormatter { // @todo needs cacheability metadata for getEntityFromContext. // @see \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayBase::getEntityFromContext() + /** @var \Drupal\file\FileInterface $entity */ if ($entity = $this->getEntityFromContext()) { $access = AccessResult::allowedIf($this->imageFactory->get($entity->getFileUri())->isValid()) // See the above @todo, this is the best we can do for now. diff --git a/tests/modules/entity_embed_test/entity_embed_test.module b/tests/modules/entity_embed_test/entity_embed_test.module index bd271c6..8502676 100644 --- a/tests/modules/entity_embed_test/entity_embed_test.module +++ b/tests/modules/entity_embed_test/entity_embed_test.module @@ -79,5 +79,7 @@ function entity_embed_test_entity_embed_alter(array &$build, EntityInterface $en * Implements hook_entity_access(). */ function entity_embed_test_entity_access(EntityInterface $entity, $operation, AccountInterface $account) { - return AccessResult::neutral()->addCacheTags(['foo:' . $entity->id()]); + if ($entity->label() == 'Embed Test Node') { + return AccessResult::neutral()->addCacheTags(['foo:' . $entity->id()]); + } }