1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-15 01:24:25 +02:00

Flextype Core: Entries API cleanup and refactoring

This commit is contained in:
Awilum
2019-08-19 15:09:39 +03:00
parent d6a38cb714
commit 78d28c81f3

View File

@@ -71,10 +71,8 @@ class Entries
// If requested entry file founded then process it
if (Filesystem::has($entry_file)) {
//
// Create unique entry cache_id
// Entry Cache ID = entry + entry file + entry file time stamp
//
if ($timestamp = Filesystem::getTimestamp($entry_file)) {
$entry_cache_id = md5('entry' . $entry_file . $timestamp);
} else {
@@ -83,9 +81,7 @@ class Entries
// Try to get the requested entry from cache
if ($this->flextype['cache']->contains($entry_cache_id)) {
//
// Try to fetch requested entry from the cache
//
if ($entry = $this->flextype['cache']->fetch($entry_cache_id)) {
// Run event onEntryAfterInitialized
$this->flextype['emitter']->emit('onEntryAfterInitialized');
@@ -101,14 +97,10 @@ class Entries
// Try to get requested entry body content
if ($entry_body = Filesystem::read($entry_file)) {
//
// Try to decode requested entry body content
//
if ($entry_decoded = JsonParser::decode($entry_body)) {
//
// Add predefined entry items
// Entry Date
//
$entry_decoded['published_at'] = $entry_decoded['published_at'] ? $entry_decoded['published_at'] : Filesystem::getTimestamp($entry_file);
$entry_decoded['created_at'] = $entry_decoded['created_at'] ? $entry_decoded['created_at'] : Filesystem::getTimestamp($entry_file);