/** * @param Model\Document $document * @throws \Zend_Json_Exception */ protected function addPropertiesToDocument(Model\Document $document) { // properties if ($this->getParam("properties")) { $properties = array(); // assign inherited properties foreach ($document->getProperties() as $p) { if ($p->isInherited()) { $properties[$p->getName()] = $p; } } $propertiesData = \Zend_Json::decode($this->getParam("properties")); if (is_array($propertiesData)) { foreach ($propertiesData as $propertyName => $propertyData) { $value = $propertyData["data"]; try { $property = new Property(); $property->setType($propertyData["type"]); $property->setName($propertyName); $property->setCtype("document"); $property->setDataFromEditmode($value); $property->setInheritable($propertyData["inheritable"]); $properties[$propertyName] = $property; } catch (\Exception $e) { \Logger::warning("Can't add " . $propertyName . " to document " . $document->getFullPath()); } } } if ($document->isAllowed("properties")) { $document->setProperties($properties); } } // force loading of properties $document->getProperties(); }
/** * @return array|null|Model\Property[] */ public function getProperties() { if ($this->properties === null) { $properties = parent::getProperties(); if ($this->getPropertiesFromSource() && $this->getSourceDocument()) { $sourceProperties = $this->getSourceDocument()->getProperties(); foreach ($sourceProperties as &$prop) { $prop = clone $prop; // because of cache $prop->setInherited(true); } $properties = array_merge($sourceProperties, $properties); } else { if ($this->getSourceDocument()) { $sourceProperties = $this->getSourceDocument()->getDao()->getProperties(false, true); foreach ($sourceProperties as &$prop) { $prop = clone $prop; // because of cache $prop->setInherited(true); } $properties = array_merge($sourceProperties, $properties); } } $this->setProperties($properties); } return $this->properties; }