本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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;
}