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


PHP IOHelper::getParentFolderPath方法代码示例

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


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

示例1: renameSourceFolder

 /**
  * @inheritDoc BaseAssetSourceType::renameSourceFolder()
  *
  * @param AssetFolderModel $folder
  * @param                  $newName
  *
  * @return bool
  */
 protected function renameSourceFolder(AssetFolderModel $folder, $newName)
 {
     $newFullPath = $this->_getPathPrefix() . IOHelper::getParentFolderPath($folder->path) . $newName . '/';
     $this->_prepareForRequests();
     $bucket = $this->getSettings()->bucket;
     $filesToMove = $this->_s3->getBucket($bucket, $this->_getPathPrefix() . $folder->path);
     rsort($filesToMove);
     foreach ($filesToMove as $file) {
         $filePath = mb_substr($file['name'], mb_strlen($this->_getPathPrefix() . $folder->path));
         $this->_s3->copyObject($bucket, $file['name'], $bucket, $newFullPath . $filePath, \S3::ACL_PUBLIC_READ);
         @$this->_s3->deleteObject($bucket, $file['name']);
     }
     return true;
 }
开发者ID:webremote,项目名称:craft_boilerplate,代码行数:22,代码来源:S3AssetSourceType.php

示例2: renameSourceFolder

 /**
  * @inheritDoc BaseAssetSourceType::renameSourceFolder()
  *
  * @param AssetFolderModel $folder
  * @param string           $newName
  *
  * @return bool
  */
 protected function renameSourceFolder(AssetFolderModel $folder, $newName)
 {
     $newFullPath = IOHelper::getParentFolderPath($folder->path) . $newName . '/';
     return IOHelper::rename($this->getSourceFileSystemPath() . $folder->path, $this->getSourceFileSystemPath() . $newFullPath);
 }
开发者ID:nathanedwards,项目名称:cowfields.craft,代码行数:13,代码来源:LocalAssetSourceType.php

示例3: renameFolder

 /**
  * Rename a folder.
  *
  * @param AssetFolderModel $folder  The assetFolderModel representing the name of the folder to rename.
  * @param string           $newName The new name of the folder.
  *
  * @throws Exception
  * @return AssetOperationResponseModel
  */
 public function renameFolder(AssetFolderModel $folder, $newName)
 {
     $parentFolder = craft()->assets->getFolderById($folder->parentId);
     if (!$parentFolder) {
         throw new Exception(Craft::t("Cannot rename folder “{folder}”!", array('folder' => $folder->name)));
     }
     // Allow this for changing the case
     if (!(StringHelper::toLowerCase($newName) == StringHelper::toLowerCase($folder->name)) && $this->folderExists($parentFolder, $newName)) {
         throw new Exception(Craft::t("Folder “{folder}” already exists there.", array('folder' => $newName)));
     }
     // Try to rename the folder in the source
     if (!$this->renameSourceFolder($folder, $newName)) {
         throw new Exception(Craft::t("Cannot rename folder “{folder}”!", array('folder' => $folder->name)));
     }
     $oldFullPath = $folder->path;
     $newFullPath = IOHelper::getParentFolderPath($folder->path) . $newName . '/';
     // Find all folders with affected fullPaths and update them.
     $folders = craft()->assets->getAllDescendantFolders($folder);
     foreach ($folders as $folderModel) {
         $folderModel->path = preg_replace('#^' . $oldFullPath . '#', $newFullPath, $folderModel->path);
         craft()->assets->storeFolder($folderModel);
     }
     // Now change the affected folder
     $folder->name = $newName;
     $folder->path = $newFullPath;
     craft()->assets->storeFolder($folder);
     // All set, Scotty!
     $response = new AssetOperationResponseModel();
     return $response->setSuccess()->setDataItem('newName', $newName);
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:39,代码来源:BaseAssetSourceType.php

示例4: renameSourceFolder

 /**
  * @inheritDoc BaseAssetSourceType::renameSourceFolder()
  *
  * @param AssetFolderModel $folder
  * @param string           $newName
  *
  * @return bool
  */
 protected function renameSourceFolder(AssetFolderModel $folder, $newName)
 {
     $newFullPath = $this->_getPathPrefix() . IOHelper::getParentFolderPath($folder->path) . $newName . '/';
     $objectList = $this->_getFileList($this->_getPathPrefix() . $folder->path);
     $filesToMove = array();
     foreach ($objectList as $object) {
         $filesToMove[$object->name] = $object;
     }
     krsort($filesToMove);
     foreach ($filesToMove as $file) {
         $filePath = mb_substr($file->name, mb_strlen($this->_getPathPrefix() . $folder->path));
         $sourceUri = $this->_prepareRequestURI($this->getSettings()->container, $file->name);
         $targetUri = $this->_prepareRequestURI($this->getSettings()->container, $newFullPath . $filePath);
         $this->_copyFile($sourceUri, $targetUri);
         $this->_deleteObject($sourceUri);
     }
     // This may or may not exist.
     $this->_deleteObject($this->_prepareRequestURI($this->getSettings()->container, $this->_getPathPrefix() . rtrim($folder->path, '/')));
     return true;
 }
开发者ID:ericnormannn,项目名称:m,代码行数:28,代码来源:RackspaceAssetSourceType.php


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