当前位置: 首页>>代码示例>>PHP>>正文


PHP Object_Abstract::doGetInheritedValues方法代码示例

本文整理汇总了PHP中Object_Abstract::doGetInheritedValues方法的典型用法代码示例。如果您正苦于以下问题:PHP Object_Abstract::doGetInheritedValues方法的具体用法?PHP Object_Abstract::doGetInheritedValues怎么用?PHP Object_Abstract::doGetInheritedValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Object_Abstract的用法示例。


在下文中一共展示了Object_Abstract::doGetInheritedValues方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($element)
 {
     parent::__construct($element);
     if ($element instanceof Object_Product) {
         $backup = Object_Abstract::doGetInheritedValues($element);
         Object_Abstract::setGetInheritedValues(true);
         if ($element->getParent() instanceof Object_Product) {
             $this->elementIcon = '/pimcore/static/img/icon/tag_green.png';
             $this->elementIconClass = null;
         } else {
             $this->elementIcon = '/pimcore/static/img/icon/tag_blue.png';
             $this->elementIconClass = null;
         }
         Object_Abstract::setGetInheritedValues($backup);
     }
 }
开发者ID:ascertain,项目名称:NGshop,代码行数:16,代码来源:AdminStyle.php

示例2: preGetValue

 /**
  * enables inheritance for field collections, if xxxInheritance field is available and set to string 'true'
  *
  * @param string $key
  * @return mixed|Object_Fieldcollection
  */
 public function preGetValue($key)
 {
     if ($this->getClass()->getAllowInherit() && Object_Abstract::doGetInheritedValues() && $this->getClass()->getFieldDefinition($key) instanceof Object_Class_Data_Fieldcollections) {
         $checkInheritanceKey = $key . "Inheritance";
         if ($this->{'get' . $checkInheritanceKey}() == "true") {
             $parentValue = $this->getValueFromParent($key);
             $data = $this->{$key};
             if (!$data) {
                 $data = $this->getClass()->getFieldDefinition($key)->preGetData($this);
             }
             if (!$data) {
                 return $parentValue;
             } else {
                 $value = new Object_Fieldcollection($data->getItems());
                 if (!empty($parentValue)) {
                     foreach ($parentValue as $entry) {
                         $value->add($entry);
                     }
                 }
                 return $value;
             }
         }
     }
     return parent::preGetValue($key);
 }
开发者ID:ascertain,项目名称:NGshop,代码行数:31,代码来源:DefaultProduct.php

