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


PHP Property::setInherited方法代码示例

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


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

示例1: setProperty

 /**
  * set a property
  *
  * @param string $name
  * @param string $type
  * @param mixed $data
  * @param boolean $inherited
  */
 public function setProperty($name, $type, $data, $inherited = false)
 {
     $this->getProperties();
     $property = new Property();
     $property->setType($type);
     $property->setCid($this->getId());
     $property->setName($name);
     $property->setCtype("asset");
     $property->setData($data);
     $property->setInherited($inherited);
     $this->properties[$name] = $property;
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:20,代码来源:Asset.php

示例2: getProperties

 /**
  * Get the properties for the object from database and assign it
  *
  * @return void
  */
 public function getProperties($onlyInherited = false)
 {
     $properties = array();
     // collect properties via parent - ids
     $parentIds = array(1);
     $obj = $this->model->getParent();
     if ($obj) {
         while ($obj) {
             $parentIds[] = $obj->getId();
             $obj = $obj->getParent();
         }
     }
     $propertiesRaw = $this->db->fetchAll("SELECT * FROM properties WHERE ((cid IN (" . implode(",", $parentIds) . ") AND inheritable = 1) OR cid = ? )  AND ctype='asset'", $this->model->getId());
     // because this should be faster than mysql
     usort($propertiesRaw, function ($left, $right) {
         return strcmp($left["cpath"], $right["cpath"]);
     });
     foreach ($propertiesRaw as $propertyRaw) {
         try {
             $property = new Property();
             $property->setType($propertyRaw["type"]);
             $property->setCid($this->model->getId());
             $property->setName($propertyRaw["name"]);
             $property->setCtype("asset");
             $property->setDataFromResource($propertyRaw["data"]);
             $property->setInherited(true);
             if ($propertyRaw["cid"] == $this->model->getId()) {
                 $property->setInherited(false);
             }
             $property->setInheritable(false);
             if ($propertyRaw["inheritable"]) {
                 $property->setInheritable(true);
             }
             if ($onlyInherited && !$property->getInherited()) {
                 continue;
             }
             $properties[$propertyRaw["name"]] = $property;
         } catch (Exception $e) {
             Logger::error("can't add property " . $propertyRaw["name"] . " to asset " . $this->model->getFullPath());
         }
     }
     // if only inherited then only return it and dont call the setter in the model
     if ($onlyInherited) {
         return $properties;
     }
     $this->model->setProperties($properties);
     return $properties;
 }
开发者ID:nblackman,项目名称:pimcore,代码行数:53,代码来源:Resource.php


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