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


PHP Asset::getByPath方法代码示例

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


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

示例1: restore

 public function restore()
 {
     $raw = file_get_contents($this->getStoreageFile());
     $element = Pimcore_Tool_Serialize::unserialize($raw);
     // check for element with the same name
     if ($element instanceof Document) {
         $indentElement = Document::getByPath($element->getFullpath());
         if ($indentElement) {
             $element->setKey($element->getKey() . "_restore");
         }
     } else {
         if ($element instanceof Asset) {
             $indentElement = Asset::getByPath($element->getFullpath());
             if ($indentElement) {
                 $element->setFilename($element->getFilename() . "_restore");
             }
         } else {
             if ($element instanceof Object_Abstract) {
                 $indentElement = Object_Abstract::getByPath($element->getFullpath());
                 if ($indentElement) {
                     $element->setKey($element->getKey() . "_restore");
                 }
             }
         }
     }
     $this->restoreChilds($element);
     $this->delete();
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:28,代码来源:Item.php

示例2: 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] = Pimcore_File::getValidFilename($nameParts[count($nameParts) - 1]);
     $sourcePath = implode("/", $nameParts);
     $nameParts = explode("/", $destinationPath);
     $nameParts[count($nameParts) - 1] = Pimcore_File::getValidFilename($nameParts[count($nameParts) - 1]);
     $destinationPath = implode("/", $nameParts);
     try {
         if (dirname($sourcePath) == dirname($destinationPath)) {
             try {
                 $destinationNode = $this->getNodeForPath($destinationPath);
                 // If we got here, it means the destination exists, and needs to be overwritten
                 $destinationNode->delete();
             } catch (Sabre_DAV_Exception_FileNotFound $e) {
                 // If we got here, it means the destination node does not yet exist
                 Logger::warning("Sabre_DAV_Exception_FileNotFound");
             }
             $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());
         }
     } catch (Exception $e) {
         Logger::error($e);
     }
     $asset->save();
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:38,代码来源:Tree.php

