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;