From 456ee44a54f999571ed4db20685ea9699e6e7939 Mon Sep 17 00:00:00 2001 From: Ivo Valchev Date: Wed, 10 Feb 2021 12:06:31 +0100 Subject: [PATCH] Make sure the magic `get` uses the configured `date_format` --- src/Utils/ContentHelper.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Utils/ContentHelper.php b/src/Utils/ContentHelper.php index b3c37c40e..2ed1f3f1a 100644 --- a/src/Utils/ContentHelper.php +++ b/src/Utils/ContentHelper.php @@ -130,9 +130,11 @@ public function get(Content $record, string $format = '', ?string $locale = null $locale = $record->getContentTypeDefaultLocale(); } + $dateFormat = $this->config->get('general/date_format'); + return preg_replace_callback( '/{([\w]+)}/i', - function ($match) use ($record, $locale) { + function ($match) use ($record, $locale, $dateFormat) { if ($match[1] === 'id') { return $record->getId(); } @@ -146,19 +148,19 @@ function ($match) use ($record, $locale) { } if ($match[1] === 'publishedAt') { - return $this->localeExtension->localdate($record->getPublishedAt(), null, $locale); + return $this->localeExtension->localdate($record->getPublishedAt(), $dateFormat, $locale); } if ($match[1] === 'modifiedAt') { - return $this->localeExtension->localdate($record->getModifiedAt(), null, $locale); + return $this->localeExtension->localdate($record->getModifiedAt(), $dateFormat, $locale); } if ($match[1] === 'createdAt') { - return $this->localeExtension->localdate($record->getCreatedAt(), null, $locale); + return $this->localeExtension->localdate($record->getCreatedAt(), $dateFormat, $locale); } if ($match[1] === 'depublishedAt') { - return $this->localeExtension->localdate($record->getDepublishedAt(), null, $locale); + return $this->localeExtension->localdate($record->getDepublishedAt(), $dateFormat, $locale); } if ($match[1] === 'contenttype') {