當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Service::getType方法代碼示例

本文整理匯總了PHP中Pimcore\Model\Element\Service::getType方法的典型用法代碼示例。如果您正苦於以下問題:PHP Service::getType方法的具體用法?PHP Service::getType怎麽用?PHP Service::getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pimcore\Model\Element\Service的用法示例。


在下文中一共展示了Service::getType方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: extractRelations

 public function extractRelations($element, $apiElementKeys, $recursive, $includeRelations)
 {
     $foundRelations = [];
     if ($includeRelations) {
         $dependency = $element->getDependencies();
         if ($dependency) {
             foreach ($dependency->getRequires() as $r) {
                 if ($e = Element\Service::getDependedElement($r)) {
                     if ($element->getId() != $e->getId() and !in_array(Element\Service::getElementType($e) . "_" . $e->getId(), $apiElementKeys)) {
                         $foundRelations[Element\Service::getElementType($e) . "_" . $e->getId()] = ["elementType" => Element\Service::getType($e), "element" => $e->getId(), "recursive" => false];
                     }
                 }
             }
         }
     }
     $childs = $element->getChilds();
     if ($recursive and $childs) {
         foreach ($childs as $child) {
             if (!in_array(Element\Service::getType($child) . "_" . $child->getId(), $apiElementKeys)) {
                 $foundRelations[Element\Service::getType($child) . "_" . $child->getId()] = ["elementType" => Element\Service::getType($child), "element" => $child->getId(), "recursive" => $recursive];
             }
         }
     }
     return $foundRelations;
 }
開發者ID:solverat,項目名稱:pimcore,代碼行數:25,代碼來源:Service.php

示例2: __construct

 /**
  * @param $webResource
  */
 public function __construct($webResource)
 {
     $this->id = $webResource->getId();
     if ($webResource instanceof Element\ElementInterface) {
         $this->type = Element\Service::getType($webResource);
     } else {
         $this->type = "unknown";
     }
 }
開發者ID:Gerhard13,項目名稱:pimcore,代碼行數:12,代碼來源:Id.php

示例3: getForWebserviceExport

 /**
  * converts data to be exposed via webservices
  * @param string $object
  * @return mixed
  */
 public function getForWebserviceExport($object)
 {
     $data = $this->getDataFromObjectParam($object);
     if ($data instanceof Element\ElementInterface) {
         return array("type" => Element\Service::getType($data), "subtype" => $data->getType(), "id" => $data->getId());
     } else {
         return null;
     }
 }
開發者ID:sfie,項目名稱:pimcore,代碼行數:14,代碼來源:Href.php

示例4: setElement

 /**
  * @param ElementInterface $element
  * @return $this
  */
 public function setElement(ElementInterface $element)
 {
     $this->setCid($element->getId());
     $this->setCtype(Service::getType($element));
     return $this;
 }
開發者ID:rolandstoll,項目名稱:pimcore,代碼行數:10,代碼來源:Note.php

示例5: marshal

 /** Encode value for packing it into a single column.
  * @param mixed $value
  * @param Model\Object\AbstractObject $object
  * @param mixed $params
  * @return mixed
  */
 public function marshal($value, $object = null, $params = [])
 {
     if (is_array($value)) {
         $result = [];
         foreach ($value as $element) {
             $type = Element\Service::getType($element);
             $id = $element->getId();
             $result[] = ["type" => $type, "id" => $id];
         }
         return $result;
     }
     return null;
 }
開發者ID:pimcore,項目名稱:pimcore,代碼行數:19,代碼來源:Objects.php

示例6: getObjectType

 /**
  * get correct type of object as string
  * @param mixed $data
  * @return void
  */
 public function getObjectType($object = null)
 {
     $this->load();
     if (!$object) {
         $object = $this->o;
     }
     if ($object instanceof Element\ElementInterface) {
         return Element\Service::getType($object);
     } else {
         return false;
     }
 }
開發者ID:sfie,項目名稱:pimcore,代碼行數:17,代碼來源:Renderlet.php

示例7: marshal

 /** Encode value for packing it into a single column.
  * @param mixed $value
  * @param Model\Object\AbstractObject $object
  * @param mixed $params
  * @return mixed
  */
 public function marshal($value, $object = null, $params = [])
 {
     if ($value instanceof Object\Data\Video) {
         $result = [];
         $result["type"] = $value->getType();
         if ($value->getTitle()) {
             $result["title"] = $value->getTitle();
         }
         if ($value->getDescription()) {
             $result["description"] = $value->getDescription();
         }
         $poster = $value->getPoster();
         if ($poster) {
             $result["poster"] = ["type" => Model\Element\Service::getType($poster), "id" => $poster->getId()];
         }
         $data = $value->getData();
         if ($data && $value->getType() == "asset") {
             $result["data"] = ["type" => Model\Element\Service::getType($data), "id" => $data->getId()];
         } else {
             $result["data"] = $data;
         }
         return $result;
     }
     return null;
 }
