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


PHP Service::pathExists方法代码示例

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


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

示例1: importDocuments

 public function importDocuments()
 {
     $file = sprintf('%s/documents.json', $this->baseDir);
     $docs = new \Zend_Config_Json($file);
     foreach ($docs as $def) {
         $def = $def->toArray();
         $parent = Document::getByPath($def['parent']);
         unset($def['parent']);
         if (!$parent) {
             $parent = Document::getById(1);
         }
         $path = $parent->getFullPath() . '/' . $def['key'];
         if (Document\Service::pathExists($path)) {
             $doc = Document::getByPath($path);
         } else {
             $docClass = '\\Pimcore\\Model\\Document\\' . ucfirst($def['type']);
             /** @var Document $doc */
             $doc = $docClass::create($parent->getId(), $def, false);
             $doc->setUserOwner(self::getUser()->getId());
             $doc->setUserModification(self::getUser()->getId());
         }
         $doc->setValues($def);
         $doc->setPublished(true);
         $doc->save();
     }
 }
开发者ID:Pegasuz,项目名称:member,代码行数:26,代码来源:Installer.php

示例2: pathExists

 /**
  * @static
  * @param $type
  * @param $path
  * @return bool
  */
 public static function pathExists($path, $type = null)
 {
     if ($type == "asset") {
         return Asset\Service::pathExists($path);
     } else {
         if ($type == "document") {
             return Document\Service::pathExists($path);
         } else {
             if ($type == "object") {
                 return Object\Service::pathExists($path);
             }
         }
     }
     return;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:21,代码来源:Service.php

示例3: correctPath

 /**
  * @throws \Exception
  */
 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 = Document::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("page");
         }
     }
     if (Document\Service::pathExists($this->getRealFullPath())) {
         $duplicate = Document::getByPath($this->getRealFullPath());
         if ($duplicate instanceof Document and $duplicate->getId() != $this->getId()) {
             throw new \Exception("Duplicate full path [ " . $this->getRealFullPath() . " ] - cannot save document");
         }
     }
     if (strlen($this->getRealFullPath()) > 765) {
         throw new \Exception("Full path is limited to 765 characters, reduce the length of your parent's path");
     }
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:44,代码来源:Document.php

示例4: addAction

 public function addAction()
 {
     $success = false;
     $errorMessage = "";
     // check for permission
     $parentDocument = Document::getById(intval($this->getParam("parentId")));
     if ($parentDocument->isAllowed("create")) {
         $intendedPath = $parentDocument->getFullPath() . "/" . $this->getParam("key");
         if (!Document\Service::pathExists($intendedPath)) {
             $createValues = array("userOwner" => $this->getUser()->getId(), "userModification" => $this->getUser()->getId(), "published" => false);
             $createValues["key"] = $this->getParam("key");
             // check for a docType
             $docType = Document\DocType::getById(intval($this->getParam("docTypeId")));
             if ($docType) {
                 $createValues["template"] = $docType->getTemplate();
                 $createValues["controller"] = $docType->getController();
                 $createValues["action"] = $docType->getAction();
                 $createValues["module"] = $docType->getModule();
             } else {
                 if ($this->getParam("type") == "page" || $this->getParam("type") == "snippet" || $this->getParam("type") == "email") {
                     $createValues["controller"] = Config::getSystemConfig()->documents->default_controller;
                     $createValues["action"] = Config::getSystemConfig()->documents->default_action;
                 }
             }
             switch ($this->getParam("type")) {
                 case "page":
                     $document = Document\Page::create($this->getParam("parentId"), $createValues, false);
                     $document->setTitle($this->getParam('title', null));
                     $document->setProperty("navigation_name", "text", $this->getParam('name', null), false);
                     $document->save();
                     $success = true;
                     break;
                 case "snippet":
                     $document = Document\Snippet::create($this->getParam("parentId"), $createValues);
                     $success = true;
                     break;
                 case "email":
                     //ckogler
                     $document = Document\Email::create($this->getParam("parentId"), $createValues);
                     $success = true;
                     break;
                 case "link":
                     $document = Document\Link::create($this->getParam("parentId"), $createValues);
                     $success = true;
                     break;
                 case "hardlink":
                     $document = Document\Hardlink::create($this->getParam("parentId"), $createValues);
                     $success = true;
                     break;
                 case "folder":
                     $document = Document\Folder::create($this->getParam("parentId"), $createValues);
                     $document->setPublished(true);
                     try {
                         $document->save();
                         $success = true;
                     } catch (\Exception $e) {
                         $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
                     }
                     break;
                 default:
                     $classname = "\\Pimcore\\Model\\Document\\" . ucfirst($this->getParam("type"));
                     // this is the fallback for custom document types using prefixes
                     // so we need to check if the class exists first
                     if (!\Pimcore\Tool::classExists($classname)) {
                         $oldStyleClass = "\\Document_" . ucfirst($this->getParam("type"));
                         if (\Pimcore\Tool::classExists($oldStyleClass)) {
                             $classname = $oldStyleClass;
                         }
                     }
                     if (Tool::classExists($classname)) {
                         $document = $classname::create($this->getParam("parentId"), $createValues);
                         try {
                             $document->save();
                             $success = true;
                         } catch (\Exception $e) {
                             $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
                         }
                         break;
                     } else {
                         \Logger::debug("Unknown document type, can't add [ " . $this->getParam("type") . " ] ");
                     }
                     break;
             }
         } else {
             $errorMessage = "prevented adding a document because document with same path+key [ {$intendedPath} ] already exists";
             \Logger::debug($errorMessage);
         }
     } else {
         $errorMessage = "prevented adding a document because of missing permissions";
         \Logger::debug($errorMessage);
     }
     if ($success) {
         $this->_helper->json(array("success" => $success, "id" => $document->getId(), "type" => $document->getType()));
     } else {
         $this->_helper->json(array("success" => $success, "message" => $errorMessage));
     }
 }
开发者ID:pawansgi92,项目名称:pimcore2,代码行数:97,代码来源:DocumentController.php


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