diff --git a/src/EntityEmbedDisplay/EntityEmbedDisplayManager.php b/src/EntityEmbedDisplay/EntityEmbedDisplayManager.php index 62bfc01..157cd2c 100644 --- a/src/EntityEmbedDisplay/EntityEmbedDisplayManager.php +++ b/src/EntityEmbedDisplay/EntityEmbedDisplayManager.php @@ -73,7 +73,7 @@ class EntityEmbedDisplayManager extends DefaultPluginManager { foreach ($contexts as $name => $value) { $display->setContextValue($name, $value); } - return $display->access(); + return $display->access()->isAllowed(); } catch (PluginException $e) { return FALSE; diff --git a/src/Plugin/Filter/EntityEmbedFilter.php b/src/Plugin/Filter/EntityEmbedFilter.php index b149a1f..36bf0b1 100644 --- a/src/Plugin/Filter/EntityEmbedFilter.php +++ b/src/Plugin/Filter/EntityEmbedFilter.php @@ -11,9 +11,9 @@ use Drupal\Component\Utility\Html; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Render\BubbleableMetadata; use Drupal\Core\Render\RenderContext; +use Drupal\Core\Render\RendererInterface; use Drupal\entity_embed\EntityHelperTrait; use Drupal\entity_embed\Exception\EntityNotFoundException; use Drupal\entity_embed\Exception\RecursiveRenderingException; @@ -37,6 +37,13 @@ class EntityEmbedFilter extends FilterBase implements ContainerFactoryPluginInte use DomHelperTrait; /** + * The renderer service. + * + * @var \Drupal\Core\RendererInterface + */ + protected $renderer; + + /** * Constructs a EntityEmbedFilter object. * * @param array $configuration @@ -50,10 +57,11 @@ class EntityEmbedFilter extends FilterBase implements ContainerFactoryPluginInte * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The Module Handler. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, RendererInterface $renderer) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->setEntityManager($entity_manager); $this->setModuleHandler($module_handler); + $this->renderer = $renderer; } /** @@ -65,7 +73,8 @@ class EntityEmbedFilter extends FilterBase implements ContainerFactoryPluginInte $plugin_id, $plugin_definition, $container->get('entity.manager'), - $container->get('module_handler') + $container->get('module_handler'), + $container->get('renderer') ); } @@ -115,8 +124,8 @@ class EntityEmbedFilter extends FilterBase implements ContainerFactoryPluginInte // when filtering text makes it onto the FilterProcessResult // object that they return ($result). To prevent that bubbling, we // must wrap the call to render() in a render context. - $entity_output = $this->renderer()->executeInRenderContext(new RenderContext(), function () use (&$build) { - return $this->renderer()->render($build); + $entity_output = $this->renderer->executeInRenderContext(new RenderContext(), function () use (&$build) { + return $this->renderer->render($build); }); $result = $result->merge(BubbleableMetadata::createFromRenderArray($build));