From ed64b7168754d87f7b25497cab512390b4fe4a32 Mon Sep 17 00:00:00 2001 From: Awilum Date: Tue, 20 Aug 2019 10:50:38 +0300 Subject: [PATCH] feat(core): update Entries methods #212 #186 - update method read: return file_parser name - update method update: ability to save with different parser types --- flextype/core/Entries.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/flextype/core/Entries.php b/flextype/core/Entries.php index bcb7685c..a116b4bb 100755 --- a/flextype/core/Entries.php +++ b/flextype/core/Entries.php @@ -391,10 +391,8 @@ class Entries */ public function update(string $id, array $data) : bool { - $entry_file = $this->_file_location($id); - - if (Filesystem::has($entry_file)) { - return Filesystem::write($entry_file, JsonParser::encode($data)); + if ($_entry = $this->read($id)) { + return Filesystem::write($_entry['file_path'], Parser::encode($data, $_entry['file_parser'])); } return false; @@ -502,6 +500,7 @@ class Entries return [ 'file_path' => $file_path, 'file_data' => $file_data, + 'file_parser' => $parser['name'] ]; } }