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


PHP Service::getCalculatedFieldValue方法代码示例

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


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

示例1: getLocalizedValue

 /**
  * @param $name
  * @param null $language
  * @return 
  */
 public function getLocalizedValue($name, $language = null, $ignoreFallbackLanguage = false)
 {
     $data = null;
     $language = $this->getLanguage($language);
     $fieldDefinition = $this->getObject()->getClass()->getFieldDefinition("localizedfields")->getFieldDefinition($name);
     if ($fieldDefinition instanceof Model\Object\ClassDefinition\Data\CalculatedValue) {
         $valueData = new Model\Object\Data\CalculatedValue($fieldDefinition->getName());
         $valueData->setContextualData("localizedfield", "localizedfields", null, $language);
         $data = Service::getCalculatedFieldValue($this->getObject(), $valueData);
         return $data;
     }
     if ($this->languageExists($language)) {
         if (array_key_exists($name, $this->items[$language])) {
             $data = $this->items[$language][$name];
         }
     }
     // check for inherited value
     $doGetInheritedValues = AbstractObject::doGetInheritedValues();
     if ($fieldDefinition->isEmpty($data) && $doGetInheritedValues) {
         $object = $this->getObject();
         $class = $object->getClass();
         $allowInherit = $class->getAllowInherit();
         if ($allowInherit) {
             if ($object->getParent() instanceof AbstractObject) {
                 $parent = $object->getParent();
                 while ($parent && $parent->getType() == "folder") {
                     $parent = $parent->getParent();
                 }
                 if ($parent && ($parent->getType() == "object" || $parent->getType() == "variant")) {
                     if ($parent->getClassId() == $object->getClassId()) {
                         $method = "getLocalizedfields";
                         if (method_exists($parent, $method)) {
                             $localizedFields = $parent->getLocalizedFields();
                             if ($localizedFields instanceof Localizedfield) {
                                 if ($localizedFields->object->getId() != $this->object->getId()) {
                                     $data = $localizedFields->getLocalizedValue($name, $language, true);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // check for fallback value
     if ($fieldDefinition->isEmpty($data) && !$ignoreFallbackLanguage && self::doGetFallbackValues()) {
         foreach (Tool::getFallbackLanguagesFor($language) as $l) {
             if ($this->languageExists($l)) {
                 if (array_key_exists($name, $this->items[$l])) {
                     $data = $this->getLocalizedValue($name, $l);
                 }
             }
         }
     }
     if ($fieldDefinition && method_exists($fieldDefinition, "preGetData")) {
         $data = $fieldDefinition->preGetData($this, array("data" => $data, "language" => $language, "name" => $name));
     }
     return $data;
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:64,代码来源:Localizedfield.php

示例2: getValueForFieldName

 /**
  * @param string $key
  * @return mixed
  */
 public function getValueForFieldName($key)
 {
     if (isset($this->{$key})) {
         return $this->{$key};
     } else {
         if ($this->getClass()->getFieldDefinition($key) instanceof Model\Object\ClassDefinition\Data\CalculatedValue) {
             $value = new Model\Object\Data\CalculatedValue($key);
             $value = Service::getCalculatedFieldValue($this, $value);
             return $value;
         }
     }
     return false;
 }
开发者ID:sfie,项目名称:pimcore,代码行数:17,代码来源:Concrete.php


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