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


PHP Service::getElementType方法代碼示例

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


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

示例1: extractRelations

 public function extractRelations($element, $apiElementKeys, $recursive, $includeRelations)
 {
     $foundRelations = array();
     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()] = array("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()] = array("elementType" => Element\Service::getType($child), "element" => $child->getId(), "recursive" => $recursive);
             }
         }
     }
     return $foundRelations;
 }
開發者ID:ChristophWurst,項目名稱:pimcore,代碼行數:25,代碼來源:Service.php

示例2: getElementWorkflowConfig

 /**
  * gets workflow config for element. always returns first valid workflow config
  *
  * @param Asset|Document|ConcreteObject $element
  * @return array
  */
 public static function getElementWorkflowConfig(AbstractElement $element)
 {
     $config = self::getWorkflowManagementConfig();
     if (!is_array($config)) {
         return null;
     }
     $elementType = Service::getElementType($element);
     $elementSubType = $element->getType();
     foreach ($config['workflows'] as $workflow) {
         //workflow is not enabled, continue with next
         if (isset($workflow['enabled']) && !$workflow['enabled']) {
             continue;
         }
         if (isset($workflow['workflowSubject']) && in_array($elementType, $workflow['workflowSubject']['types'])) {
             switch ($elementType) {
                 case 'asset':
                     if (isset($workflow['workflowSubject']['assetTypes']) && is_array($workflow['workflowSubject']['assetTypes'])) {
                         if (in_array($elementSubType, $workflow['workflowSubject']['assetTypes'])) {
                             return $workflow;
                         }
                     } else {
                         \Logger::warning('WorkflowManagement::getClassWorkflowConfig workflow does not feature a valid array of available asset types');
                     }
                     break;
                 case 'document':
                     if (isset($workflow['workflowSubject']['documentTypes']) && is_array($workflow['workflowSubject']['documentTypes'])) {
                         if (in_array($elementSubType, $workflow['workflowSubject']['documentTypes'])) {
                             return $workflow;
                         }
                     } else {
                         \Logger::warning('WorkflowManagement::getClassWorkflowConfig workflow does not feature a valid array of available document types');
                     }
                     break;
                 case 'object':
                     if ($element instanceof ConcreteObject) {
                         if (isset($workflow['workflowSubject']['classes']) && is_array($workflow['workflowSubject']['classes'])) {
                             $classId = $element->getClassId();
                             if (in_array($classId, $workflow['workflowSubject']['classes'])) {
                                 return $workflow;
                             }
                         } else {
                             \Logger::warning('WorkflowManagement::getClassWorkflowConfig workflow does not feature a valid array of available class ID\'s');
                         }
                     }
                     break;
                 default:
                     //unknown element type, return null
                     return null;
             }
         }
     }
     return null;
 }
開發者ID:solverat,項目名稱:pimcore,代碼行數:59,代碼來源:Config.php

示例3: interpret

 public static function interpret($value, $config = null)
 {
     $result = array();
     if (is_array($value)) {
         foreach ($value as $v) {
             $result[] = array("dest" => $v->getId(), "type" => \Pimcore\Model\Element\Service::getElementType($v));
         }
     } else {
         if ($value instanceof \Pimcore\Model\Element\AbstractElement) {
             $result[] = array("dest" => $value->getId(), "type" => \Pimcore\Model\Element\Service::getElementType($value));
         }
     }
     return $result;
 }
開發者ID:ascertain,項目名稱:NGshop,代碼行數:14,代碼來源:DefaultRelations.php

示例4: cleanAllForElement

 /**
  * Clear all relations in the database
  * @param Element\ElementInterface $element
  */
 public function cleanAllForElement($element)
 {
     try {
         $id = $element->getId();
         $type = Element\Service::getElementType($element);
         //schedule for sanity check
         $data = $this->db->fetchAll("SELECT * FROM dependencies WHERE targetid = ? AND targettype = ?", array($id, $type));
         if (is_array($data)) {
             foreach ($data as $row) {
                 $sanityCheck = new Element\Sanitycheck();
                 $sanityCheck->setId($row['sourceid']);
                 $sanityCheck->setType($row['sourcetype']);
                 $sanityCheck->save();
             }
         }
         $this->db->delete("dependencies", $this->db->quoteInto("sourceid = ?", $id) . " AND " . $this->db->quoteInto("sourcetype = ?", $type));
         $this->db->delete("dependencies", $this->db->quoteInto("targetid = ?", $id) . " AND " . $this->db->quoteInto("targettype = ?", $type));
     } catch (\Exception $e) {
         \Logger::error($e);
     }
 }
