copyAsChild() публичный Метод

public copyAsChild ( Asset $target, Asset $source ) : Asset
$target Pimcore\Model\Asset
$source Pimcore\Model\Asset
Результат Pimcore\Model\Asset copied asset
 public function copyAction()
 {
     $success = false;
     $sourceId = intval($this->getParam("sourceId"));
     $source = Asset::getById($sourceId);
     $session = Tool\Session::get("pimcore_copy");
     $targetId = intval($this->getParam("targetId"));
     if ($this->getParam("targetParentId")) {
         $sourceParent = Asset::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 = Asset::getById($session->{$this->getParam("transactionId")}["parentId"]);
         } else {
             $targetParent = Asset::getById($this->getParam("targetParentId"));
         }
         $targetPath = preg_replace("@^" . $sourceParent->getFullPath() . "@", $targetParent . "/", $source->getPath());
         $target = Asset::getByPath($targetPath);
     } else {
         $target = Asset::getById($targetId);
     }
     if ($target->isAllowed("create")) {
         $source = Asset::getById($sourceId);
         if ($source != null) {
             if ($this->getParam("type") == "child") {
                 $newAsset = $this->_assetService->copyAsChild($target, $source);
                 // 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"] = $newAsset->getId();
                 }
             } else {
                 if ($this->getParam("type") == "replace") {
                     $this->_assetService->copyContents($target, $source);
                 }
             }
             $success = true;
         } else {
             \Logger::debug("prevended copy/paste because asset 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("error" => false, "message" => "missing_permission"));
     }
     Tool\Session::writeClose();
     $this->_helper->json(array("success" => $success));
 }