示例3: getChild

 /**
  * Returns a children by the filename
  *
  * @param string $asset
  * @return array
  */
 function getChild($name)
 {
     $nameParts = explode("/", $name);
     $name = Pimcore_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 Sabre_DAV_Exception_FileNotFound('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 Sabre_DAV_Exception_FileNotFound('File not found: ' . $name);
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:33,代码来源:Folder.php

示例4: decode

 public static function decode($value)
 {
     if ($value['type'] === self::TYPE) {
         return Asset::getByPath($value['data']);
     }
     return null;
 }
开发者ID:jv10,项目名称:pimpon,代码行数:7,代码来源:Image.php

示例5: setDataFromEditmode

 /**
  * Takes data from editmode and convert it to internal objects
  *
  * @param mixed $data
  * @return void
  */
 public function setDataFromEditmode($data)
 {
     // IMPORTANT: if you use this method be sure that the type of the property is already set
     if ($this->type == "document") {
         $this->data = Document::getByPath($data);
     } else {
         if ($this->type == "asset") {
             $this->data = Asset::getByPath($data);
         } else {
             if ($this->type == "object") {
                 $this->data = Object_Abstract::getByPath($data);
             } else {
                 if ($this->type == "date") {
                     $this->data = new Zend_Date($data);
                 } else {
                     if ($this->type == "bool") {
                         $this->data = false;
                         if (!empty($data)) {
                             $this->data = true;
                         }
                     } else {
                         // plain text
                         $this->data = $data;
                     }
                 }
             }
         }
     }
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:35,代码来源:Property.php

示例6: getWebsiteConfig

 /**
  * @static
  * @return mixed|Zend_Config
  */
 public static function getWebsiteConfig()
 {
     try {
         $config = Zend_Registry::get("pimcore_config_website");
     } catch (Exception $e) {
         $cacheKey = "website_config";
         if (!($config = Pimcore_Model_Cache::load($cacheKey))) {
             $websiteSettingFile = PIMCORE_CONFIGURATION_DIRECTORY . "/website.xml";
             $settingsArray = array();
             if (is_file($websiteSettingFile)) {
                 $rawConfig = new Zend_Config_Xml($websiteSettingFile);
                 $arrayData = $rawConfig->toArray();
                 foreach ($arrayData as $key => $value) {
                     $s = null;
                     if ($value["type"] == "document") {
                         $s = Document::getByPath($value["data"]);
                     } else {
                         if ($value["type"] == "asset") {
                             $s = Asset::getByPath($value["data"]);
                         } else {
                             if ($value["type"] == "object") {
                                 $s = Object_Abstract::getByPath($value["data"]);
                             } else {
                                 if ($value["type"] == "bool") {
                                     $s = (bool) $value["data"];
                                 } else {
                                     if ($value["type"] == "text") {
                                         $s = (string) $value["data"];
                                     }
                                 }
                             }
                         }
                     }
                     if ($s) {
                         $settingsArray[$key] = $s;
                     }
                 }
             }
             $config = new Zend_Config($settingsArray, true);
             Pimcore_Model_Cache::save($config, $cacheKey, array("websiteconfig", "system", "config"), null, 998);
         }
         self::setWebsiteConfig($config);
     }
     return $config;
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:49,代码来源:Config.php

示例7: setValuesToDocument

 protected function setValuesToDocument(Document_Link $link)
 {
     // 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();
         } else {
             if ($asset = Asset::getByPath($data["path"])) {
                 $data["linktype"] = "internal";
                 $data["internalType"] = "asset";
                 $data["internal"] = $asset->getId();
             } else {
                 $data["linktype"] = "direct";
                 $data["direct"] = $data["path"];
             }
         }
     }
     unset($data["path"]);
     $link->setValues($data);
     $this->addPropertiesToDocument($link);
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:24,代码来源:LinkController.php

示例8: getElementByPath

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

示例9: copyAction

 public function copyAction()
 {
     $success = false;
     $sourceId = intval($this->_getParam("sourceId"));
     $source = Asset::getById($sourceId);
     $session = new Zend_Session_Namespace("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"));
     }
     $this->_helper->json(array("success" => $success));
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:44,代码来源:AssetController.php

示例10: array

$arrayData = $rawConfig->toArray();
$data = array();
foreach ($arrayData as $key => $value) {
    $setting = new WebsiteSetting();
    $setting->setName($key);
    $type = $value["type"];
    $setting->setType($type);
    $data = $value["data"];
    if ($type == "bool") {
        $data = (bool) $data;
    } else {
        if ($type == "document") {
            $data = Document::getByPath($value["data"]);
        } else {
            if ($type == "asset") {
                $data = Asset::getByPath($value["data"]);
            } else {
                if ($type == "object") {
                    $data = Object_Abstract::getByPath($value["data"]);
                }
            }
        }
    }
    if ($data instanceof Element_Interface) {
        $data = $data->getId();
    }
    $setting->setData($data);
    $siteId = $value["siteId"] > 0 ? (int) $value["siteId"] : null;
    $setting->setSiteId($siteId);
    $setting->save();
}
开发者ID:SeerUK,项目名称:pimcore-manual-updater,代码行数:31,代码来源:postupdate.php

示例11: correctPath

 public function correctPath()
 {
     // set path
     if ($this->getId() != 1) {
         // not for the root node
         $parent = Asset::getById($this->getParentId());
         if ($parent) {
             $this->setPath(str_replace("//", "/", $parent->getFullPath() . "/"));
         } 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("/");
         }
     }
     $duplicate = Asset::getByPath($this->getFullPath());
     if ($duplicate instanceof Asset and $duplicate->getId() != $this->getId()) {
         throw new Exception("Duplicate full path [ " . $this->getFullPath() . " ] - cannot create asset");
     }
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:21,代码来源:Asset.php

示例12: setDataFromEditmode

 /**
  * @see Document_Tag_Interface::setDataFromEditmode
  * @param mixed $data
  * @return void
  */
 public function setDataFromEditmode($data)
 {
     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;
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:25,代码来源:Link.php

示例13: setPath

 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;
             }
         }
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:19,代码来源:Link.php

示例14: getFromCsvImport

 /**
  * fills object field data values from CSV Import String
  * @abstract
  * @param string $importValue
  * @param Object_Abstract $abstract
  * @return Object_Class_Data
  */
 public function getFromCsvImport($importValue)
 {
     $value = null;
     $values = explode(":", $importValue);
     if (count($values) == 2) {
         $type = $values[0];
         $path = $values[1];
         $value = Element_Service::getElementByPath($type, $path);
     } else {
         //fallback for old export files
         if ($el = Asset::getByPath($importValue)) {
             $value = $el;
         } else {
             if ($el = Document::getByPath($importValue)) {
                 $value = $el;
             } else {
                 if ($el = Object_Abstract::getByPath($importValue)) {
                     $value = $el;
                 }
             }
         }
     }
     return $value;
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:31,代码来源:Href.php

示例15: getSaveCopyName

 /**
  * Returns a uniqe key for the document in the $target-Path (recursive)
  * @param Element_Interface $element
  */
 protected function getSaveCopyName($element, $key, $path)
 {
     if ($element instanceof Object_Abstract) {
         $equal = Object_Abstract::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:shanky0110,项目名称:pimcore-custom,代码行数:23,代码来源:Service.php


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