laravel-filemanager
laravel-filemanager copied to clipboard
ItemsController:domove() fires FileWasMoving instead of FolderIsMoving hook
- Operating system : 5.4.72-microsoft-standard-WSL2
- Laravel version : v8.83.6
- Package version : v2.4.1
- Steps to reproduce your issue :
- Add var_dump($is_directory) to vendor/unisharp/laravel-filemanager/src/Controllers/ItemsController.php:69
- Create two Folders (New Folder button) on Laravel Filemanager main screen
- Select one of the folders, click Move and select the second folder
- You will see var_dump output from point 1.
The value of this variable determines which event will be sent:
In this particular example, I'm expecting that FolderWasMoving/FolderIsMoving will be fired instead of FileWasMoving/FileIsMoving
Same issue here, it's caused by the following line: https://github.com/UniSharp/laravel-filemanager/blob/9e9022747832fb862a15bdafd4e6fdd564f10c82/src/Controllers/ItemsController.php#L67
The pretty function requires a second parameter to mark an item as a directory or not. So it's pretty illogical to retrieve whether it's a directory or not on the next line based on the returned item of this function.
(Also consider renaming this function, it doesn't make anything pretty, it creates an LfmItem object from a path.)