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


PHP AbstractObject::getByPath方法代碼示例

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


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

示例1: makeParticipation

 /**
  * @return AbstractObject|\Pimcore\Model\Object\Participation
  * @throws \Exception
  */
 public function makeParticipation()
 {
     $objectFolderPath = Plugin::getConfig()->get(Plugin::CONFIG_OBJECTFOLDERPATH);
     $objectFolder = AbstractObject::getByPath($objectFolderPath);
     if (!$objectFolder instanceof Folder) {
         throw new \Exception("Error: objectFolderPath [{$objectFolderPath}] " . "is not a valid object folder.");
     }
     // create basic object stuff
     $key = $this->createParticipationKey();
     $participation = new Participation();
     $participation->setKey($key);
     $participation->setParent($objectFolder);
     $participation->setPublished(true);
     $participation->setCreationDate(time());
     $participation->SetIpCreated($_SERVER['REMOTE_ADDR']);
     $confirmation = $this->makeConfirmation();
     $participation->setConfirmationCode($confirmation->createCode());
     return $participation;
 }
開發者ID:basilicom,項目名稱:pimcore-plugin-participation,代碼行數:23,代碼來源:Manager.php

示例2: getSaveCopyName

 /**
  * @param $element
  * @param $key
  * @param $path
  * @return string
  */
 protected function getSaveCopyName($element, $key, $path)
 {
     if ($element instanceof Object\AbstractObject) {
         $equal = Object\AbstractObject::getByPath($path . "/" . $key);
     } else {
         if ($element instanceof Document) {
             $equal = Document::getByPath($path . "/" . $key);
         } else {
             if ($element instanceof Asset) {
                 $equal = Asset::getByPath($path . "/" . $key);
             }
         }
     }
     if ($equal) {
         $key .= "_WScopy";
         return $this->getSaveCopyName($element, $key, $path);
     }
     return $key;
 }
開發者ID:pawansgi92,項目名稱:pimcore2,代碼行數:25,代碼來源:Service.php

示例3: correctPath

 public function correctPath()
 {
     // set path
     if ($this->getId() != 1) {
         // not for the root node
         if ($this->getParentId() == $this->getId()) {
             throw new \Exception("ParentID and ID is identical, an element can't be the parent of itself.");
         }
         $parent = AbstractObject::getById($this->getParentId());
         if ($parent) {
             // use the parent's path from the database here (getCurrentFullPath), to ensure the path really exists and does not rely on the path
             // that is currently in the parent object (in memory), because this might have changed but wasn't not saved
             $this->setPath(str_replace("//", "/", $parent->getCurrentFullPath() . "/"));
         } else {
             // parent document doesn't exist anymore, set the parent to to root
             $this->setParentId(1);
             $this->setPath("/");
         }
         if (strlen($this->getKey()) < 1) {
             $this->setKey("---no-valid-key---" . $this->getId());
             throw new \Exception("Document requires key, generated key automatically");
         }
     } else {
         if ($this->getId() == 1) {
             // some data in root node should always be the same
             $this->setParentId(0);
             $this->setPath("/");
             $this->setKey("");
             $this->setType("folder");
         }
     }
     if (Service::pathExists($this->getFullPath())) {
         $duplicate = AbstractObject::getByPath($this->getFullPath());
         if ($duplicate instanceof self and $duplicate->getId() != $this->getId()) {
             throw new \Exception("Duplicate full path [ " . $this->getFullPath() . " ] - cannot save object");
         }
     }
     if (strlen($this->getFullPath()) > 765) {
         throw new \Exception("Full path is limited to 765 characters, reduce the length of your parent's path");
     }
 }
開發者ID:rolandstoll,項目名稱:pimcore,代碼行數:41,代碼來源:AbstractObject.php

示例4: createObjects

 private static function createObjects()
 {
     try {
         $objectFolder = AbstractObject::getByPath(Plugin::CONFIG_OBJECTFOLDERPATH_DEFAULT);
         if (!is_object($objectFolder)) {
             $objectFolder = new Folder();
             $objectFolder->setKey(basename(Plugin::CONFIG_OBJECTFOLDERPATH_DEFAULT));
             $objectFolder->setParent(AbstractObject::getByPath(dirname(Plugin::CONFIG_OBJECTFOLDERPATH_DEFAULT)));
             $objectFolder->save();
         }
         if (!$objectFolder instanceof Folder) {
             throw new \Exception('Can not use object path [' . Plugin::CONFIG_OBJECTFOLDERPATH_DEFAULT . '] as default participation folder.');
         }
     } catch (\Exception $exception) {
         throw new \Exception('Unable to create/use participation folder [' . Plugin::CONFIG_OBJECTFOLDERPATH_DEFAULT . ']: ' . $exception->getMessage());
     }
 }
開發者ID:basilicom,項目名稱:pimcore-plugin-participation,代碼行數:17,代碼來源:Plugin.php


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