Use [[PLACEHOLDER]] instead of %%PLACEHOLDER%% for label placeholders.

This commit is contained in:
Jan Böhmer 2020-04-25 18:19:15 +02:00
parent cb2d0d9845
commit 3163a7ba09
14 changed files with 80 additions and 78 deletions

View file

@ -47,20 +47,20 @@ class GlobalProviders implements PlaceholderProviderInterface
*/
public function replace(string $placeholder, object $label_target, array $options = []): ?string
{
if ($placeholder === "%%INSTALL_NAME%%") {
if ($placeholder === "[[INSTALL_NAME]]") {
return $this->partdb_title;
}
$user = $this->security->getUser();
if ($placeholder === "%%USERNAME%%") {
if ($placeholder === "[[USERNAME]]") {
if ($user instanceof User) {
return $user->getName();
}
return 'anonymous';
}
if ($placeholder === "%%USERNAME_FULL%%") {
if ($placeholder === "[[USERNAME_FULL]]") {
if ($user instanceof User) {
return $user->getFullName(true);
}
@ -69,7 +69,7 @@ class GlobalProviders implements PlaceholderProviderInterface
$now = new \DateTime();
if ($placeholder === '%%DATETIME%%') {
if ($placeholder === '[[DATETIME]]') {
$formatter = IntlDateFormatter::create(
Locale::getDefault(),
IntlDateFormatter::SHORT,
@ -80,7 +80,7 @@ class GlobalProviders implements PlaceholderProviderInterface
return $formatter->format($now);
}
if ($placeholder === '%%DATE%%') {
if ($placeholder === '[[DATE]]') {
$formatter = IntlDateFormatter::create(
Locale::getDefault(),
IntlDateFormatter::SHORT,
@ -91,7 +91,7 @@ class GlobalProviders implements PlaceholderProviderInterface
return $formatter->format($now);
}
if ($placeholder === '%%TIME%%') {
if ($placeholder === '[[TIME]]') {
$formatter = IntlDateFormatter::create(
Locale::getDefault(),
IntlDateFormatter::NONE,