public getProperties ( ) : |
||
return |
public function getProperties()
{
if ($this->properties === null) {
// try to get from cache
$cacheKey = "document_properties_" . $this->getId();
$properties = \Pimcore\Cache::load($cacheKey);
if (!is_array($properties)) {
$properties = $this->getDao()->getProperties();
$elementCacheTag = $this->getCacheTag();
$cacheTags = ["document_properties" => "document_properties", $elementCacheTag => $elementCacheTag];
\Pimcore\Cache::save($properties, $cacheKey, $cacheTags);
}
$this->setProperties($properties);
}
return $this->properties;
}
/** * @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(); }