Skip to content

Commit

Permalink
Make sure the magic get uses the configured date_format
Browse files Browse the repository at this point in the history
  • Loading branch information
I-Valchev authored and bobdenotter committed Feb 11, 2021
1 parent 46b9718 commit 456ee44
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Utils/ContentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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') {
Expand Down

0 comments on commit 456ee44

Please sign in to comment.