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


PHP Service::hasInheritableParentObject方法代码示例

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


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

示例1: recursiveGetActiveGroupsIds

 /**
  * @param $object \Object_Abstract
  * @param array $activeGroups
  * @return array
  */
 public function recursiveGetActiveGroupsIds($object, $activeGroups = [])
 {
     if (!$object) {
         return;
     }
     $getter = "get" . ucfirst($this->getName());
     /** @var  $classificationStore Object\Classificationstore */
     $classificationStore = $object->{$getter}();
     $activeGroupIds = $classificationStore->getActiveGroups();
     if ($activeGroupIds) {
         foreach ($activeGroupIds as $groupId => $enabled) {
             if ($enabled) {
                 $activeGroups[$groupId] = $enabled;
             }
         }
     }
     $class = $object->getClass();
     $inheritanceAllowed = $class->getAllowInherit();
     if ($inheritanceAllowed) {
         $parent = Object\Service::hasInheritableParentObject($object);
         if ($parent) {
             $activeGroups = $this->recursiveGetActiveGroupsIds($parent, $activeGroups);
         }
     }
     return $activeGroups;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:31,代码来源:Classificationstore.php

示例2: getParentValue

 private function getParentValue($object, $key)
 {
     $parent = Object\Service::hasInheritableParentObject($object);
     $getter = "get" . ucfirst($key);
     if ($parent) {
         $value = $parent->{$getter}();
         if ($value) {
             $result = new stdClass();
             $result->value = $value;
             $result->id = $parent->getId();
             return $result;
         } else {
             return $this->getParentValue($parent, $key);
         }
     }
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:16,代码来源:ObjectController.php

示例3: getValueFromParent

 /**
  * @return mixed
  */
 public function getValueFromParent($key)
 {
     $parent = Object\Service::hasInheritableParentObject($this->getObject());
     if (!empty($parent)) {
         $containerGetter = "get" . ucfirst($this->fieldname);
         $brickGetter = "get" . ucfirst($this->getType());
         $getter = "get" . ucfirst($key);
         if ($parent->{$containerGetter}()->{$brickGetter}()) {
             return $parent->{$containerGetter}()->{$brickGetter}()->{$getter}();
         }
     }
     return null;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:16,代码来源:AbstractData.php

示例4: getProperties

 /**
  * @param bool $forEditMode
  * @return array
  */
 public function getProperties($forEditMode = false)
 {
     $result = array();
     $object = Object::getById($this->objectId);
     if (!$object) {
         throw new \Exception('Object with Id ' . $this->objectId . ' not found');
     }
     $objectName = $object->getKey();
     $internalKeys = array();
     foreach ($this->arr as $pair) {
         $pair["inherited"] = false;
         $pair["source"] = $object->getId();
         $pair["groupId"] = Object\KeyValue\KeyConfig::getById($pair['key'])->getGroup();
         $result[] = $pair;
         $internalKeys[] = $pair["key"];
     }
     $blacklist = $internalKeys;
     $parent = Object\Service::hasInheritableParentObject($object);
     while ($parent) {
         $kv = $parent->getKeyvaluepairs();
         $parentProperties = $kv ? $kv->getInternalProperties() : [];
         $addedKeys = array();
         foreach ($parentProperties as $parentPair) {
             $parentKeyId = $parentPair["key"];
             $parentValue = $parentPair["value"];
             if (in_array($parentKeyId, $blacklist)) {
                 continue;
             }
             if ($this->multivalent && !$forEditMode && in_array($parentKeyId, $internalKeys)) {
                 continue;
             }
             $add = true;
             for ($i = 0; $i < count($result); ++$i) {
                 $resultPair = $result[$i];
                 $resultKey = $resultPair["key"];
                 $existingPair = null;
                 if ($resultKey == $parentKeyId) {
                     if ($this->multivalent && !in_array($resultKey, $blacklist)) {
                     } else {
                         $add = false;
                     }
                     // if the parent's key is already in the (internal) result list then
                     // we don't add it => not inherited.
                     if (!$this->multivalent) {
                         $add = false;
                         if (empty($resultPair["altSource"])) {
                             $resultPair["altSource"] = $parent->getId();
                             $resultPair["altValue"] = $parentPair["value"];
                         }
                     }
                     $result[$i] = $resultPair;
                 }
                 if (!$this->multivalent) {
                     break;
                 }
             }
             $addedKeys[] = $parentPair["key"];
             if ($add) {
                 $parentPair["inherited"] = true;
                 $parentPair["source"] = $parent->getId();
                 $parentPair["altSource"] = $parent->getId();
                 $parentPair["altValue"] = $parentPair["value"];
                 $parentPair["groupId"] = Object\KeyValue\KeyConfig::getById($parentPair['key'])->getGroup();
                 $result[] = $parentPair;
             }
         }
         foreach ($parentProperties as $parentPair) {
             $parentKeyId = $parentPair["key"];
             $blacklist[] = $parentKeyId;
         }
         $parent = Object\Service::hasInheritableParentObject($parent);
     }
     return $result;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:78,代码来源:KeyValue.php

示例5: doGetDataForEditMode

 /**
  * @param $data
  * @param $object
  * @param $fieldData
  * @param $metaData
  * @param int $level
  * @return array
  */
 private function doGetDataForEditMode($data, $object, &$fieldData, &$metaData, $level = 1)
 {
     $class = $object->getClass();
     $inheritanceAllowed = $class->getAllowInherit();
     $inherited = false;
     foreach ($data->getItems() as $language => $values) {
         foreach ($this->getFieldDefinitions() as $fd) {
             $key = $fd->getName();
             $fdata = $values[$fd->getName()];
             if (!isset($fieldData[$language][$key]) || $fd->isEmpty($fieldData[$language][$key])) {
                 // never override existing data
                 $fieldData[$language][$key] = $fdata;
                 if (!$fd->isEmpty($fdata)) {
                     $metaData[$language][$key] = array("inherited" => $level > 1, "objectid" => $object->getId());
                 }
             }
         }
     }
     if ($inheritanceAllowed) {
         // check if there is a parent with the same type
         $parent = Object\Service::hasInheritableParentObject($object);
         if ($parent) {
             // same type, iterate over all language and all fields and check if there is something missing
             $validLanguages = Tool::getValidLanguages();
             $foundEmptyValue = false;
             foreach ($validLanguages as $language) {
                 $fieldDefinitions = $this->getFieldDefinitions();
                 foreach ($fieldDefinitions as $fd) {
                     $key = $fd->getName();
                     if ($fd->isEmpty($fieldData[$language][$key])) {
                         $foundEmptyValue = true;
                         $inherited = true;
                         $metaData[$language][$key] = array("inherited" => true, "objectid" => $parent->getId());
                     }
                 }
             }
             if ($foundEmptyValue) {
                 // still some values are passing, ask the parent
                 $parentData = $parent->getLocalizedFields();
                 $parentResult = $this->doGetDataForEditMode($parentData, $parent, $fieldData, $metaData, $level + 1);
             }
         }
     }
     $result = array("data" => $fieldData, "metaData" => $metaData, "inherited" => $inherited);
     return $result;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:54,代码来源:Localizedfields.php

示例6: doGetDiffDataForEditmode

 /**
  * @param $data
  * @param $getter
  * @param $objectFromVersion
  * @param int $level
  * @return array
  */
 private function doGetDiffDataForEditmode($data, $getter, $objectFromVersion, $level = 0)
 {
     $parent = Object\Service::hasInheritableParentObject($data->getObject());
     $item = $data->{$getter}();
     if (!$item && !empty($parent)) {
         $data = $parent->{"get" . ucfirst($this->getName())}();
         return $this->doGetDiffDataForEditmode($data, $getter, $objectFromVersion, $level + 1);
     }
     if (!$item instanceof Object\Objectbrick\Data\AbstractData) {
         return null;
     }
     try {
         $collectionDef = Object\Objectbrick\Definition::getByKey($item->getType());
     } catch (\Exception $e) {
         return null;
     }
     $result = array();
     foreach ($collectionDef->getFieldDefinitions() as $fd) {
         $fieldData = $this->getDiffDataForField($item, $fd->getName(), $fd, $level, $data->getObject(), $getter, $objectFromVersion);
         //$fd->getDataForEditmode($item->{$fd->getName()});
         $diffdata = array();
         foreach ($fieldData as $subdata) {
             $diffdata["field"] = $this->getName();
             $diffdata["key"] = $this->getName() . "~" . $fd->getName();
             $diffdata["value"] = $subdata["value"];
             $diffdata["type"] = $subdata["type"];
             $diffdata["disabled"] = $subdata["disabled"];
             // this is not needed anymoe
             unset($subdata["type"]);
             unset($subdata["value"]);
             $diffdata["title"] = $this->getName() . " / " . $subdata["title"];
             $brickdata = array("brick" => substr($getter, 3), "name" => $fd->getName(), "subdata" => $subdata);
             $diffdata["data"] = $brickdata;
         }
         $result[] = $diffdata;
     }
     return $result;
 }
开发者ID:sfie,项目名称:pimcore,代码行数:45,代码来源:Objectbricks.php

示例7: getVariantDifferences

 /**
  * Get all Variants Differences
  *
  * @return array
  */
 public function getVariantDifferences()
 {
     $master = $this;
     $parent = Object\Service::hasInheritableParentObject($this);
     if ($parent) {
         $master = $parent;
     }
     return \CoreShop\Tool\Service::getDimensions($master);
 }
开发者ID:Cube-Solutions,项目名称:pimcore-coreshop,代码行数:14,代码来源:Product.php


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