getProperties() 공개 메소드

Get a list of properties (including the inherited)
public getProperties ( ) : Property[]
리턴 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;
 }