From d5de0244f25f0f0abf5d7f2d1b908075b83212c6 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Thu, 6 Aug 2020 09:56:45 +0200 Subject: [PATCH] [update] introduce Model::FIELD_FILTER_ONLY_FIELDS and use it --- src/Model.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Model.php b/src/Model.php index 2482d38e93..65640a2f6c 100644 --- a/src/Model.php +++ b/src/Model.php @@ -83,6 +83,8 @@ class Model implements \IteratorAggregate public const FIELD_FILTER_EDITABLE = 'editable'; /** @const string */ public const FIELD_FILTER_PERSIST = 'persist'; + /** @const string */ + public const FIELD_FILTER_ONLY_FIELDS = 'only fields'; // {{{ Properties of the class @@ -811,16 +813,8 @@ public function get(string $field = null) if ($field === null) { // Collect list of eligible fields $data = []; - if ($this->only_fields) { - // collect data for actual fields - foreach ($this->only_fields as $field) { - $data[$field] = $this->get($field); - } - } else { - // get all fields - foreach ($this->getFields() as $field => $f) { - $data[$field] = $this->get($field); - } + foreach ($this->getFields(self::FIELD_FILTER_ONLY_FIELDS) as $field) { + $data[$field] = $this->get($field); } return $data;