開發者ID:Gerhard13,項目名稱:pimcore,代碼行數:25,代碼來源:Resource.php

示例5: resolveDependencies

 /**
  * @param $data
  * @return array
  */
 public function resolveDependencies($data)
 {
     $dependencies = [];
     if (is_array($data) && count($data) > 0) {
         foreach ($data as $e) {
             if ($e instanceof Element\ElementInterface) {
                 $elementType = Element\Service::getElementType($e);
                 $dependencies[$elementType . "_" . $e->getId()] = ["id" => $e->getId(), "type" => $elementType];
             }
         }
     }
     return $dependencies;
 }
開發者ID:pimcore,項目名稱:pimcore,代碼行數:17,代碼來源:Multihref.php

示例6: getStorageFileBinary

 /**
  * @param $element
  * @return string
  */
 public function getStorageFileBinary($element)
 {
     return PIMCORE_RECYCLEBIN_DIRECTORY . "/" . $this->getId() . "_" . Element\Service::getElementType($element) . "-" . $element->getId() . ".bin";
 }
開發者ID:rolandstoll,項目名稱:pimcore,代碼行數:8,代碼來源:Item.php

示例7: resolveDependencies

 /**
  * @return array
  */
 public function resolveDependencies()
 {
     $dependencies = [];
     if ($this->getData() instanceof ElementInterface) {
         $elementType = Element\Service::getElementType($this->getData());
         $key = $elementType . "_" . $this->getData()->getId();
         $dependencies[$key] = ["id" => $this->getData()->getId(), "type" => $elementType];
     }
     return $dependencies;
 }
開發者ID:solverat,項目名稱:pimcore,代碼行數:13,代碼來源:Property.php

示例8: save

 /**
  * @param $object
  * @param string $ownertype
  * @param $ownername
  * @param $position
  */
 public function save($object, $ownertype = "object", $ownername, $position)
 {
     $element = $this->getElement();
     $type = Model\Element\Service::getElementType($element);
     $this->getDao()->save($object, $ownertype, $ownername, $position, $type);
 }
開發者ID:ChristophWurst,項目名稱:pimcore,代碼行數:12,代碼來源:ElementMetadata.php

示例9: rewriteIds

 /**
  * Rewrites id from source to target, $idMapping contains
  * array(
  *  "document" => array(
  *      SOURCE_ID => TARGET_ID,
  *      SOURCE_ID => TARGET_ID
  *  ),
  *  "object" => array(...),
  *  "asset" => array(...)
  * )
  * @param mixed $object
  * @param array $idMapping
  * @param array $params
  * @return Element\ElementInterface
  */
 public function rewriteIds($object, $idMapping, $params = array())
 {
     $data = $this->getDataFromObjectParam($object, $params);
     if (is_array($data)) {
         foreach ($data as &$metaObject) {
             $eo = $metaObject->getObject();
             if ($eo instanceof Element\ElementInterface) {
                 $id = $eo->getId();
                 $type = Element\Service::getElementType($eo);
                 if (array_key_exists($type, $idMapping) && array_key_exists($id, $idMapping[$type])) {
                     $newElement = Element\Service::getElementById($type, $idMapping[$type][$id]);
                     $metaObject->setObject($newElement);
                 }
             }
         }
     }
     return $data;
 }
開發者ID:yonetici,項目名稱:pimcore-coreshop-demo,代碼行數:33,代碼來源:ObjectsMetadata.php

示例10: setItem

 /**
  * @param $item
  * @return $this
  */
 public function setItem($item)
 {
     $this->setItemId($item->getId());
     $this->setType(Model\Element\Service::getElementType($item));
     $this->item = $item;
     return $this;
 }
開發者ID:Gerhard13,項目名稱:pimcore,代碼行數:11,代碼來源:UUID.php

示例11: addAction

 public function addAction()
 {
     $element = Element\Service::getElementById($this->getParam("type"), $this->getParam("id"));
     if ($element) {
         $type = Element\Service::getElementType($element);
         $listClass = "\\Pimcore\\Model\\" . ucfirst($type) . "\\Listing";
         $list = new $listClass();
         $list->setCondition(($type == "object" ? "o_" : "") . "path LIKE '" . $element->getFullPath() . "/%'");
         $children = $list->getTotalCount();
         if ($children <= 100) {
             Recyclebin\Item::create($element, $this->getUser());
         }
         $this->_helper->json(array("success" => true));
     } else {
         $this->_helper->json(array("success" => false));
     }
 }
開發者ID:emanuel-london,項目名稱:pimcore,代碼行數:17,代碼來源:RecyclebinController.php

