ChainedPlaceholderStrategy.php in Drupal 9
File
core/lib/Drupal/Core/Render/Placeholder/ChainedPlaceholderStrategy.php
View source
<?php
namespace Drupal\Core\Render\Placeholder;
class ChainedPlaceholderStrategy implements PlaceholderStrategyInterface {
protected $placeholderStrategies = [];
public function addPlaceholderStrategy(PlaceholderStrategyInterface $strategy) {
$this->placeholderStrategies[] = $strategy;
}
public function processPlaceholders(array $placeholders) {
if (empty($placeholders)) {
return [];
}
assert(!empty($this->placeholderStrategies), 'At least one placeholder strategy must be present; by default the fallback strategy \\Drupal\\Core\\Render\\Placeholder\\SingleFlushStrategy is always present.');
$new_placeholders = [];
foreach ($this->placeholderStrategies as $strategy) {
$processed_placeholders = $strategy
->processPlaceholders($placeholders);
assert(array_intersect_key($processed_placeholders, $placeholders) === $processed_placeholders, 'Processed placeholders must be a subset of all placeholders.');
$placeholders = array_diff_key($placeholders, $processed_placeholders);
$new_placeholders += $processed_placeholders;
if (empty($placeholders)) {
break;
}
}
return $new_placeholders;
}
}