diff --git a/core/core.services.yml b/core/core.services.yml
index 55384a7..dc79944 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -1515,10 +1515,8 @@ services:
arguments: ['@render_strategy_manager']
render_strategy_manager:
class: Drupal\Core\Render\Strategy\RenderStrategyManager
- arguments: ['@renderer']
tags:
- { name: service_collector, tag: render_strategy, call: addRenderStrategy }
- lazy: true
render_strategy.single_flush:
class: Drupal\Core\Render\Strategy\SingleFlushRenderStrategy
tags:
diff --git a/core/lib/Drupal/Core/EventSubscriber/HtmlRenderStrategySubscriber.php b/core/lib/Drupal/Core/EventSubscriber/HtmlRenderStrategySubscriber.php
index d40f451..c93e0b0 100644
--- a/core/lib/Drupal/Core/EventSubscriber/HtmlRenderStrategySubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/HtmlRenderStrategySubscriber.php
@@ -8,35 +8,35 @@
namespace Drupal\Core\EventSubscriber;
use Drupal\Core\Render\HtmlResponse;
-use Drupal\Core\Render\Strategy\RenderStrategyManagerInterface;
+use Drupal\Core\Render\Strategy\RenderStrategyInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
- * Response subscriber to handle render strategies for HTML responses.
+ * HTML Response subscriber to handle placeholder render strategies.
*/
class HtmlRenderStrategySubscriber implements EventSubscriberInterface {
/**
* The render strategy manager service.
*
- * @var \Drupal\Core\Render\Strategy\RenderStrategyManager
+ * @var \Drupal\Core\Render\Strategy\RenderStrategyInterface
*/
protected $renderStrategyManager;
/**
* Constructs a HtmlRenderStrategySubscriber object.
*
- * @param \Drupal\Core\Render\Strategy\RenderStrategyManagerInterface $render_strategy_manager
+ * @param \Drupal\Core\Render\Strategy\RenderStrategyInterface $render_strategy_manager
* The render strategy manager service.
*/
- public function __construct(RenderStrategyManagerInterface $render_strategy_manager) {
+ public function __construct(RenderStrategyInterface $render_strategy_manager) {
$this->renderStrategyManager = $render_strategy_manager;
}
/**
- * Processes attachments for HtmlResponse responses.
+ * Processes placeholders for HtmlResponse responses.
*
* @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
* The event to process.
diff --git a/core/lib/Drupal/Core/ProxyClass/Render/Strategy/RenderStrategyManager.php b/core/lib/Drupal/Core/ProxyClass/Render/Strategy/RenderStrategyManager.php
deleted file mode 100644
index 7200c4d..0000000
--- a/core/lib/Drupal/Core/ProxyClass/Render/Strategy/RenderStrategyManager.php
+++ /dev/null
@@ -1,92 +0,0 @@
-container = $container;
- $this->drupalProxyOriginalServiceId = $drupal_proxy_original_service_id;
- }
-
- /**
- * Lazy loads the real service from the container.
- *
- * @return object
- * Returns the constructed real service.
- */
- protected function lazyLoadItself()
- {
- if (!isset($this->service)) {
- $this->service = $this->container->get($this->drupalProxyOriginalServiceId);
- }
-
- return $this->service;
- }
-
- /**
- * {@inheritdoc}
- */
- public function addRenderStrategy(\Drupal\Core\Render\Strategy\RenderStrategyInterface $strategy)
- {
- return $this->lazyLoadItself()->addRenderStrategy($strategy);
- }
-
- /**
- * {@inheritdoc}
- */
- public function processPlaceholders(array $placeholders)
- {
- return $this->lazyLoadItself()->processPlaceholders($placeholders);
- }
-
- }
-
-}
diff --git a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
index 728599a..cc20063 100644
--- a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
+++ b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
@@ -182,31 +182,6 @@ protected function renderPlaceholders(HtmlResponse $response) {
return $response;
}
- /**
- * Renders placeholders (#attached[placeholders]).
- *
- * @param \Drupal\Core\Render\HtmlResponse $response
- * The HTML response whose placeholders to replace.
- *
- * @see \Drupal\Core\Render\Renderer::replacePlaceholders()
- * @see \Drupal\Core\Render\Renderer::renderPlaceholder()
- */
- protected function renderPlaceholders(HtmlResponse $response) {
- // Render the placeholders in the HTML Response object.
- $build = [
- '#markup' => SafeString::create($response->getContent()),
- '#attached' => $response->getAttachments(),
- ];
- $this->renderer->renderRoot($build);
-
- // Update the Response object now that the placeholders have been rendered.
- $placeholders_bubbleable_metadata = BubbleableMetadata::createFromRenderArray($build);
- $response
- ->setContent($build['#markup'])
- ->addCacheableDependency($placeholders_bubbleable_metadata)
- ->setAttachments($placeholders_bubbleable_metadata->getAttachments());
- }
-
/**
* Processes asset libraries into render arrays.
*
diff --git a/core/lib/Drupal/Core/Render/Renderer.php b/core/lib/Drupal/Core/Render/Renderer.php
index 681af5b..e9a9634 100644
--- a/core/lib/Drupal/Core/Render/Renderer.php
+++ b/core/lib/Drupal/Core/Render/Renderer.php
@@ -258,8 +258,6 @@ protected function doRender(&$elements, $is_root_call = FALSE) {
// - this is a render cacheable subtree, to ensure that the cached data has
// the configurable defaults (which may affect the ID and invalidation).
if ($is_root_call || isset($elements['#cache']['keys'])) {
- // This is inlined for performance reasons. Also see
- // applyRequiredCacheContexts() function below.
$required_cache_contexts = $this->rendererConfig['required_cache_contexts'];
if (isset($elements['#cache']['contexts'])) {
$elements['#cache']['contexts'] = Cache::mergeContexts($elements['#cache']['contexts'], $required_cache_contexts);
@@ -564,21 +562,6 @@ protected function doRender(&$elements, $is_root_call = FALSE) {
/**
* {@inheritdoc}
*/
- public function applyRequiredCacheContexts(array $elements) {
- $required_cache_contexts = $this->rendererConfig['required_cache_contexts'];
- if (isset($elements['#cache']['contexts'])) {
- $elements['#cache']['contexts'] = Cache::mergeContexts($elements['#cache']['contexts'], $required_cache_contexts);
- }
- else {
- $elements['#cache']['contexts'] = $required_cache_contexts;
- }
-
- return $elements;
- }
-
- /**
- * {@inheritdoc}
- */
public function hasRenderContext() {
return (bool) $this->getCurrentRenderContext();
}
diff --git a/core/lib/Drupal/Core/Render/RendererInterface.php b/core/lib/Drupal/Core/Render/RendererInterface.php
index c2c3012..155eec4 100644
--- a/core/lib/Drupal/Core/Render/RendererInterface.php
+++ b/core/lib/Drupal/Core/Render/RendererInterface.php
@@ -365,21 +365,6 @@ public function hasRenderContext();
public function executeInRenderContext(RenderContext $context, callable $callable);
/**
- * Applies the required cache contexts to a render array.
- *
- * Note: This function should only be needed in edge-case circumstances; e.g.
- * when interacting directly with the RenderCache class or by rendering
- * without replacing placeholders.
- *
- * @param array $elements
- * The render array to apply the required cache contexts to.
- *
- * @return array
- * A render array with the required cache contexts added.
- */
- public function applyRequiredCacheContexts(array $elements);
-
- /**
* Merges the bubbleable rendering metadata o/t 2nd render array with the 1st.
*
* @param array $a
diff --git a/core/lib/Drupal/Core/Render/Strategy/RenderStrategyManager.php b/core/lib/Drupal/Core/Render/Strategy/RenderStrategyManager.php
index 2a18a72..9f188e0 100644
--- a/core/lib/Drupal/Core/Render/Strategy/RenderStrategyManager.php
+++ b/core/lib/Drupal/Core/Render/Strategy/RenderStrategyManager.php
@@ -12,14 +12,7 @@
/**
* Provides a class which allows to render placeholders.
*/
-class RenderStrategyManager implements RenderStrategyManagerInterface {
-
- /**
- * The renderer.
- *
- * @var \Drupal\Core\Render\RendererInterface
- */
- protected $renderer;
+class RenderStrategyManager implements RenderStrategyInterface {
/**
* The RenderStrategy services.
@@ -29,16 +22,6 @@ class RenderStrategyManager implements RenderStrategyManagerInterface {
protected $renderStrategies;
/**
- * Constructs a new RenderStrategyManager class.
- *
- * @param \Drupal\Core\Render\RendererInterface
- * The renderer.
- */
- public function __construct(RendererInterface $renderer) {
- $this->renderer = $renderer;
- }
-
- /**
* Adds a render strategy to process.
*
* @param RenderStrategyInterface $strategy
diff --git a/core/lib/Drupal/Core/Render/Strategy/RenderStrategyManagerInterface.php b/core/lib/Drupal/Core/Render/Strategy/RenderStrategyManagerInterface.php
deleted file mode 100644
index 0120f50..0000000
--- a/core/lib/Drupal/Core/Render/Strategy/RenderStrategyManagerInterface.php
+++ /dev/null
@@ -1,26 +0,0 @@
-addRenderStrategy($strategy);
+ }
+
+ $this->assertEquals($result, $render_strategy_manager->processPlaceholders($placeholders));
+ }
+
+ /**
+ * Provides a list of render strategies, placeholders and results.
+ *
+ * @return array
+ */
+ public function providerProcessPlaceholders() {
+ $data = [];
+
+ // Empty placeholders.
+ $data[] = [[], [], []];
+
+ // Placeholder removing strategy.
+ $placeholders = [
+ 'remove-me' => ['#markup' => 'I-am-a-llama-that-will-be-removed-sad-face.'],
+ ];
+
+ $prophecy = $this->prophesize('\Drupal\Core\Render\Strategy\RenderStrategyInterface');
+ $prophecy->processPlaceholders($placeholders)->willReturn([]);
+ $dev_null_strategy = $prophecy->reveal();
+
+ $data[] = [[$dev_null_strategy], $placeholders, []];
+
+ // Fake Single Flush strategy.
+ $placeholders = [
+ '67890' => ['#markup' => 'special-placeholder'],
+ ];
+
+ $prophecy = $this->prophesize('\Drupal\Core\Render\Strategy\RenderStrategyInterface');
+ $prophecy->processPlaceholders($placeholders)->willReturn($placeholders);
+ $single_flush_strategy = $prophecy->reveal();
+
+ $data[] = [[$single_flush_strategy], $placeholders, $placeholders];
+
+ // Fake ESI strategy.
+ $placeholders = [
+ '12345' => ['#markup' => 'special-placeholder-for-esi'],
+ ];
+ $result = [
+ '12345' => ['#markup' => ''],
+ ];
+
+ $prophecy = $this->prophesize('\Drupal\Core\Render\Strategy\RenderStrategyInterface');
+ $prophecy->processPlaceholders($placeholders)->willReturn($result);
+ $esi_strategy = $prophecy->reveal();
+
+ $data[] = [[$esi_strategy], $placeholders, $result];
+
+ // ESI + SingleFlush strategy (ESI replaces all).
+ $prophecy = $this->prophesize('\Drupal\Core\Render\Strategy\RenderStrategyInterface');
+ $prophecy->processPlaceholders($placeholders)->willReturn($result);
+ $esi_strategy = $prophecy->reveal();
+
+ $prophecy = $this->prophesize('\Drupal\Core\Render\Strategy\RenderStrategyInterface');
+ $single_flush_strategy = $prophecy->reveal();
+
+ $data[] = [[$esi_strategy, $single_flush_strategy], $placeholders, $result];
+
+ // ESI + SingleFlush strategy (mixed).
+ $placeholders = [
+ '12345' => ['#markup' => 'special-placeholder-for-ESI'],
+ '67890' => ['#markup' => 'special-placeholder'],
+ 'foo' => ['#markup' => 'bar'],
+ ];
+
+ $esi_result = [
+ '12345' => ['#markup' => ''],
+ ];
+
+ $normal_result = [
+ '67890' => ['#markup' => 'special-placeholder'],
+ 'foo' => ['#markup' => 'bar'],
+ ];
+
+ $result = $esi_result + $normal_result;
+
+ $prophecy = $this->prophesize('\Drupal\Core\Render\Strategy\RenderStrategyInterface');
+ $prophecy->processPlaceholders($placeholders)->willReturn($esi_result);
+ $esi_strategy = $prophecy->reveal();
+
+ $prophecy = $this->prophesize('\Drupal\Core\Render\Strategy\RenderStrategyInterface');
+ $prophecy->processPlaceholders($normal_result)->willReturn($normal_result);
+ $single_flush_strategy = $prophecy->reveal();
+
+ $data[] = [[$esi_strategy, $single_flush_strategy], $placeholders, $result];
+
+ return $data;
+ }
+
+}