開發者ID:pimcore,項目名稱:pimcore,代碼行數:31,代碼來源:Video.php

示例8: unlockPropagate

 /**
  *
  */
 public function unlockPropagate()
 {
     $type = Service::getType($this);
     $ids = $this->getDao()->unlockPropagate();
     // invalidate cache items
     foreach ($ids as $id) {
         $element = Service::getElementById($type, $id);
         if ($element) {
             $element->clearDependentCache();
         }
     }
 }
開發者ID:ChristophWurst,項目名稱:pimcore,代碼行數:15,代碼來源:AbstractElement.php

示例9: getForWebserviceExport

 /**
  * converts data to be exposed via webservices
  * @param string $object
  * @return mixed
  */
 public function getForWebserviceExport($object)
 {
     $data = $this->getDataFromObjectParam($object);
     if (is_array($data)) {
         $items = array();
         foreach ($data as $eo) {
             if ($eo instanceof Element\ElementInterface) {
                 $items[] = array("type" => Element\Service::getType($eo), "subtype" => $eo->getType(), "id" => $eo->getId());
             }
         }
         return $items;
     } else {
         return null;
     }
 }
開發者ID:emanuel-london,項目名稱:pimcore,代碼行數:20,代碼來源:Multihref.php

示例10: marshal

 /** Encode value for packing it into a single column.
  * @param mixed $value
  * @param Model\Object\AbstractObject $object
  * @param mixed $params
  * @return mixed
  */
 public function marshal($value, $object = null, $params = [])
 {
     if ($value) {
         $type = Element\Service::getType($value);
         $id = $value->getId();
         return ["type" => $type, "id" => $id];
     }
 }
開發者ID:pimcore,項目名稱:pimcore,代碼行數:14,代碼來源:Href.php

