mirror of
https://github.com/getgrav/grav.git
synced 2026-05-06 05:26:25 +02:00
Flex: Improve row rename logic
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
* Fixed `Flex Pages` bug where `onAdminSave` passes page as `$event['page']` instead of `$event['object']` [#2995](https://github.com/getgrav/grav/issues/2995)
|
||||
* Fixed `Flex Pages` bug where changing a modular page template added duplicate file [admin#1899](https://github.com/getgrav/grav-plugin-admin/issues/1899)
|
||||
* Fixed `Flex Pages` bug where renaming slug causes bad ordering range after save [#2997](https://github.com/getgrav/grav/issues/2997)
|
||||
#2997
|
||||
|
||||
# v1.7.0-rc.15
|
||||
## 07/22/2020
|
||||
|
||||
@@ -230,10 +230,6 @@ class FolderStorage extends AbstractFilesystemStorage
|
||||
*/
|
||||
public function renameRow(string $src, string $dst): bool
|
||||
{
|
||||
if ($this->hasKey($dst)) {
|
||||
throw new \RuntimeException("Cannot rename object: key '{$dst}' is already taken");
|
||||
}
|
||||
|
||||
if (!$this->hasKey($src)) {
|
||||
return false;
|
||||
}
|
||||
@@ -241,7 +237,15 @@ class FolderStorage extends AbstractFilesystemStorage
|
||||
$srcPath = $this->getStoragePath($src);
|
||||
$dstPath = $this->getStoragePath($dst);
|
||||
if (!$srcPath || !$dstPath) {
|
||||
return false;
|
||||
throw new \RuntimeException("Destination path '{$dst}' is empty");
|
||||
}
|
||||
|
||||
if ($srcPath === $dstPath) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->hasKey($dst)) {
|
||||
throw new \RuntimeException("Cannot rename object '{$src}': key '{$dst}' is already taken $srcPath $dstPath");
|
||||
}
|
||||
|
||||
return $this->moveFolder($srcPath, $dstPath);
|
||||
|
||||
Reference in New Issue
Block a user