Added placeholders filter to utilize the placeholders in twig mode

Fixes #546
This commit is contained in:
Jan Böhmer 2024-03-06 21:00:21 +01:00
parent 757201cafa
commit dff1ef04bf
5 changed files with 83 additions and 3 deletions

View file

@ -64,6 +64,17 @@ final class LabelTextReplacer
* @return string If the placeholder was valid, the replaced info. Otherwise the passed string.
*/
public function handlePlaceholder(string $placeholder, object $target): string
{
return $this->handlePlaceholderOrReturnNull($placeholder, $target) ?? $placeholder;
}
/**
* Similar to handlePlaceholder, but returns null if the placeholder is not known (instead of the original string)
* @param string $placeholder
* @param object $target
* @return string|null
*/
public function handlePlaceholderOrReturnNull(string $placeholder, object $target): ?string
{
foreach ($this->providers as $provider) {
/** @var PlaceholderProviderInterface $provider */
@ -73,7 +84,7 @@ final class LabelTextReplacer
}
}
return $placeholder;
return null;
}
/**