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


PHP AbstractObject::getGetInheritedValues方法代码示例

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


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

示例1: save

 /**
  * @param Concrete $object
  * @return void
  */
 public function save($object)
 {
     // set the current object again, this is necessary because the related object in $this->object can change (eg. clone & copy & paste, etc.)
     $this->setObject($object);
     $getters = $this->getBrickGetters();
     foreach ($getters as $getter) {
         $brick = $this->{$getter}();
         if ($brick instanceof Objectbrick\Data\AbstractData) {
             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 = AbstractObject::getGetInheritedValues();
                 AbstractObject::setGetInheritedValues(true);
                 if (AbstractObject::doGetInheritedValues($object)) {
                     $container = $object->getValueFromParent($this->fieldname);
                     if (!empty($container)) {
                         $parentBrick = $container->{$getter}();
                     }
                 }
                 AbstractObject::setGetInheritedValues($inheritanceModeBackup);
                 if (!empty($parentBrick)) {
                     $brickType = "\\Pimcore\\Model\\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 = AbstractObject::getGetInheritedValues();
                 AbstractObject::setGetInheritedValues(true);
                 if (AbstractObject::doGetInheritedValues($object)) {
                     $container = $object->getValueFromParent($this->fieldname);
                     if (!empty($container)) {
                         $parentBrick = $container->{$getter}();
                     }
                 }
                 AbstractObject::setGetInheritedValues($inheritanceModeBackup);
                 if (!empty($parentBrick)) {
                     $brickType = "\\Pimcore\\Model\\Object\\Objectbrick\\Data\\" . ucfirst($parentBrick->getType());
                     $brick = new $brickType($object);
                     $brick->setFieldname($this->getFieldname());
                     $brick->save($object);
                 }
             }
         }
     }
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:60,代码来源:Objectbrick.php

示例2: getDataForField

 /**
  * gets recursively attribute data from parent and fills objectData and metaData
  *
  * @param  $item
  * @param  $key
  * @param  $fielddefinition
  * @return mixed
  */
 private function getDataForField($item, $key, $fielddefinition, $level, $baseObject, $getter, $objectFromVersion)
 {
     $result = new \stdClass();
     $parent = Object\Service::hasInheritableParentObject($baseObject);
     $valueGetter = "get" . ucfirst($key);
     // relations but not for objectsMetadata, because they have additional data which cannot be loaded directly from the DB
     if (!$objectFromVersion && method_exists($fielddefinition, "getLazyLoading") && $fielddefinition->getLazyLoading() && !$fielddefinition instanceof Object\ClassDefinition\Data\ObjectsMetadata && !$fielddefinition instanceof Object\ClassDefinition\Data\MultihrefMetadata) {
         //lazy loading data is fetched from DB differently, so that not every relation object is instantiated
         if ($fielddefinition->isRemoteOwner()) {
             $refKey = $fielddefinition->getOwnerFieldName();
             $refId = $fielddefinition->getOwnerClassId();
         } else {
             $refKey = $key;
         }
         $relations = $item->getRelationData($refKey, !$fielddefinition->isRemoteOwner(), $refId);
         if (empty($relations) && !empty($parent)) {
             $parentItem = $parent->{"get" . ucfirst($this->getName())}();
             if (!empty($parentItem)) {
                 $parentItem = $parentItem->{$getter}();
                 if ($parentItem) {
                     return $this->getDataForField($parentItem, $key, $fielddefinition, $level + 1, $parent, $getter, $objectFromVersion);
                 }
             }
         }
         $data = array();
         if ($fielddefinition instanceof Object\ClassDefinition\Data\Href) {
             $data = $relations[0];
         } else {
             foreach ($relations as $rel) {
                 if ($fielddefinition instanceof Object\ClassDefinition\Data\Objects) {
                     $data[] = array($rel["id"], $rel["path"], $rel["subtype"]);
                 } else {
                     $data[] = array($rel["id"], $rel["path"], $rel["type"], $rel["subtype"]);
                 }
             }
         }
         $result->objectData = $data;
         $result->metaData['objectid'] = $baseObject->getId();
         $result->metaData['inherited'] = $level != 0;
     } else {
         $editmodeValue = null;
         if (!empty($item)) {
             $fieldValue = $item->{$valueGetter}();
             $editmodeValue = $fielddefinition->getDataForEditmode($fieldValue, $baseObject);
         }
         if ($fielddefinition->isEmpty($fieldValue) && !empty($parent)) {
             $backup = Object\AbstractObject::getGetInheritedValues();
             Object\AbstractObject::setGetInheritedValues(true);
             $parentItem = $parent->{"get" . ucfirst($this->getName())}()->{$getter}();
             Object\AbstractObject::setGetInheritedValues($backup);
             if (!empty($parentItem)) {
                 return $this->getDataForField($parentItem, $key, $fielddefinition, $level + 1, $parent, $getter, $objectFromVersion);
             }
         }
         $result->objectData = $editmodeValue;
         $result->metaData['objectid'] = $baseObject->getId();
         $result->metaData['inherited'] = $level != 0;
     }
     return $result;
 }
开发者ID:sfie,项目名称:pimcore,代码行数:68,代码来源:Objectbricks.php

示例3: getDimensions

 /**
  * Gets all Differences in the variants
  *
  * @param CoreShopProduct $product
  * @return array
  */
 public static function getDimensions(CoreShopProduct $product)
 {
     $variants = $product->getChilds(array(AbstractObject::OBJECT_TYPE_VARIANT));
     $fieldDefinition = $product->getClass()->getFieldDefinition("dimensions");
     $variantsAndMaster = array_merge(array($product), $variants);
     $currentInheritedValue = AbstractObject::getGetInheritedValues();
     AbstractObject::setGetInheritedValues(false);
     $overwrittenKeyValues = array();
     $overwrittenKeys = array();
     if (count($variants) > 0) {
         foreach ($variants as $variant) {
             $fieldData = $variant->getDimensions();
             $value = $fieldDefinition->getDataForEditmode($fieldData, $variant);
             //Search for not inherited fields
             foreach ($value as $singleBrickData) {
                 if (!$singleBrickData) {
                     continue;
                 }
                 if (!array_key_exists($singleBrickData['type'], $overwrittenKeys)) {
                     $overwrittenKeys[$singleBrickData['type']] = array();
                 }
                 foreach ($singleBrickData['metaData'] as $key => $meta) {
                     if (!$meta['inherited']) {
                         if (!in_array($key, $overwrittenKeys[$singleBrickData['type']])) {
                             $overwrittenKeys[$singleBrickData['type']][] = $key;
                         }
                     }
                 }
             }
         }
         //We now have the keys and reloop the variants to get all the values
         foreach ($variantsAndMaster as $variant) {
             $fieldData = $variant->getDimensions();
             $value = $fieldDefinition->getDataForEditmode($fieldData, $variant);
             foreach ($value as $singleBrickData) {
                 if (!$singleBrickData) {
                     continue;
                 }
                 if (array_key_exists($singleBrickData['type'], $overwrittenKeys)) {
                     if (!is_array($overwrittenKeyValues[$singleBrickData['type']])) {
                         $overwrittenKeyValues[$singleBrickData['type']] = array();
                     }
                     foreach ($overwrittenKeys[$singleBrickData['type']] as $key) {
                         $found = false;
                         foreach ($overwrittenKeyValues[$singleBrickData['type']][$key] as $existingValue) {
                             if ($existingValue['value'] == $singleBrickData['data'][$key]) {
                                 $found = true;
                                 break;
                             }
                         }
                         if (!$found) {
                             $overwrittenKeyValues[$singleBrickData['type']][$key][] = array("value" => $singleBrickData['data'][$key], "object" => $variant->getId());
                         }
                     }
                 }
             }
         }
     }
     AbstractObject::setGetInheritedValues($currentInheritedValue);
     return $overwrittenKeyValues;
 }
开发者ID:Cube-Solutions,项目名称:pimcore-coreshop,代码行数:67,代码来源:Service.php

示例4: save

 /**
  * Save Product
  *
  * @throws \Exception
  */
 public function save()
 {
     $currentGetInheritedValues = \Pimcore\Model\Object\AbstractObject::getGetInheritedValues();
     \Pimcore\Model\Object\AbstractObject::setGetInheritedValues(true);
     //Calculate Retail Price with Tax
     $retailPriceWithTax = $this->getRetailPrice() * (1 + $this->getTax());
     $this->setPrice($retailPriceWithTax);
     \Pimcore\Model\Object\AbstractObject::setGetInheritedValues($currentGetInheritedValues);
     parent::save();
 }
开发者ID:Cube-Solutions,项目名称:pimcore-coreshop,代码行数:15,代码来源:Product.php


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