mirror of
https://github.com/flextype/flextype.git
synced 2025-08-09 06:36:52 +02:00
feat(fields): use Atomastic Filesystem for CreatedAtField #478
This commit is contained in:
@@ -7,13 +7,12 @@ declare(strict_types=1);
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
use Atomastic\Strings\Strings;
|
||||
|
||||
if (flextype('registry')->get('flextype.settings.entries.fields.created_at.enabled')) {
|
||||
flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void {
|
||||
if (flextype('entries')->getStorage('fetch_single.data.created_at') == null) {
|
||||
flextype('entries')->setStorage('fetch_single.data.created_at', (int) Filesystem::getTimestamp(flextype('entries')->getFileLocation(flextype('entries')->getStorage('fetch_single.id'))));
|
||||
flextype('entries')->setStorage('fetch_single.data.created_at', (int) flextype('filesystem')->file(flextype('entries')->getFileLocation(flextype('entries')->getStorage('fetch_single.id')))->lastModified());
|
||||
} else {
|
||||
flextype('entries')->setStorage('fetch_single.data.created_at', (int) strtotime(flextype('entries')->getStorage('fetch_single.data.created_at')));
|
||||
}
|
||||
|
Reference in New Issue
Block a user