From bdee5686496d0f85073786685d36525577f34ced Mon Sep 17 00:00:00 2001 From: Awilum Date: Sat, 25 May 2019 12:53:22 +0300 Subject: [PATCH] Slim Framework integration #118 #117 - Fieldsets: new method fetch() added --- flextype/Fieldsets.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/flextype/Fieldsets.php b/flextype/Fieldsets.php index 0d306efe..64b4a8b6 100644 --- a/flextype/Fieldsets.php +++ b/flextype/Fieldsets.php @@ -31,6 +31,32 @@ class Fieldsets $this->flextype = $flextype; } + /** + * Fetch fieldsets + * + * @access public + * @param string $id Fieldsets id + * @return array|false The entry contents or false on failure. + */ + public function fetch(string $id) + { + $fieldsets_file = Fieldsets::_file_location($id); + + if (Filesystem::has($fieldsets_file)) { + if ($fieldsets_body = Filesystem::read($fieldsets_file)) { + if ($fieldsets_decoded = JsonParser::decode($fieldsets_body)) { + return $fieldsets_decoded; + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } + /** * Fetch Fieldsets for current theme *