File tree Expand file tree Collapse file tree 7 files changed +115
-2
lines changed Expand file tree Collapse file tree 7 files changed +115
-2
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Unisharp \Laravelfilemanager \Events ;
4+
5+ class FolderIsRenaming
6+ {
7+ private $ path ;
8+
9+ public function __construct ($ old_path , $ new_path )
10+ {
11+ $ this ->old_path = $ old_path ;
12+ $ this ->new_path = $ new_path ;
13+ }
14+
15+ /**
16+ * @return string
17+ */
18+ public function old_path ()
19+ {
20+ return $ this ->old_path ;
21+ }
22+
23+ public function new_path ()
24+ {
25+ return $ this ->new_path ;
26+ }
27+
28+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Unisharp \Laravelfilemanager \Events ;
4+
5+ class ImageIsDeleting
6+ {
7+ private $ path ;
8+
9+ public function __construct ($ path )
10+ {
11+ $ this ->path = $ path ;
12+ }
13+
14+ /**
15+ * @return string
16+ */
17+ public function path ()
18+ {
19+ return $ this ->path ;
20+ }
21+
22+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Unisharp \Laravelfilemanager \Events ;
4+
5+ class ImageIsRenaming
6+ {
7+ private $ path ;
8+
9+ public function __construct ($ old_path , $ new_path )
10+ {
11+ $ this ->old_path = $ old_path ;
12+ $ this ->new_path = $ new_path ;
13+ }
14+
15+ /**
16+ * @return string
17+ */
18+ public function old_path ()
19+ {
20+ return $ this ->old_path ;
21+ }
22+
23+ public function new_path ()
24+ {
25+ return $ this ->new_path ;
26+ }
27+
28+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Unisharp \Laravelfilemanager \Events ;
4+
5+ class ImageIsUploading
6+ {
7+ private $ path ;
8+
9+ public function __construct ($ path )
10+ {
11+ $ this ->path = $ path ;
12+ }
13+
14+ /**
15+ * @return string
16+ */
17+ public function path ()
18+ {
19+ return $ this ->path ;
20+ }
21+
22+ }
Original file line number Diff line number Diff line change 66use Illuminate \Support \Facades \File ;
77use Illuminate \Support \Facades \Input ;
88use Lang ;
9+ use Unisharp \Laravelfilemanager \Events \ImageIsDeleting ;
910use Unisharp \Laravelfilemanager \Events \ImageWasDeleted ;
1011
1112/**
@@ -28,6 +29,8 @@ public function getDelete()
2829 $ file_to_delete = $ file_path . $ name_to_delete ;
2930 $ thumb_to_delete = parent ::getPath ('thumb ' ) . $ name_to_delete ;
3031
32+ Event::fire (new ImageIsDeleting ($ file_to_delete ));
33+
3134 if (!File::exists ($ file_to_delete )) {
3235 return $ file_to_delete . ' not found! ' ;
3336 }
@@ -44,7 +47,7 @@ public function getDelete()
4447
4548 File::delete ($ file_to_delete );
4649 Event::fire (new ImageWasDeleted ($ file_to_delete ));
47-
50+
4851 if ('Images ' === $ this ->file_type ) {
4952 File::delete ($ thumb_to_delete );
5053 }
Original file line number Diff line number Diff line change 77use Illuminate \Support \Facades \Input ;
88use Illuminate \Support \Str ;
99use Lang ;
10+ use Unisharp \Laravelfilemanager \Events \ImageIsRenaming ;
1011use Unisharp \Laravelfilemanager \Events \ImageWasRenamed ;
12+ use Unisharp \Laravelfilemanager \Events \FolderIsRenaming ;
1113use Unisharp \Laravelfilemanager \Events \FolderWasRenamed ;
1214
1315/**
@@ -36,6 +38,12 @@ public function getRename()
3638
3739 $ new_file = $ file_path . $ new_name ;
3840
41+ if (File::isDirectory ($ old_file )) {
42+ Event::fire (new FolderIsRenaming ($ old_file , $ new_file ));
43+ } else {
44+ Event::fire (new ImageIsRenaming ($ old_file , $ new_file ));
45+ }
46+
3947 if (Config::get ('lfm.alphanumeric_directory ' ) && preg_match ('/[^\w-]/i ' , $ new_name )) {
4048 return Lang::get ('laravel-filemanager::lfm.error-folder-alnum ' );
4149 } elseif (File::exists ($ new_file )) {
Original file line number Diff line number Diff line change 99use Lang ;
1010use Intervention \Image \Facades \Image ;
1111use Symfony \Component \HttpFoundation \File \UploadedFile ;
12+ use Unisharp \Laravelfilemanager \Events \ImageIsUploading ;
1213use Unisharp \Laravelfilemanager \Events \ImageWasUploaded ;
1314
1415/**
@@ -45,9 +46,10 @@ public function upload()
4546 foreach ($ files as $ file )
4647 {
4748 $ new_filename = $ this ->getNewName ($ file );
48-
4949 $ dest_path = parent ::getPath ('directory ' );
5050
51+ Event::fire (new ImageIsUploading ($ dest_path . $ new_filename ));
52+
5153 if (File::exists ($ dest_path . $ new_filename )) {
5254 return Lang::get ('laravel-filemanager::lfm.error-file-exist ' );
5355 }
You can’t perform that action at this time.
0 commit comments