示例11: create

 /**
  * @throws \Exception
  * @param  $rootElement
  * @param  $apiKey
  * @param  $path
  * @param  $apiElement
  * @param  bool $overwrite
  * @param  $elementCounter
  * @return Element\ElementInterface
  */
 public function create($rootElement, $apiKey, $path, $apiElement, $overwrite, $elementCounter)
 {
     //correct relative path
     if (strpos($path, "/") !== 0) {
         $path = $rootElement->getFullPath() . "/" . $path;
     }
     $type = $apiElement->type;
     if ($apiElement instanceof Webservice\Data\Asset) {
         $className = "\\Pimcore\\Model\\Asset\\" . ucfirst($type);
         $parentClassName = "\\Pimcore\\Model\\Asset";
         $maintype = "asset";
         $fullPath = $path . $apiElement->filename;
     } else {
         if ($apiElement instanceof Webservice\Data\Object) {
             $maintype = "object";
             if ($type == "object") {
                 $className = "\\Pimcore\\Model\\Object\\" . ucfirst($apiElement->className);
                 if (!Tool::classExists($className)) {
                     throw new \Exception("Unknown class [ " . $className . " ]");
                 }
             } else {
                 $className = "\\Pimcore\\Model\\Object\\" . ucfirst($type);
             }
             $parentClassName = "\\Pimcore\\Model\\Object";
             $fullPath = $path . $apiElement->key;
         } else {
             if ($apiElement instanceof Webservice\Data\Document) {
                 $maintype = "document";
                 $className = "\\Pimcore\\Model\\Document\\" . ucfirst($type);
                 $parentClassName = "\\Pimcore\\Model\\Document";
                 $fullPath = $path . $apiElement->key;
             } else {
                 throw new \Exception("Unknown import element");
             }
         }
     }
     $existingElement = $className::getByPath($fullPath);
     if ($overwrite && $existingElement) {
         $apiElement->parentId = $existingElement->getParentId();
         return $existingElement;
     }
     $element = new $className();
     $element->setId(null);
     $element->setCreationDate(time());
     if ($element instanceof Asset) {
         $element->setFilename($apiElement->filename);
         $element->setData(base64_decode($apiElement->data));
     } else {
         if ($element instanceof Object\Concrete) {
             $element->setKey($apiElement->key);
             $element->setClassName($apiElement->className);
             $class = Object\ClassDefinition::getByName($apiElement->className);
             if (!$class instanceof Object\ClassDefinition) {
                 throw new \Exception("Unknown object class [ " . $apiElement->className . " ] ");
             }
             $element->setClassId($class->getId());
         } else {
             $element->setKey($apiElement->key);
         }
     }
     $this->setModificationParams($element, true);
     $key = $element->getKey();
     if (empty($key) and $apiElement->id == 1) {
         if ($element instanceof Asset) {
             $element->setFilename("home_" . uniqid());
         } else {
             $element->setKey("home_" . uniqid());
         }
     } else {
         if (empty($key)) {
             throw new \Exception("Cannot create element without key ");
         }
     }
     $parent = $parentClassName::getByPath($path);
     if (Element\Service::getType($rootElement) == $maintype and $parent) {
         $element->setParentId($parent->getId());
         $apiElement->parentId = $parent->getId();
         $existingElement = $parentClassName::getByPath($parent->getFullPath() . "/" . $element->getKey());
         if ($existingElement) {
             //set dummy key to avoid duplicate paths
             if ($element instanceof Asset) {
                 $element->setFilename(str_replace("/", "_", $apiElement->path) . uniqid() . "_" . $elementCounter . "_" . $element->getFilename());
             } else {
                 $element->setKey(str_replace("/", "_", $apiElement->path) . uniqid() . "_" . $elementCounter . "_" . $element->getKey());
             }
         }
     } else {
         if (Element\Service::getType($rootElement) != $maintype) {
             //this is a related element - try to import it to it's original path or set the parent to home folder
             $potentialParent = $parentClassName::getByPath($path);
//.........這裏部分代碼省略.........
開發者ID:ChristophWurst,項目名稱:pimcore,代碼行數:101,代碼來源:Service.php

示例12: marshal

 /** Encode value for packing it into a single column.
  * @param mixed $value
  * @param Model\Object\AbstractObject $object
  * @param mixed $params
  * @return mixed
  */
 public function marshal($value, $object = null, $params = [])
 {
     if ($value instanceof Object\Data\Hotspotimage) {
         $result = [];
         $result["hotspots"] = $value->getHotspots();
         $result["marker"] = $value->getMarker();
         $result["crop"] = $value->getCrop();
         $image = $value->getImage();
         if ($image) {
             $type = Element\Service::getType($image);
             $id = $image->getId();
             $result["image"] = ["type" => $type, "id" => $id];
         }
         return $result;
     }
     return null;
 }
開發者ID:pimcore,項目名稱:pimcore,代碼行數:23,代碼來源:Hotspotimage.php

示例13: marshal

 /** Encode value for packing it into a single column.
  * @param mixed $value
  * @param Model\Object\AbstractObject $object
  * @param mixed $params
  * @return mixed
  */
 public function marshal($value, $object = null, $params = [])
 {
     if (is_array($value)) {
         $result = [];
         /** @var  $elementMetadata Object\Data\ElementMetadata */
         foreach ($value as $elementMetadata) {
             $element = $elementMetadata->getElement();
             $type = Element\Service::getType($element);
             $id = $element->getId();
             $result[] = ["element" => ["type" => $type, "id" => $id], "fieldname" => $elementMetadata->getFieldname(), "columns" => $elementMetadata->getColumns(), "data" => $elementMetadata->data];
         }
         return $result;
     }
     return null;
 }
開發者ID:pimcore,項目名稱:pimcore,代碼行數:21,代碼來源:MultihrefMetadata.php

示例14: getForWebserviceExport

 /**
  * @param Object\AbstractObject $object
  * @return array|mixed|null
  */
 public function getForWebserviceExport($object)
 {
     $data = $this->getDataFromObjectParam($object);
     if (is_array($data)) {
         $items = array();
         foreach ($data as $metaObject) {
             $eo = $metaObject->getElement();
             if ($eo instanceof Element\ElementInterface) {
                 $item = array();
                 $item["type"] = Element\Service::getType($eo);
                 $item["id"] = $eo->getId();
                 foreach ($this->getColumns() as $c) {
                     $getter = "get" . ucfirst($c['key']);
                     $item[$c['key']] = $metaObject->{$getter}();
                 }
                 $items[] = $item;
             }
         }
         return $items;
     } else {
         return null;
     }
 }
開發者ID:sfie,項目名稱:pimcore,代碼行數:27,代碼來源:MultihrefMetadata.php


注:本文中的Pimcore\Model\Element\Service::getType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。