mirror of
https://github.com/flextype/flextype.git
synced 2025-08-11 07:34:22 +02:00
fix(entries): fix wrong Implementation of Slug Field for Entries #452
This commit is contained in:
@@ -13,7 +13,7 @@ if ($flextype->registry->get('flextype.settings.entries.fields.created_at.enable
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->entries->entry['created_at'] = isset($flextype->entries->entry['created_at']) ?
|
||||
(int) strtotime($flextype->entries->entry['created_at']) :
|
||||
(int) Filesystem::getTimestamp($flextype->entries->getFileLocation($flextype->entries->entry_path));
|
||||
(int) Filesystem::getTimestamp($flextype->entries->getFileLocation($flextype->entries->entry_id));
|
||||
});
|
||||
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) : void {
|
||||
|
@@ -9,6 +9,6 @@ declare(strict_types=1);
|
||||
|
||||
if ($flextype->registry->get('flextype.settings.entries.fields.id.enabled')) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->entries->entry['id'] = isset($flextype->entries->entry['id']) ? (string) $flextype->entries->entry['id'] : (string) ltrim(rtrim($flextype->entries->entry_path, '/'), '/');
|
||||
$flextype->entries->entry['id'] = isset($flextype->entries->entry['id']) ? (string) $flextype->entries->entry['id'] : (string) ltrim(rtrim($flextype->entries->entry_id, '/'), '/');
|
||||
});
|
||||
}
|
||||
|
@@ -11,6 +11,6 @@ use Flextype\Component\Filesystem\Filesystem;
|
||||
|
||||
if ($flextype->registry->get('flextype.settings.entries.fields.modified_at.enabled')) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->entries->entry['modified_at'] = (int) Filesystem::getTimestamp($flextype->entries->getFileLocation($flextype->entries->entry_path));
|
||||
$flextype->entries->entry['modified_at'] = (int) Filesystem::getTimestamp($flextype->entries->getFileLocation($flextype->entries->entry_id));
|
||||
});
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ if ($flextype->registry->get('flextype.settings.entries.fields.published_at.enab
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->entries->entry['published_at'] = isset($flextype->entries->entry['published_at']) ?
|
||||
(int) strtotime($flextype->entries->entry['published_at']) :
|
||||
(int) Filesystem::getTimestamp($flextype->entries->getFileLocation($flextype->entries->entry_path));
|
||||
(int) Filesystem::getTimestamp($flextype->entries->getFileLocation($flextype->entries->entry_id));
|
||||
});
|
||||
|
||||
$flextype->emitter->addListener('onEntryCreate', function () use ($flextype) : void {
|
||||
|
@@ -9,7 +9,7 @@ declare(strict_types=1);
|
||||
|
||||
if ($flextype->registry->get('flextype.settings.entries.fields.slug.enabled')) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$parts = explode('/', ltrim(rtrim($flextype->entries->entry_path, '/'), '/'));
|
||||
$parts = explode('/', ltrim(rtrim($flextype->entries->entry_id, '/'), '/'));
|
||||
$flextype->entries->entry['slug'] = isset($flextype->entries->entry['slug']) ? (string) $flextype->entries->entry['slug'] : (string) end($parts);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user