示例3: update

 /**
  * @return void
  */
 protected function update()
 {
     $fieldDefintions = $this->getO_class()->getFieldDefinitions();
     foreach ($fieldDefintions as $fd) {
         $getter = "get" . ucfirst($fd->getName());
         $setter = "set" . ucfirst($fd->getName());
         if (method_exists($this, $getter)) {
             //To make sure, inherited values are not set again
             $inheritedValues = Object_Abstract::doGetInheritedValues();
             Object_Abstract::setGetInheritedValues(false);
             $value = $this->{$getter}();
             if (is_array($value) and ($fd instanceof Object_Class_Data_Multihref or $fd instanceof Object_Class_Data_Objects)) {
                 //don't save relations twice
                 $this->{$setter}(array_unique($value));
             }
             Object_Abstract::setGetInheritedValues($inheritedValues);
             $value = $this->{$getter}();
             $omitMandatoryCheck = $this->getOmitMandatoryCheck();
             /*$timeSinceCreation = (time()-$this->getCreationDate());
               if($timeSinceCreation <= 5){
                   // legacy hack: in previous version there was no check for mandatory fields,
                   // and everybody uses the save method for new object creation - so now let's evict the mandatory check
                   // if the object was created within the last 5 seconds
                   $omitMandatoryCheck=true;
                   Logger::debug("executing mandatory fields check for object [ ".$this->getId()." ]");
               }
               */
             //check throws Exception
             try {
                 $fd->checkValidity($value, $omitMandatoryCheck);
             } catch (Exception $e) {
                 if ($this->getO_class()->getAllowInherit()) {
                     //try again with parent data when inheritance in activated
                     try {
                         $getInheritedValues = Object_Abstract::doGetInheritedValues();
                         Object_Abstract::setGetInheritedValues(true);
                         $value = $this->{$getter}();
                         $fd->checkValidity($value, $omitMandatoryCheck);
                         Object_Abstract::setGetInheritedValues($getInheritedValues);
                     } catch (Exception $e) {
                         throw new Exception($e->getMessage() . " fieldname=" . $fd->getName());
                     }
                 } else {
                     throw new Exception($e->getMessage() . " fieldname=" . $fd->getName());
                 }
             }
         }
     }
     parent::update();
     $this->getResource()->update();
     $this->saveScheduledTasks();
     $this->saveVersion(false, false);
     $this->saveChilds();
     Pimcore_API_Plugin_Broker::getInstance()->postUpdateObject($this);
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:58,代码来源:Concrete.php

示例4: setDataFromElement

 /**
  * @param  Element_Interface  $element
  * @return void
  */
 public function setDataFromElement($element)
 {
     $this->data = null;
     $this->id = new Search_Backend_Data_Id($element);
     $this->fullPath = $element->getFullPath();
     $this->creationDate = $element->getCreationDate();
     $this->modificationDate = $element->getModificationDate();
     $this->userModification = $element->getUserModification();
     $this->userOwner = $element->getUserOwner();
     $this->type = $element->getType();
     if ($element instanceof Object_Concrete) {
         $this->subtype = $element->getO_className();
     } else {
         $this->subtype = $this->type;
     }
     $properties = $element->getProperties();
     if (is_array($properties)) {
         foreach ($properties as $nextProperty) {
             if ($nextProperty->getType() == 'text') {
                 $this->properties .= $nextProperty->getData() . " ";
             }
         }
     }
     if ($element instanceof Document) {
         if ($element instanceof Document_Folder) {
             $this->data = $element->getKey();
             $this->published = true;
         } else {
             if ($element instanceof Document_Link) {
                 $this->published = $element->isPublished();
                 $this->data = $element->getName() . " " . $element->getTitle() . " " . $element->getHref();
             } else {
                 if ($element instanceof Document_PageSnippet) {
                     $this->published = $element->isPublished();
                     $elements = $element->getElements();
                     if (is_array($elements)) {
                         foreach ($elements as $tag) {
                             if ($tag instanceof Document_Tag_Interface) {
                                 ob_start();
                                 $this->data .= strip_tags($tag->frontend()) . " ";
                                 $this->data .= ob_get_clean();
                             }
                         }
                     }
                     if ($element instanceof Document_Page) {
                         $this->published = $element->isPublished();
                         $this->data .= " " . $element->getName() . " " . $element->getTitle() . " " . $element->getDescription() . " " . $element->getKeywords();
                     }
                 }
             }
         }
     } else {
         if ($element instanceof Asset) {
             $this->data = $element->getFilename();
             $this->published = true;
         } else {
             if ($element instanceof Object_Abstract) {
                 if ($element instanceof Object_Concrete) {
                     $getInheritedValues = Object_Abstract::doGetInheritedValues();
                     Object_Abstract::setGetInheritedValues(true);
                     $this->published = $element->isPublished();
                     foreach ($element->getClass()->getFieldDefinitions() as $key => $value) {
                         // Object_Class_Data_Fieldcollections is special because it doesn't support the csv export
                         if ($value instanceof Object_Class_Data_Fieldcollections) {
                             $getter = "get" . $value->getName();
                             $this->fieldcollectionData .= Pimcore_Tool_Serialize::serialize($value->getDataForEditmode($element->{$getter}(), $element)) . " ";
                         } else {
                             if ($value instanceof Object_Class_Data_Localizedfields) {
                                 $getter = "get" . $value->getName();
                                 $this->localizedData .= Pimcore_Tool_Serialize::serialize($value->getDataForEditmode($element->{$getter}(), $element)) . " ";
                             } else {
                                 $this->data .= $value->getForCsvExport($element) . " ";
                             }
                         }
                     }
                     Object_Abstract::setGetInheritedValues($getInheritedValues);
                 } else {
                     if ($element instanceof Object_Folder) {
                         $this->data = $element->getKey();
                         $this->published = true;
                     }
                 }
             } else {
                 Logger::crit("Search_Backend_Data received an unknown element!");
             }
         }
     }
 }
开发者ID:nblackman,项目名称:pimcore,代码行数:92,代码来源:Data.php

示例5: save

 /**
  * @param Object_Concrete $object
  * @return void
  */
 public function save(Object_Concrete $object)
 {
     // HACK: set the pimcore admin mode to false to get the inherited values from parent if this source one is empty
     $inheritedValues = Object_Abstract::doGetInheritedValues();
     $storetable = $this->model->getDefinition()->getTableName($object->getClass(), false);
     $querytable = $this->model->getDefinition()->getTableName($object->getClass(), true);
     $this->inheritanceHelper = new Object_Concrete_Resource_InheritanceHelper($object->getClassId(), "o_id", $storetable, $querytable);
     $this->createDataRows($object);
     Object_Abstract::setGetInheritedValues(false);
     $fd = $this->model->getDefinition()->getFieldDefinitions();
     $data = array();
     $data["o_id"] = $object->getId();
     $data["fieldname"] = $this->model->getFieldname();
     // remove all relations
     try {
         $this->db->delete("object_relations_" . $object->getClassId(), "src_id = " . $object->getId() . " AND ownertype = 'objectbrick' AND ownername = '" . $this->model->getFieldname() . "'");
     } catch (Exception $e) {
         Logger::warning("Error during removing old relations: " . $e);
     }
     foreach ($fd as $key => $value) {
         $getter = "get" . ucfirst($value->getName());
         if (method_exists($fd, "save")) {
             // for fieldtypes which have their own save algorithm eg. objects, multihref, ...
             $value->save($this->model);
         } else {
             if ($value->getColumnType()) {
                 if (is_array($value->getColumnType())) {
                     $insertDataArray = $value->getDataForResource($this->model->{$getter}(), $object);
                     $data = array_merge($data, $insertDataArray);
                 } else {
                     $insertData = $value->getDataForResource($this->model->{$getter}(), $object);
                     $data[$key] = $insertData;
                 }
             } else {
                 if (method_exists($value, "save")) {
                     // for fieldtypes which have their own save algorithm eg. fieldcollections
                     $value->save($this->model);
                 }
             }
         }
     }
     $this->db->update($storetable, $data, $this->db->quoteInto("o_id = ?", $object->getId()));
     // get data for query table
     // $tableName = $this->model->getDefinition()->getTableName($object->getClass(), true);
     // this is special because we have to call each getter to get the inherited values from a possible parent object
     Object_Abstract::setGetInheritedValues(true);
     $objectVars = get_object_vars($this->model);
     $data = array();
     $data["o_id"] = $object->getId();
     $data["fieldname"] = $this->model->getFieldname();
     $this->inheritanceHelper->resetFieldsToCheck();
     $oldData = $this->db->fetchRow("SELECT * FROM " . $querytable . " WHERE o_id = ?", $object->getId());
     foreach ($objectVars as $key => $value) {
         $fd = $this->model->getDefinition()->getFieldDefinition($key);
         if ($fd) {
             if ($fd->getQueryColumnType()) {
                 //exclude untouchables if value is not an array - this means data has not been loaded
                 if (!is_array($this->model->{$key})) {
                     $method = "get" . $key;
                     $insertData = $fd->getDataForQueryResource($this->model->{$method}(), $object);
                     if (is_array($insertData)) {
                         $data = array_merge($data, $insertData);
                     } else {
                         $data[$key] = $insertData;
                     }
                     //get changed fields for inheritance
                     if ($fd->isRelationType()) {
                         if (is_array($insertData)) {
                             $doInsert = false;
                             foreach ($insertData as $insertDataKey => $insertDataValue) {
                                 if ($oldData[$insertDataKey] != $insertDataValue) {
                                     $doInsert = true;
                                 }
                             }
                             if ($doInsert) {
                                 $this->inheritanceHelper->addRelationToCheck($key, array_keys($insertData));
                             }
                         } else {
                             if ($oldData[$key] != $insertData) {
                                 $this->inheritanceHelper->addRelationToCheck($key);
                             }
                         }
                     } else {
                         if (is_array($insertData)) {
                             foreach ($insertData as $insertDataKey => $insertDataValue) {
                                 if ($oldData[$insertDataKey] != $insertDataValue) {
                                     $this->inheritanceHelper->addFieldToCheck($insertDataKey);
                                 }
                             }
                         } else {
                             if ($oldData[$key] != $insertData) {
                                 $this->inheritanceHelper->addFieldToCheck($key);
                             }
                         }
                     }
                 } else {
//.........这里部分代码省略.........
开发者ID:ngocanh,项目名称:pimcore,代码行数:101,代码来源:Resource.php

示例6: save

 /**
  * @param Object_Concrete $object
  * @return void
  */
 public function save($object)
 {
     $getters = $this->getBrickGetters();
     foreach ($getters as $getter) {
         $brick = $this->{$getter}();
         if ($brick instanceof Object_Objectbrick_Data_Abstract) {
             if ($brick->getDoDelete()) {
                 $brick->delete($object);
                 $setter = "s" . substr($getter, 1);
                 $this->{$setter}(null);
                 //check if parent object has brick, and if so, create an empty brick to enable inheritance
                 $parentBrick = null;
                 $inheritanceModeBackup = Object_Abstract::getGetInheritedValues();
                 Object_Abstract::setGetInheritedValues(true);
                 if (Object_Abstract::doGetInheritedValues($object)) {
                     $container = $object->getValueFromParent($this->fieldname);
                     if (!empty($container)) {
                         $parentBrick = $container->{$getter}();
                     }
                 }
                 Object_Abstract::setGetInheritedValues($inheritanceModeBackup);
                 if (!empty($parentBrick)) {
                     $brickType = "Object_Objectbrick_Data_" . ucfirst($parentBrick->getType());
                     $brick = new $brickType($object);
                     $brick->setFieldname($this->getFieldname());
                     $brick->save($object);
                     $this->{$setter}($brick);
                 }
             } else {
                 $brick->setFieldname($this->getFieldname());
                 $brick->save($object);
             }
         } else {
             if ($brick == null) {
                 $parentBrick = null;
                 $inheritanceModeBackup = Object_Abstract::getGetInheritedValues();
                 Object_Abstract::setGetInheritedValues(true);
                 if (Object_Abstract::doGetInheritedValues($object)) {
                     $container = $object->getValueFromParent($this->fieldname);
                     if (!empty($container)) {
                         $parentBrick = $container->{$getter}();
                     }
                 }
                 Object_Abstract::setGetInheritedValues($inheritanceModeBackup);
                 if (!empty($parentBrick)) {
                     $brickType = "Object_Objectbrick_Data_" . ucfirst($parentBrick->getType());
                     $brick = new $brickType($object);
                     $brick->setFieldname($this->getFieldname());
                     $brick->save($object);
                 }
             }
         }
     }
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:58,代码来源:Objectbrick.php

示例7: update

 /**
  * Save changes to database, it's an good idea to use save() instead
  *
  * @return void
  */
 public function update()
 {
     // check if the rows must be inserted or updated in the query and store table
     if ($this->model->getId()) {
         try {
             $this->insertOrUpdate = $this->db->fetchRow("SELECT\r\n                  object_store_" . $this->model->getO_classId() . ".oo_id as store, object_query_" . $this->model->getO_classId() . ".oo_id as query, object.o_id as object\r\n                FROM\r\n                  (SELECT o_id FROM objects WHERE o_id = " . $this->model->getId() . ") as object LEFT JOIN\r\n                  object_store_" . $this->model->getO_classId() . " ON object.o_id = object_store_" . $this->model->getO_classId() . ".oo_id LEFT JOIN\r\n                  object_query_" . $this->model->getO_classId() . " ON object.o_id = object_query_" . $this->model->getO_classId() . ".oo_id;");
         } catch (Exception $e) {
             $this->insertOrUpdate = null;
         }
     }
     if (empty($this->insertOrUpdate)) {
         $this->insertOrUpdate = array("query" => null, "store" => null, "object" => null);
     }
     parent::update();
     //$this->createDataRows();
     // get fields which shouldn't be updated
     $fd = $this->model->geto_class()->getFieldDefinitions();
     $untouchable = array();
     foreach ($fd as $key => $value) {
         if (method_exists($value, "getLazyLoading") && $value->getLazyLoading()) {
             if (!in_array($key, $this->model->getLazyLoadedFields())) {
                 //this is a relation subject to lazy loading - it has not been loaded
                 $untouchable[] = $key;
             }
         }
     }
     // empty relation table except the untouchable fields (eg. lazy loading fields)
     if (count($untouchable) > 0) {
         $untouchables = "'" . implode("','", $untouchable) . "'";
         $this->db->delete("object_relations_" . $this->model->getO_classId(), $this->db->quoteInto("src_id = ? AND fieldname not in (" . $untouchables . ") AND ownertype = 'object'", $this->model->getO_id()));
     } else {
         $this->db->delete("object_relations_" . $this->model->getO_classId(), $this->db->quoteInto("src_id = ? AND ownertype = 'object'", $this->model->getO_id()));
     }
     $inheritedValues = Object_Abstract::doGetInheritedValues();
     Object_Abstract::setGetInheritedValues(false);
     $data = array();
     $data["oo_id"] = $this->model->getO_id();
     foreach ($fd as $key => $value) {
         $getter = "get" . ucfirst($key);
         if (method_exists($value, "save")) {
             // for fieldtypes which have their own save algorithm eg. fieldcollections, objects, multihref, ...
             $value->save($this->model);
         } else {
             if ($value->getColumnType()) {
                 // pimcore saves the values with getDataForResource
                 if (is_array($value->getColumnType())) {
                     $insertDataArray = $value->getDataForResource($this->model->{$getter}(), $this->model);
                     if (is_array($insertDataArray)) {
                         $data = array_merge($data, $insertDataArray);
                     }
                 } else {
                     $insertData = $value->getDataForResource($this->model->{$getter}(), $this->model);
                     $data[$key] = $insertData;
                 }
             }
         }
     }
     if ($this->insertOrUpdate["store"]) {
         $this->db->update("object_store_" . $this->model->getO_classId(), $data, $this->db->quoteInto("oo_id = ?", $this->model->getO_id()));
     } else {
         $this->db->insert("object_store_" . $this->model->getO_classId(), $data);
     }
     // get data for query table
     // this is special because we have to call each getter to get the inherited values from a possible parent object
     Object_Abstract::setGetInheritedValues(true);
     $object = get_object_vars($this->model);
     $data = array();
     $this->inheritanceHelper->resetFieldsToCheck();
     $oldData = $this->db->fetchRow("SELECT * FROM object_query_" . $this->model->getO_classId() . " WHERE oo_id = ?", $this->model->getId());
     foreach ($object as $key => $value) {
         $fd = $this->model->geto_class()->getFieldDefinition($key);
         if ($fd) {
             if ($fd->getQueryColumnType()) {
                 //exclude untouchables if value is not an array - this means data has not been loaded
                 if (!(in_array($key, $untouchable) and !is_array($this->model->{$key}))) {
                     $method = "get" . $key;
                     $insertData = $fd->getDataForQueryResource($this->model->{$method}(), $this->model);
                     if (is_array($insertData)) {
                         $data = array_merge($data, $insertData);
                     } else {
                         $data[$key] = $insertData;
                     }
                     //get changed fields for inheritance
                     if ($fd->isRelationType()) {
                         if (is_array($insertData)) {
                             $doInsert = false;
                             foreach ($insertData as $insertDataKey => $insertDataValue) {
                                 if ($oldData[$insertDataKey] != $insertDataValue) {
                                     $doInsert = true;
                                 }
                             }
                             if ($doInsert) {
                                 $this->inheritanceHelper->addRelationToCheck($key, array_keys($insertData));
                             }
                         } else {
//.........这里部分代码省略.........
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:101,代码来源:Resource.php

示例8: setDataFromElement

 /**
  * @param  Element_Interface  $element
  * @return void
  */
 public function setDataFromElement($element)
 {
     $this->data = null;
     $this->id = new Search_Backend_Data_Id($element);
     $this->fullPath = $element->getFullPath();
     $this->creationDate = $element->getCreationDate();
     $this->modificationDate = $element->getModificationDate();
     $this->userModification = $element->getUserModification();
     $this->userOwner = $element->getUserOwner();
     $this->type = $element->getType();
     if ($element instanceof Object_Concrete) {
         $this->subtype = $element->getO_className();
     } else {
         $this->subtype = $this->type;
     }
     $this->properties = "";
     $properties = $element->getProperties();
     if (is_array($properties)) {
         foreach ($properties as $nextProperty) {
             if ($nextProperty->getType() == 'text') {
                 $this->properties .= $nextProperty->getData() . " ";
             }
         }
     }
     $this->data = "";
     if ($element instanceof Document) {
         if ($element instanceof Document_Folder) {
             $this->data = $element->getKey();
             $this->published = true;
         } else {
             if ($element instanceof Document_Link) {
                 $this->published = $element->isPublished();
                 $this->data = $element->getName() . " " . $element->getTitle() . " " . $element->getHref();
             } else {
                 if ($element instanceof Document_PageSnippet) {
                     $this->published = $element->isPublished();
                     $elements = $element->getElements();
                     if (is_array($elements) && !empty($elements)) {
                         foreach ($elements as $tag) {
                             if ($tag instanceof Document_Tag_Interface) {
                                 ob_start();
                                 $this->data .= strip_tags($tag->frontend()) . " ";
                                 $this->data .= ob_get_clean();
                             }
                         }
                     }
                     if ($element instanceof Document_Page) {
                         $this->published = $element->isPublished();
                         $this->data .= " " . $element->getName() . " " . $element->getTitle() . " " . $element->getDescription() . " " . $element->getKeywords();
                     }
                 }
             }
         }
     } else {
         if ($element instanceof Asset) {
             $this->data = $element->getFilename();
             $this->published = true;
         } else {
             if ($element instanceof Object_Abstract) {
                 if ($element instanceof Object_Concrete) {
                     $getInheritedValues = Object_Abstract::doGetInheritedValues();
                     Object_Abstract::setGetInheritedValues(true);
                     $this->published = $element->isPublished();
                     foreach ($element->getClass()->getFieldDefinitions() as $key => $value) {
                         // Object_Class_Data_Fieldcollections, Object_Class_Data_Localizedfields and Object_Class_Data_Objectbricks is special because it doesn't support the csv export
                         if ($value instanceof Object_Class_Data_Fieldcollections) {
                             $getter = "get" . $value->getName();
                             $fcData = $element->{$getter}();
                             if ($fcData instanceof Object_Fieldcollection) {
                                 foreach ($fcData as $item) {
                                     if (!$item instanceof Object_Fieldcollection_Data_Abstract) {
                                         continue;
                                     }
                                     try {
                                         $collectionDef = Object_Fieldcollection_Definition::getByKey($item->getType());
                                     } catch (Exception $e) {
                                         continue;
                                     }
                                     foreach ($collectionDef->getFieldDefinitions() as $fd) {
                                         $this->data .= $fd->getForCsvExport($item) . " ";
                                     }
                                 }
                             }
                             //$this->data .= Pimcore_Tool_Serialize::serialize($value->getDataForEditmode($element->$getter(), $element))." ";
                         } else {
                             if ($value instanceof Object_Class_Data_Localizedfields) {
                                 // only for text-values at the moment, because the CSV doesn't work for localized fields (getter-problem)
                                 $getter = "get" . $value->getName();
                                 $lfData = $element->{$getter}();
                                 if ($lfData instanceof Object_Localizedfield) {
                                     foreach ($lfData->getItems() as $language => $values) {
                                         foreach ($values as $lData) {
                                             if (is_string($lData)) {
                                                 $this->data .= $lData . " ";
                                             }
                                         }
//.........这里部分代码省略.........
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:101,代码来源:Data.php


注:本文中的Object_Abstract::doGetInheritedValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。