diff --git a/core/core.services.yml b/core/core.services.yml index d60f42c..5b500d6 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -1508,9 +1508,9 @@ services: class: Drupal\Core\EventSubscriber\HtmlResponsePlaceholderStrategySubscriber tags: - { name: event_subscriber } - arguments: ['@placeholder_strategy_manager'] - placeholder_strategy_manager: - class: Drupal\Core\Render\Placeholder\PlaceholderStrategyManager + arguments: ['@placeholder_strategy.chained'] + placeholder_strategy.chained: + class: Drupal\Core\Render\Placeholder\ChainedPlaceholderStrategy tags: - { name: service_collector, tag: placeholder_strategy, call: addPlaceholderStrategy } placeholder_strategy.single_flush: diff --git a/core/lib/Drupal/Core/EventSubscriber/HtmlResponsePlaceholderStrategySubscriber.php b/core/lib/Drupal/Core/EventSubscriber/HtmlResponsePlaceholderStrategySubscriber.php index ca7f2ac..943b08b 100644 --- a/core/lib/Drupal/Core/EventSubscriber/HtmlResponsePlaceholderStrategySubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/HtmlResponsePlaceholderStrategySubscriber.php @@ -25,20 +25,20 @@ class HtmlResponsePlaceholderStrategySubscriber implements EventSubscriberInterface { /** - * The placeholder strategy manager service. + * The placeholder strategy to use. * * @var \Drupal\Core\Render\Placeholder\PlaceholderStrategyInterface */ - protected $placeholderStrategyManager; + protected $placeholderStrategy; /** * Constructs a HtmlResponsePlaceholderStrategySubscriber object. * - * @param \Drupal\Core\Render\Placeholder\PlaceholderStrategyInterface $placeholder_strategy_manager - * The placeholder strategy manager service. + * @param \Drupal\Core\Render\Placeholder\PlaceholderStrategyInterface $placeholder_strategy + * The placeholder strategy to use. */ - public function __construct(PlaceholderStrategyInterface $placeholder_strategy_manager) { - $this->placeholderStrategyManager = $placeholder_strategy_manager; + public function __construct(PlaceholderStrategyInterface $placeholder_strategy) { + $this->placeholderStrategy = $placeholder_strategy; } /** @@ -62,10 +62,9 @@ public function onRespond(FilterResponseEvent $event) { return; } - $attachments['placeholders'] = $this->placeholderStrategyManager->processPlaceholders($attachments['placeholders']); + $attachments['placeholders'] = $this->placeholderStrategy->processPlaceholders($attachments['placeholders']); $response->setAttachments($attachments); - $event->setResponse($response); } /** diff --git a/core/lib/Drupal/Core/Render/Placeholder/PlaceholderStrategyManager.php b/core/lib/Drupal/Core/Render/Placeholder/ChainedPlaceholderStrategy.php similarity index 93% rename from core/lib/Drupal/Core/Render/Placeholder/PlaceholderStrategyManager.php rename to core/lib/Drupal/Core/Render/Placeholder/ChainedPlaceholderStrategy.php index 0940fd4..7be9f55 100644 --- a/core/lib/Drupal/Core/Render/Placeholder/PlaceholderStrategyManager.php +++ b/core/lib/Drupal/Core/Render/Placeholder/ChainedPlaceholderStrategy.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Core\Render\Placeholder\PlaceholderStrategyManager. + * Contains \Drupal\Core\Render\Placeholder\ChainedPlaceholderStrategy. */ namespace Drupal\Core\Render\Placeholder; @@ -10,7 +10,7 @@ /** * Renders placeholders using different strategies depending on priorities. */ -class PlaceholderStrategyManager implements PlaceholderStrategyInterface { +class ChainedPlaceholderStrategy implements PlaceholderStrategyInterface { /** * An ordered list of placeholder strategy services. diff --git a/core/tests/Drupal/Tests/Core/Render/Placeholder/PlaceholderStrategyManagerTest.php b/core/tests/Drupal/Tests/Core/Render/Placeholder/ChainedPlaceholderStrategyTest.php similarity index 84% rename from core/tests/Drupal/Tests/Core/Render/Placeholder/PlaceholderStrategyManagerTest.php rename to core/tests/Drupal/Tests/Core/Render/Placeholder/ChainedPlaceholderStrategyTest.php index 87c766a..ebd9216 100644 --- a/core/tests/Drupal/Tests/Core/Render/Placeholder/PlaceholderStrategyManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Render/Placeholder/ChainedPlaceholderStrategyTest.php @@ -2,19 +2,19 @@ /** * @file - * Contains \Drupal\Tests\Core\Render\Placeholder\PlaceholderStrategyManagerTest. + * Contains \Drupal\Tests\Core\Render\Placeholder\ChainedPlaceholderStrategyTest. */ namespace Drupal\Tests\Core\Render\Placeholder; -use Drupal\Core\Render\Placeholder\PlaceholderStrategyManager; +use Drupal\Core\Render\Placeholder\ChainedPlaceholderStrategy; use Drupal\Tests\UnitTestCase; /** - * @coversDefaultClass \Drupal\Core\Render\Placeholder\PlaceholderStrategyManager + * @coversDefaultClass \Drupal\Core\Render\Placeholder\ChainedPlaceholderStrategy * @group Render */ -class PlaceholderStrategyManagerTest extends UnitTestCase { +class ChainedPlaceholderStrategyTest extends UnitTestCase { /** * @covers ::addPlaceholderStrategy @@ -22,14 +22,14 @@ class PlaceholderStrategyManagerTest extends UnitTestCase { * * @dataProvider providerProcessPlaceholders */ - public function testProcessPlaceholdersSingleFlush($strategies, $placeholders, $result) { - $placeholder_strategy_manager = new PlaceholderStrategyManager(); + public function testProcessPlaceholders($strategies, $placeholders, $result) { + $chained_placeholder_strategy = new ChainedPlaceholderStrategy(); foreach ($strategies as $strategy) { - $placeholder_strategy_manager->addPlaceholderStrategy($strategy); + $chained_placeholder_strategy->addPlaceholderStrategy($strategy); } - $this->assertEquals($result, $placeholder_strategy_manager->processPlaceholders($placeholders)); + $this->assertEquals($result, $chained_placeholder_strategy->processPlaceholders($placeholders)); } /** @@ -132,11 +132,11 @@ public function providerProcessPlaceholders() { public function testProcessPlaceholdersNoStrategies() { // Placeholders but no strategies defined. $placeholders = [ - 'assert-me' => ['#markup' => 'I-am-a-llama-that-will-lead-to-an-assertion-by-the-placeholder-strategy-manager.'], + 'assert-me' => ['#markup' => 'I-am-a-llama-that-will-lead-to-an-assertion-by-the-chained-placeholder-strategy.'], ]; - $placeholder_strategy_manager = new PlaceholderStrategyManager(); - $placeholder_strategy_manager->processPlaceholders($placeholders); + $chained_placeholder_strategy = new ChainedPlaceholderStrategy(); + $chained_placeholder_strategy->processPlaceholders($placeholders); } /** @@ -160,10 +160,9 @@ public function testProcessPlaceholdersWithRoguePlaceholderStrategy() { $prophecy->processPlaceholders($placeholders)->willReturn($result); $rogue_strategy = $prophecy->reveal(); - $placeholder_strategy_manager = new PlaceholderStrategyManager(); - $placeholder_strategy_manager->addPlaceholderStrategy($rogue_strategy); - $placeholder_strategy_manager->processPlaceholders($placeholders); + $chained_placeholder_strategy = new ChainedPlaceholderStrategy(); + $chained_placeholder_strategy->addPlaceholderStrategy($rogue_strategy); + $chained_placeholder_strategy->processPlaceholders($placeholders); } - }