1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-14 00:54:03 +02:00

fix(entries): fix wrong Implementation of Slug Field for Entries #452

- add new field `id`

BREAKING CHANGES

use field `id` to get entry path instead of `slug` field
This commit is contained in:
Awilum
2020-08-11 20:22:23 +03:00
parent d75d40deb8
commit 47618093c0
3 changed files with 19 additions and 2 deletions

View File

@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
/**
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/
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, '/'), '/');
});
}

View File

@@ -9,6 +9,7 @@ declare(strict_types=1);
if ($flextype->registry->get('flextype.settings.entries.fields.slug.enabled')) {
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
$flextype->entries->entry['slug'] = isset($flextype->entries->entry['slug']) ? (string) $flextype->entries->entry['slug'] : (string) ltrim(rtrim($flextype->entries->entry_path, '/'), '/');
$parts = explode('/', ltrim(rtrim($flextype->entries->entry_path, '/'), '/'));
$flextype->entries->entry['slug'] = isset($flextype->entries->entry['slug']) ? (string) $flextype->entries->entry['slug'] : (string) end($parts);
});
}

View File

@@ -79,7 +79,9 @@ entries:
enabled: true
uuid:
enabled: true
id:
enabled: true
# Cache
#
# - enabled: Set to true to enable caching