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


PHP Asset::getByPath方法代码示例

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


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

示例1: getChild

 /**
  * @param string $name
  * @return DAV\INode|void
  * @throws DAV\Exception\NotFound
  */
 function getChild($name)
 {
     $nameParts = explode("/", $name);
     $name = File::getValidFilename($nameParts[count($nameParts) - 1]);
     //$name = implode("/",$nameParts);
     if (is_string($name)) {
         $parentPath = $this->asset->getFullPath();
         if ($parentPath == "/") {
             $parentPath = "";
         }
         if (!($asset = Asset::getByPath($parentPath . "/" . $name))) {
             throw new DAV\Exception\NotFound('File not found: ' . $name);
         }
     } else {
         if ($name instanceof Asset) {
             $asset = $name;
         }
     }
     if ($asset instanceof Asset) {
         if ($asset->getType() == "folder") {
             return new Asset\WebDAV\Folder($asset);
         } else {
             return new Asset\WebDAV\File($asset);
         }
     }
     throw new DAV\Exception\NotFound('File not found: ' . $name);
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:32,代码来源:Folder.php

示例2: setValuesToDocument

 protected function setValuesToDocument(Document\Link $link)
 {
     // data
     if ($this->getParam("data")) {
         $data = \Zend_Json::decode($this->getParam("data"));
         if (!empty($data["path"])) {
             if ($document = Document::getByPath($data["path"])) {
                 $data["linktype"] = "internal";
                 $data["internalType"] = "document";
                 $data["internal"] = $document->getId();
             } elseif ($asset = Asset::getByPath($data["path"])) {
                 $data["linktype"] = "internal";
                 $data["internalType"] = "asset";
                 $data["internal"] = $asset->getId();
             } else {
                 $data["linktype"] = "direct";
                 $data["direct"] = $data["path"];
             }
         } else {
             // clear content of link
             $data["linktype"] = "internal";
             $data["direct"] = "";
             $data["internalType"] = null;
             $data["internal"] = null;
         }
         unset($data["path"]);
         $link->setValues($data);
     }
     $this->addPropertiesToDocument($link);
 }
开发者ID:solverat,项目名称:pimcore,代码行数:30,代码来源:LinkController.php

示例3: move

 /**
  * Moves a file/directory
  *
  * @param string $sourcePath
  * @param string $destinationPath
  * @return void
  */
 public function move($sourcePath, $destinationPath)
 {
     $nameParts = explode("/", $sourcePath);
     $nameParts[count($nameParts) - 1] = File::getValidFilename($nameParts[count($nameParts) - 1]);
     $sourcePath = implode("/", $nameParts);
     $nameParts = explode("/", $destinationPath);
     $nameParts[count($nameParts) - 1] = File::getValidFilename($nameParts[count($nameParts) - 1]);
     $destinationPath = implode("/", $nameParts);
     try {
         if (dirname($sourcePath) == dirname($destinationPath)) {
             $asset = null;
             if ($asset = Asset::getByPath("/" . $destinationPath)) {
                 // If we got here, this means the destination exists, and needs to be overwritten
                 $sourceAsset = Asset::getByPath("/" . $sourcePath);
                 $asset->setData($sourceAsset->getData());
                 $sourceAsset->delete();
             }
             // see: Asset\WebDAV\File::delete() why this is necessary
             $log = Asset\WebDAV\Service::getDeleteLog();
             if (!$asset && array_key_exists("/" . $destinationPath, $log)) {
                 $asset = \Pimcore\Tool\Serialize::unserialize($log["/" . $destinationPath]["data"]);
                 if ($asset) {
                     $sourceAsset = Asset::getByPath("/" . $sourcePath);
                     $asset->setData($sourceAsset->getData());
                     $sourceAsset->delete();
                 }
             }
             if (!$asset) {
                 $asset = Asset::getByPath("/" . $sourcePath);
             }
             $asset->setFilename(basename($destinationPath));
         } else {
             $asset = Asset::getByPath("/" . $sourcePath);
             $parent = Asset::getByPath("/" . dirname($destinationPath));
             $asset->setPath($parent->getFullPath() . "/");
             $asset->setParentId($parent->getId());
         }
         $user = \Pimcore\Tool\Admin::getCurrentUser();
         $asset->setUserModification($user->getId());
         $asset->save();
     } catch (\Exception $e) {
         \Logger::error($e);
     }
 }
开发者ID:cannonerd,项目名称:pimcore,代码行数:51,代码来源:Tree.php

示例4: getDataFromEditmode

 /**
  * @see Model\Object\ClassDefinition\Data::getDataFromEditmode
  * @param integer $data
  * @param null|Model\Object\AbstractObject $object
  * @return Asset
  */
 public function getDataFromEditmode($data, $object = null)
 {
     $video = null;
     if ($data["type"] == "asset") {
         if ($asset = Asset::getByPath($data["data"])) {
             $data["data"] = $asset;
         } else {
             $data["data"] = null;
         }
     }
     if ($data["poster"]) {
         if ($poster = Asset::getByPath($data["poster"])) {
             $data["poster"] = $poster;
         } else {
             $data["poster"] = null;
         }
     }
     if (!empty($data["data"])) {
         $video = new Object\Data\Video();
         $video->setData($data["data"]);
         $video->setType($data["type"]);
         $video->setPoster($data["poster"]);
         $video->setTitle($data["title"]);
         $video->setDescription($data["description"]);
     }
     return $video;
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:33,代码来源:Video.php

示例5: getFromCsvImport

 /**
  * @param $importValue
  * @return mixed|null|Asset
  */
 public function getFromCsvImport($importValue)
 {
     $value = null;
     if ($el = Asset::getByPath($importValue)) {
         $value = $el;
     } else {
         $value = null;
     }
     return $value;
 }
开发者ID:ptaferner,项目名称:pimcore,代码行数:14,代码来源:Image.php

示例6: 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 = Asset::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, so delete this document
             //$this->delete();
             // parent document doesn't exist anymore, set the parent to to root
             $this->setParentId(1);
             $this->setPath("/");
         }
     } else {
         if ($this->getId() == 1) {
             // some data in root node should always be the same
             $this->setParentId(0);
             $this->setPath("/");
             $this->setFilename("");
             $this->setType("folder");
         }
     }
     // do not allow PHP and .htaccess files
     if (preg_match("@\\.ph(p[345]?|t|tml|ps)\$@i", $this->getFilename()) || $this->getFilename() == ".htaccess") {
         $this->setFilename($this->getFilename() . ".txt");
     }
     if (Asset\Service::pathExists($this->getFullPath())) {
         $duplicate = Asset::getByPath($this->getFullPath());
         if ($duplicate instanceof Asset and $duplicate->getId() != $this->getId()) {
             throw new \Exception("Duplicate full path [ " . $this->getFullPath() . " ] - cannot save asset");
         }
     }
     if (strlen($this->getFullPath()) > 765) {
         throw new \Exception("Full path is limited to 765 characters, reduce the length of your parent's path");
     }
 }
