1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Laravel IDE Helper Generator. |
4
|
|
|
* |
5
|
|
|
* @author Barry vd. Heuvel <[email protected]> |
6
|
|
|
* @copyright 2014 Barry vd. Heuvel / Fruitcake Studio (http://www.fruitcakestudio.nl) |
7
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
8
|
|
|
* @link https://github.com/barryvdh/laravel-ide-helper |
9
|
|
|
*/ |
10
|
|
|
namespace SleepingOwl\Admin\Console\Commands; |
11
|
|
|
|
12
|
|
|
use SleepingOwl\Admin\Console\Generator; |
13
|
|
|
use Barryvdh\LaravelIdeHelper\Console\GeneratorCommand as IdeHelperGeneratorCommand; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* A command to generate autocomplete information for your IDE. |
17
|
|
|
* |
18
|
|
|
* @author Aios Dave <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class GeneratorCommand extends IdeHelperGeneratorCommand |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* The console command name. |
24
|
|
|
* |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
protected $name = 'sleepingowl:ide:generate'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException |
31
|
|
|
*/ |
32
|
|
|
public function handle() |
33
|
|
|
{ |
34
|
|
|
if (file_exists(base_path().'/vendor/compiled.php') || |
35
|
|
|
file_exists(base_path().'/bootstrap/cache/compiled.php') || |
36
|
|
|
file_exists(base_path().'/storage/framework/compiled.php')) { |
37
|
|
|
$this->error( |
38
|
|
|
'Error generating IDE Helper: first delete your compiled file (php artisan clear-compiled)' |
39
|
|
|
); |
40
|
|
|
} else { |
41
|
|
|
$filename = (string) $this->argument('filename'); |
42
|
|
|
$format = (string) $this->option('format'); |
43
|
|
|
|
44
|
|
|
// Strip the php extension |
45
|
|
|
if (substr($filename, -4, 4) == '.php') { |
46
|
|
|
$filename = substr($filename, 0, -4); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$filename = implode('.', [$filename, $format]); |
50
|
|
|
|
51
|
|
|
if ($this->option('memory')) { |
52
|
|
|
$this->useMemoryDriver(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
$helpers = ''; |
56
|
|
|
if ($this->option('helpers') || ($this->config->get('ide-helper.include_helpers'))) { |
57
|
|
|
foreach ($this->config->get('ide-helper.helper_files', []) as $helper) { |
58
|
|
|
if (file_exists($helper)) { |
59
|
|
|
$helpers .= str_replace(['<?php', '?>'], '', $this->files->get($helper)); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
} else { |
63
|
|
|
$helpers = ''; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
$generator = new Generator($this->config, $this->view, $this->getOutput(), $helpers); |
67
|
|
|
$content = $generator->generate($format); |
68
|
|
|
$written = (int) $this->files->put($filename, $content); |
69
|
|
|
|
70
|
|
|
if ($written === false) { |
|
|
|
|
71
|
|
|
$this->error("The helper file could not be created at $filename"); |
72
|
|
|
} else { |
73
|
|
|
$this->info("A new helper file was written to $filename"); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|