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


PHP Service::copyAsChild方法代码示例

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


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

示例1: copyAction

 public function copyAction()
 {
     $success = false;
     $sourceId = intval($this->getParam("sourceId"));
     $source = Document::getById($sourceId);
     $session = Session::get("pimcore_copy");
     $targetId = intval($this->getParam("targetId"));
     if ($this->getParam("targetParentId")) {
         $sourceParent = Document::getById($this->getParam("sourceParentId"));
         // this is because the key can get the prefix "_copy" if the target does already exists
         if ($session->{$this->getParam("transactionId")}["parentId"]) {
             $targetParent = Document::getById($session->{$this->getParam("transactionId")}["parentId"]);
         } else {
             $targetParent = Document::getById($this->getParam("targetParentId"));
         }
         $targetPath = preg_replace("@^" . $sourceParent->getFullPath() . "@", $targetParent . "/", $source->getPath());
         $target = Document::getByPath($targetPath);
     } else {
         $target = Document::getById($targetId);
     }
     if ($target instanceof Document) {
         if ($target->isAllowed("create")) {
             if ($source != null) {
                 if ($this->getParam("type") == "child") {
                     $enableInheritance = $this->getParam("enableInheritance") == "true" ? true : false;
                     $resetIndex = $this->getParam("resetIndex") == "true" ? true : false;
                     $newDocument = $this->_documentService->copyAsChild($target, $source, $enableInheritance, $resetIndex);
                     $session->{$this->getParam("transactionId")}["idMapping"][(int) $source->getId()] = (int) $newDocument->getId();
                     // this is because the key can get the prefix "_copy" if the target does already exists
                     if ($this->getParam("saveParentId")) {
                         $session->{$this->getParam("transactionId")}["parentId"] = $newDocument->getId();
                     }
                     Session::writeClose();
                 } else {
                     if ($this->getParam("type") == "replace") {
                         $this->_documentService->copyContents($target, $source);
                     }
                 }
                 $success = true;
             } else {
                 \Logger::error("prevended copy/paste because document with same path+key already exists in this location");
             }
         } else {
             \Logger::error("could not execute copy/paste because of missing permissions on target [ " . $targetId . " ]");
             $this->_helper->json(array("success" => false, "message" => "missing_permission"));
         }
     }
     $this->_helper->json(array("success" => $success));
 }
开发者ID:sfie,项目名称:pimcore,代码行数:49,代码来源:DocumentController.php


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