开发者ID:Gerhard13,项目名称:pimcore,代码行数:46,代码来源:Asset.php

示例7: getFromCsvImport

 /**
  * fills object field data values from CSV Import String
  * @abstract
  * @param string $importValue
  * @param null|Model\Object\AbstractObject $object
  * @param mixed $params
  * @return Object\ClassDefinition\Data
  */
 public function getFromCsvImport($importValue, $object = null, $params = [])
 {
     $values = explode(",", $importValue);
     $value = [];
     foreach ($values as $element) {
         $tokens = explode(":", $element);
         if (count($tokens) == 2) {
             $type = $tokens[0];
             $path = $tokens[1];
             $value[] = Element\Service::getElementByPath($type, $path);
         } else {
             //fallback for old export files
             if ($el = Asset::getByPath($element)) {
                 $value[] = $el;
             } elseif ($el = Document::getByPath($element)) {
                 $value[] = $el;
             } elseif ($el = Object::getByPath($element)) {
                 $value[] = $el;
             }
         }
     }
     return $value;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:31,代码来源:Multihref.php

示例8: restore

 /**
  *
  */
 public function restore($user = null)
 {
     $raw = file_get_contents($this->getStoreageFile());
     $element = Serialize::unserialize($raw);
     // check for element with the same name
     if ($element instanceof Document) {
         $indentElement = Document::getByPath($element->getRealFullPath());
         if ($indentElement) {
             $element->setKey($element->getKey() . "_restore");
         }
     } elseif ($element instanceof Asset) {
         $indentElement = Asset::getByPath($element->getRealFullPath());
         if ($indentElement) {
             $element->setFilename($element->getFilename() . "_restore");
         }
     } elseif ($element instanceof Object\AbstractObject) {
         $indentElement = Object::getByPath($element->getRealFullPath());
         if ($indentElement) {
             $element->setKey($element->getKey() . "_restore");
         }
     }
     if (\Pimcore\Tool\Admin::getCurrentUser()) {
         $parent = $element->getParent();
         if (!$parent->isAllowed("publish")) {
             throw new \Exception("Not sufficient permissions");
         }
     }
     $this->restoreChilds($element);
     $this->delete();
 }
开发者ID:solverat,项目名称:pimcore,代码行数:33,代码来源:Item.php

示例9: 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

示例10: getElementByPath

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

示例11: getFromCsvImport

 /**
  * @param $importValue
  * @param null|Model\Object\AbstractObject $object
  * @param mixed $params
  * @return mixed|null|Asset
  */
 public function getFromCsvImport($importValue, $object = null, $params = [])
 {
     $value = null;
     if ($el = Asset::getByPath($importValue)) {
         $value = $el;
     } else {
         $value = null;
     }
     return $value;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:16,代码来源:Image.php

示例12: setDataFromEditmode

 /**
  * @see Document\Tag\TagInterface::setDataFromEditmode
  * @param mixed $data
  * @return void
  */
 public function setDataFromEditmode($data)
 {
     if (!is_array($data)) {
         $data = array();
     }
     if ($doc = Document::getByPath($data['path'])) {
         if ($doc instanceof Document) {
             $data['internal'] = true;
             $data['internalId'] = $doc->getId();
             $data['internalType'] = 'document';
         }
         //its an object?
     } else {
         if (strpos($data['path'], '::') !== FALSE) {
             $data['internal'] = true;
             $data['internalType'] = 'object';
         }
     }
     if (!$data['internal']) {
         if ($asset = Asset::getByPath($data['path'])) {
             if ($asset instanceof Asset) {
                 $data['internal'] = true;
                 $data['internalId'] = $asset->getId();
                 $data['internalType'] = 'asset';
             }
         }
     }
     $this->data = $data;
     return $this;
 }
开发者ID:dachcom-digital,项目名称:pimcore-toolbox,代码行数:35,代码来源:Globallink.php

示例13: setDataFromEditmode

 /**
  * @see Document\Tag\TagInterface::setDataFromEditmode
  * @param mixed $data
  * @return void
  */
 public function setDataFromEditmode($data)
 {
     if (!is_array($data)) {
         $data = array();
     }
     if ($doc = Document::getByPath($data["path"])) {
         if ($doc instanceof Document) {
             $data["internal"] = true;
             $data["internalId"] = $doc->getId();
             $data["internalType"] = "document";
         }
     }
     if (!$data["internal"]) {
         if ($asset = Asset::getByPath($data["path"])) {
             if ($asset instanceof Asset) {
                 $data["internal"] = true;
                 $data["internalId"] = $asset->getId();
                 $data["internalType"] = "asset";
             }
         }
     }
     $this->data = $data;
     return $this;
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:29,代码来源:Link.php

示例14: setPath

 /**
  * @param $path
  * @return $this
  */
 public function setPath($path)
 {
     if (!empty($path)) {
         if ($document = Document::getByPath($path)) {
             $this->linktype = "internal";
             $this->internalType = "document";
             $this->internal = $document->getId();
         } else {
             if ($asset = Asset::getByPath($path)) {
                 $this->linktype = "internal";
                 $this->internalType = "asset";
                 $this->internal = $asset->getId();
             } else {
                 $this->linktype = "direct";
                 $this->direct = $path;
             }
         }
     }
     return $this;
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:24,代码来源:Link.php

示例15: copyAction

 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));
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:45,代码来源:AssetController.php


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