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:
Barry vd. Heuvel
2014-02-07 09:50:07 +01:00
parent 107fda3c20
commit 948eb369a6
2 changed files with 15 additions and 14 deletions
@@ -42,7 +42,7 @@ class ModelsCommand extends Command {
protected $properties = array();
protected $methods = array();
protected $write = false;
protected $dir;
protected $dirs = array();
protected $reset;
@@ -56,7 +56,7 @@ class ModelsCommand extends Command {
{
$filename = $this->option('filename');
$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');
$ignore = $this->option('ignore');
$this->reset = $this->option('reset');
@@ -102,7 +102,7 @@ class ModelsCommand extends Command {
{
return array(
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('nowrite', 'N', InputOption::VALUE_NONE, 'Don\'t write to Model file'),
array('reset', 'R', InputOption::VALUE_NONE, 'Remove the original phpdocs instead of appending'),
@@ -167,12 +167,11 @@ class ModelsCommand extends Command {
protected function loadModels(){
$default = (array)(base_path().'/'.$this->dir);
$dir = array_merge(\Config::get('laravel-ide-helper::model_locations'),$default);
$models = array();
foreach($dir as $d){
if(file_exists($d)){
foreach(ClassMapGenerator::createMap($d) as $model=> $path){
foreach($this->dirs as $dir){
$dir = base_path() . '/' . $dir;
if(file_exists($dir)){
foreach(ClassMapGenerator::createMap($dir) as $model=> $path){
$models[] = $model;
}
}
+8 -6
View File
@@ -28,18 +28,20 @@ return array(
'helper_files' => array(
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
| outside of the /app/models directory.
| Define in which directories the ide-helper:models command should look
| for models.
|
*/
'model_locations' => (),
'model_locations' => array(
'app/models',
),
/*