mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-30 13:34:28 +02:00
Added placeholders filter to utilize the placeholders in twig mode
Fixes #546
This commit is contained in:
parent
757201cafa
commit
dff1ef04bf
5 changed files with 83 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue