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


PHP Property::setType方法代码示例

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


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

示例1: addPropertiesToDocument

 protected function addPropertiesToDocument(Document $document)
 {
     // properties
     if ($this->_getParam("properties")) {
         $properties = array();
         // assign inherited properties
         foreach ($document->getProperties() as $p) {
             if ($p->isInherited()) {
                 $properties[$p->getName()] = $p;
             }
         }
         $propertiesData = Zend_Json::decode($this->_getParam("properties"));
         if (is_array($propertiesData)) {
             foreach ($propertiesData as $propertyName => $propertyData) {
                 $value = $propertyData["data"];
                 try {
                     $property = new Property();
                     $property->setType($propertyData["type"]);
                     $property->setName($propertyName);
                     $property->setCtype("document");
                     $property->setDataFromEditmode($value);
                     $property->setInheritable($propertyData["inheritable"]);
                     $properties[$propertyName] = $property;
                 } catch (Exception $e) {
                     Logger::warning("Can't add " . $propertyName . " to document " . $document->getFullPath());
                 }
             }
         }
         if ($document->isAllowed("properties")) {
             $document->setProperties($properties);
         }
     }
     // force loading of properties
     $document->getProperties();
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:35,代码来源:Document.php

示例2: parse

 public function parse($comment)
 {
     $lines = $this->getLines($comment);
     $lines = array_map(function ($line) {
         return $this->parseLine($line);
     }, $lines);
     $lines = array_filter($lines, function ($line) {
         return $line && $this->isVar($line);
     });
     $lines = array_map(function ($line) {
         return array_slice($line, 1);
     }, $lines);
     if (count($lines) > 0) {
         $property = new Property();
         foreach ($lines as $line) {
             if (count($line) >= 1) {
                 // @var {type} [...]
                 $property->setType($line[0]);
             }
         }
         return $property;
     }
     return false;
 }
开发者ID:rmasters,项目名称:reflection-casting,代码行数:24,代码来源:PropertyParser.php

示例3: saveAction

 public function saveAction()
 {
     $success = false;
     if ($this->_getParam("id")) {
         $asset = Asset::getById($this->_getParam("id"));
         if ($asset->isAllowed("publish")) {
             // properties
             if ($this->_getParam("properties")) {
                 $properties = array();
                 $propertiesData = Zend_Json::decode($this->_getParam("properties"));
                 if (is_array($propertiesData)) {
                     foreach ($propertiesData as $propertyName => $propertyData) {
                         $value = $propertyData["data"];
                         try {
                             $property = new Property();
                             $property->setType($propertyData["type"]);
                             $property->setName($propertyName);
                             $property->setCtype("asset");
                             $property->setDataFromEditmode($value);
                             $property->setInheritable($propertyData["inheritable"]);
                             $properties[$propertyName] = $property;
                         } catch (Exception $e) {
                             Logger::err("Can't add " . $propertyName . " to asset " . $asset->getFullPath());
                         }
                     }
                     $asset->setProperties($properties);
                 }
             }
             // scheduled tasks
             if ($this->_getParam("scheduler")) {
                 $tasks = array();
                 $tasksData = Zend_Json::decode($this->_getParam("scheduler"));
                 if (!empty($tasksData)) {
                     foreach ($tasksData as $taskData) {
                         $taskData["date"] = strtotime($taskData["date"] . " " . $taskData["time"]);
                         $task = new Schedule_Task($taskData);
                         $tasks[] = $task;
                     }
                 }
                 $asset->setScheduledTasks($tasks);
             }
             if ($this->_getParam("data")) {
                 $asset->setData($this->_getParam("data"));
             }
             $asset->setUserModification($this->getUser()->getId());
             try {
                 $asset->save();
                 $asset->getData();
                 $success = true;
             } catch (Exception $e) {
                 $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
             }
         } else {
             Logger::debug("prevented save asset because of missing permissions ");
         }
         $this->_helper->json(array("success" => $success));
     }
     $this->_helper->json(false);
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:59,代码来源:AssetController.php

示例4: 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

示例5: 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

示例6: assignPropertiesFromEditmode

 protected function assignPropertiesFromEditmode($object)
 {
     if ($this->_getParam("properties")) {
         $properties = array();
         // assign inherited properties
         foreach ($object->getProperties() as $p) {
             if ($p->isInherited()) {
                 $properties[$p->getName()] = $p;
             }
         }
         $propertiesData = Zend_Json::decode($this->_getParam("properties"));
         if (is_array($propertiesData)) {
             foreach ($propertiesData as $propertyName => $propertyData) {
                 $value = $propertyData["data"];
                 try {
                     $property = new Property();
                     $property->setType($propertyData["type"]);
                     $property->setName($propertyName);
                     $property->setCtype("object");
                     $property->setDataFromEditmode($value);
                     $property->setInheritable($propertyData["inheritable"]);
                     $properties[$propertyName] = $property;
                 } catch (Exception $e) {
                     Logger::err("Can't add " . $propertyName . " to object " . $object->getFullPath());
                 }
             }
         }
         $object->setProperties($properties);
     }
     return $object;
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:31,代码来源:ObjectController.php

示例7: getRandomProperties

 /**
  * @param  string $ctype
  *
  * @return array
  */
 protected function getRandomProperties($ctype)
 {
     $document = $this->createRandomDocument("snippet");
     $asset = $this->createRandomAssetImage();
     $object = $this->createRandomObject("unittest");
     $properties = array();
     // object property
     $property = new Property();
     $property->setType("object");
     $property->setName("object");
     $property->setCtype($ctype);
     $property->setDataFromEditmode($object->getFullPath());
     $property->setInheritable(true);
     $properties["object"] = $property;
     // document property
     $property = new Property();
     $property->setType("document");
     $property->setName("document");
     $property->setCtype($ctype);
     $property->setDataFromEditmode($document->getFullPath());
     $property->setInheritable(true);
     $properties["document"] = $property;
     // asset property
     $property = new Property();
     $property->setType("asset");
     $property->setName("asset");
     $property->setCtype($ctype);
     $property->setDataFromEditmode($asset->getFullPath());
     $property->setInheritable(true);
     $properties["asset"] = $property;
     // text property
     $property = new Property();
     $property->setType("text");
     $property->setName("text");
     $property->setCtype($ctype);
     $property->setDataFromEditmode("hallo property");
     $property->setInheritable(true);
     $properties["text"] = $property;
     // bool  property
     $property = new Property();
     $property->setType("bool");
     $property->setName("bool");
     $property->setCtype($ctype);
     $property->setDataFromEditmode(true);
     $property->setInheritable(true);
     $properties["bool"] = $property;
     // date  property
     $property = new Property();
     $property->setType("date");
     $property->setName("date");
     $property->setCtype($ctype);
     $property->setDataFromEditmode(new Zend_Date());
     $property->setInheritable(true);
     $properties["date"] = $property;
     return $properties;
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:61,代码来源:ElementCreateTest.php


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