Skip to content

Commit e5acc65

Browse files
authored
Merge pull request #85 from ejeanneaubc/master
Add folder rename event
2 parents 48aac99 + c8db08f commit e5acc65

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/Events/FolderWasRenamed.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Unisharp\Laravelfilemanager\Events;
4+
5+
class FolderWasRenamed
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+
}

src/controllers/RenameController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Support\Str;
99
use Lang;
1010
use Unisharp\Laravelfilemanager\Events\ImageWasRenamed;
11+
use Unisharp\Laravelfilemanager\Events\FolderWasRenamed;
1112

1213
/**
1314
* Class RenameController
@@ -39,10 +40,9 @@ public function getRename()
3940
return Lang::get('laravel-filemanager::lfm.error-rename');
4041
}
4142

42-
Event::fire(new ImageWasRenamed($old_file, $new_file));
43-
4443
if (File::isDirectory($old_file)) {
4544
File::move($old_file, $new_file);
45+
Event::fire(new FolderWasRenamed($old_file, $new_file));
4646
return 'OK';
4747
}
4848

@@ -52,6 +52,8 @@ public function getRename()
5252
File::move($thumb_path . $old_name, $thumb_path . $new_name);
5353
}
5454

55+
Event::fire(new ImageWasRenamed($old_file, $new_file));
56+
5557
return 'OK';
5658
}
5759
}

0 commit comments

Comments
 (0)