public function withSchemaItemCollectionCollection() { $datas = is_object($this->getData()) ? get_object_vars($this->getData()) : $this->getData(); $datas = is_array($datas) ? $datas : [$datas]; array_map(function ($key, $data) { switch (true) { case is_array($data) && array_filter($data, function ($d) { return is_array($d) || is_object($d); }): case is_object($data) && array_filter((array) $data, function ($d) { return is_array($d) || is_object($d); }): $this->properties->put($key, PropertyCollection::make($data)->setFieldName($key)->setType(is_object($data) ? SchemaType::OBJECT_TYPE : SchemaType::ARRAY_TYPE)->withSchemaItemCollectionCollection()); break; default: $this->properties->put($key, PropertyItem::make($data)->setFieldName($key)->settingData()); break; } }, array_keys($datas), array_values($datas)); return $this; }
/** * Возвращает коллекцию свойств документа * @param number $i * @return PropertyCollection | Property */ function getProperties($i = null) { $props =& $this->properties; if (!$props) { if ($this->getId()) { $props = TDataBaseDocument::getPropertiesByParentId(TRUSTED_DB_TABLE_DOCUMENTS_PROPERTY, $this->getId()); } else { $props = new PropertyCollection(); } } $res = $props; if (!is_null($i)) { $res = $props->items($i); } return $res; }