getProperties() public method

Get a list of properties (including the inherited)
public getProperties ( ) : Property[]
return Property[]
示例#1
0
 /**
  * @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();
 }
示例#2
0
文件: Hardlink.php 项目: sfie/pimcore
 /**
  * @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;
 }