mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
Add additional directories
For #57 (and #58), tweak a bit. Make the input option an array, so commandline can also add multiple dirs. Add app/models to the config, prepend the base_path() to every dir.
This commit is contained in:
@@ -42,7 +42,7 @@ class ModelsCommand extends Command {
|
|||||||
protected $properties = array();
|
protected $properties = array();
|
||||||
protected $methods = array();
|
protected $methods = array();
|
||||||
protected $write = false;
|
protected $write = false;
|
||||||
protected $dir;
|
protected $dirs = array();
|
||||||
protected $reset;
|
protected $reset;
|
||||||
|
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ class ModelsCommand extends Command {
|
|||||||
{
|
{
|
||||||
$filename = $this->option('filename');
|
$filename = $this->option('filename');
|
||||||
$this->write = $this->option('write');
|
$this->write = $this->option('write');
|
||||||
$this->dir = $this->option('dir');
|
$this->dirs = array_merge($this->laravel['config']->get('laravel-ide-helper::model_locations'), $this->option('dir'));
|
||||||
$model = $this->argument('model');
|
$model = $this->argument('model');
|
||||||
$ignore = $this->option('ignore');
|
$ignore = $this->option('ignore');
|
||||||
$this->reset = $this->option('reset');
|
$this->reset = $this->option('reset');
|
||||||
@@ -102,7 +102,7 @@ class ModelsCommand extends Command {
|
|||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array('filename', 'F', InputOption::VALUE_OPTIONAL, 'The path to the helper file', $this->filename),
|
array('filename', 'F', InputOption::VALUE_OPTIONAL, 'The path to the helper file', $this->filename),
|
||||||
array('dir', 'D', InputOption::VALUE_OPTIONAL, 'The model dir','app/models'),
|
array('dir', 'D', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The model dir', array()),
|
||||||
array('write', 'W', InputOption::VALUE_NONE, 'Write to Model file'),
|
array('write', 'W', InputOption::VALUE_NONE, 'Write to Model file'),
|
||||||
array('nowrite', 'N', InputOption::VALUE_NONE, 'Don\'t write to Model file'),
|
array('nowrite', 'N', InputOption::VALUE_NONE, 'Don\'t write to Model file'),
|
||||||
array('reset', 'R', InputOption::VALUE_NONE, 'Remove the original phpdocs instead of appending'),
|
array('reset', 'R', InputOption::VALUE_NONE, 'Remove the original phpdocs instead of appending'),
|
||||||
@@ -167,12 +167,11 @@ class ModelsCommand extends Command {
|
|||||||
|
|
||||||
|
|
||||||
protected function loadModels(){
|
protected function loadModels(){
|
||||||
$default = (array)(base_path().'/'.$this->dir);
|
|
||||||
$dir = array_merge(\Config::get('laravel-ide-helper::model_locations'),$default);
|
|
||||||
$models = array();
|
$models = array();
|
||||||
foreach($dir as $d){
|
foreach($this->dirs as $dir){
|
||||||
if(file_exists($d)){
|
$dir = base_path() . '/' . $dir;
|
||||||
foreach(ClassMapGenerator::createMap($d) as $model=> $path){
|
if(file_exists($dir)){
|
||||||
|
foreach(ClassMapGenerator::createMap($dir) as $model=> $path){
|
||||||
$models[] = $model;
|
$models[] = $model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,18 +28,20 @@ return array(
|
|||||||
'helper_files' => array(
|
'helper_files' => array(
|
||||||
base_path().'/vendor/laravel/framework/src/Illuminate/Support/helpers.php',
|
base_path().'/vendor/laravel/framework/src/Illuminate/Support/helpers.php',
|
||||||
),
|
),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Additional model locations to include
|
| Model locations to include
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| Include additional model locations Useful for if you have models
|
| Define in which directories the ide-helper:models command should look
|
||||||
| outside of the /app/models directory.
|
| for models.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'model_locations' => (),
|
'model_locations' => array(
|
||||||
|
'app/models',
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user