1 | <?php |
||
2 | |||
3 | namespace Prateekkarki\Laragen\Models; |
||
4 | use Symfony\Component\Filesystem\Filesystem as SymphonyFilesystem; |
||
5 | |||
6 | class FileSystem extends SymphonyFilesystem |
||
7 | { |
||
8 | public function clone($src, $dest){ |
||
9 | $src = $this->getFullSourcePath($src); |
||
10 | |||
11 | $dest = base_path($dest); |
||
12 | |||
13 | if (is_dir($src)) { |
||
14 | $this->mirror($src, $dest."/".basename($src)); |
||
15 | } else { |
||
16 | $this->copy($src, $dest); |
||
17 | } |
||
18 | } |
||
19 | |||
20 | public function getFullSourcePath($path) { |
||
21 | return realpath(__DIR__."/../resources/".$path); |
||
22 | } |
||
23 | |||
24 | public function removeDir($dir) { |
||
25 | if (! is_dir($dir)) { |
||
26 | throw new InvalidArgumentException("$dir must be a directory"); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
27 | } |
||
28 | if (substr($dir, strlen($dir) - 1, 1) != '/') { |
||
29 | $dir .= '/'; |
||
30 | } |
||
31 | $files = glob($dir . '*', GLOB_MARK); |
||
32 | foreach ($files as $file) { |
||
33 | if (is_dir($file)) { |
||
34 | $this->removeDir($file); |
||
35 | } else { |
||
36 | $this->remove($file); |
||
37 | } |
||
38 | } |
||
39 | $this->remove($dir); |
||
40 | } |
||
41 | } |
||
42 |