示例12: setData

 /**
  * @param mixed $data
  * @return static
  */
 public function setData($data)
 {
     if ($data instanceof ElementInterface) {
         $this->setType(Service::getElementType($data));
         $data = $data->getId();
     }
     $this->data = $data;
     return $this;
 }
開發者ID:emanuel-london,項目名稱:pimcore,代碼行數:13,代碼來源:Property.php

示例13: resolveDependencies

 /**
  * @return array
  */
 public function resolveDependencies()
 {
     $this->setElements();
     $dependencies = [];
     if (is_array($this->elements) && count($this->elements) > 0) {
         foreach ($this->elements as $element) {
             if ($element instanceof Element\ElementInterface) {
                 $elementType = Element\Service::getElementType($element);
                 $key = $elementType . "_" . $element->getId();
                 $dependencies[$key] = ["id" => $element->getId(), "type" => $elementType];
             }
         }
     }
     return $dependencies;
 }
開發者ID:solverat,項目名稱:pimcore,代碼行數:18,代碼來源:Multihref.php

示例14: getWorkflowStateForElement

 /**
  * @return null|WorkflowState
  */
 public function getWorkflowStateForElement()
 {
     $elementType = Service::getElementType($this->element);
     $workflowState = WorkflowState::getByPrimary($this->element->getId(), $elementType, $this->workflow->getId());
     if (empty($workflowState)) {
         $workflowState = new WorkflowState();
         $workflowState->setCid($this->element->getId());
         $workflowState->setCtype($elementType);
         $workflowState->setWorkflowId($this->workflow->getId());
     }
     return $workflowState;
 }
開發者ID:pimcore,項目名稱:pimcore,代碼行數:15,代碼來源:Manager.php

示例15: maintenanceCleanUp

 /**
  *
  */
 public function maintenanceCleanUp()
 {
     $conf["document"] = Config::getSystemConfig()->documents->versions;
     $conf["asset"] = Config::getSystemConfig()->assets->versions;
     $conf["object"] = Config::getSystemConfig()->objects->versions;
     $elementTypes = array();
     foreach ($conf as $elementType => $tConf) {
         if (intval($tConf->days) > 0) {
             $versioningType = "days";
             $value = intval($tConf->days);
         } else {
             $versioningType = "steps";
             $value = intval($tConf->steps);
         }
         if ($versioningType) {
             $elementTypes[] = array("elementType" => $elementType, $versioningType => $value);
         }
     }
     $ignoredIds = array();
     while (true) {
         $versions = $this->getDao()->maintenanceGetOutdatedVersions($elementTypes, $ignoredIds);
         if (count($versions) == 0) {
             break;
         }
         $counter = 0;
         \Logger::debug("versions to check: " . count($versions));
         if (is_array($versions) && !empty($versions)) {
             $totalCount = count($versions);
             foreach ($versions as $index => $id) {
                 try {
                     $version = Version::getById($id);
                 } catch (\Exception $e) {
                     $ignoredIds[] = $id;
                     \Logger::debug("Version with " . $id . " not found\n");
                     continue;
                 }
                 $counter++;
                 // do not delete public versions
                 if ($version->getPublic()) {
                     $ignoredIds[] = $version->getId();
                     continue;
                 }
                 if ($version->getCtype() == "document") {
                     $element = Document::getById($version->getCid());
                 } elseif ($version->getCtype() == "asset") {
                     $element = Asset::getById($version->getCid());
                 } elseif ($version->getCtype() == "object") {
                     $element = Object::getById($version->getCid());
                 }
                 if ($element instanceof ElementInterface) {
                     \Logger::debug("currently checking Element-ID: " . $element->getId() . " Element-Type: " . Element\Service::getElementType($element) . " in cycle: " . $counter . "/" . $totalCount);
                     if ($element->getModificationDate() >= $version->getDate()) {
                         // delete version if it is outdated
                         \Logger::debug("delete version: " . $version->getId() . " because it is outdated");
                         $version->delete();
                     } else {
                         $ignoredIds[] = $version->getId();
                         \Logger::debug("do not delete version (" . $version->getId() . ") because version's date is newer than the actual modification date of the element. Element-ID: " . $element->getId() . " Element-Type: " . Element\Service::getElementType($element));
                     }
                 } else {
                     // delete version if the corresponding element doesn't exist anymore
                     \Logger::debug("delete version (" . $version->getId() . ") because the corresponding element doesn't exist anymore");
                     $version->delete();
                 }
                 // call the garbage collector if memory consumption is > 100MB
                 if (memory_get_usage() > 100000000) {
                     \Pimcore::collectGarbage();
                 }
             }
         }
     }
 }
開發者ID:emanuel-london,項目名稱:pimcore,代碼行數:75,代碼來源:Version.php


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