Skip to content

Commit

Permalink
Injecting specific SP to commands
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Engebretson <adam@enge.me>
  • Loading branch information
adamgoose committed Mar 27, 2015
1 parent 9c250d8 commit 67519c3
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/AnnotationsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected function registerEventScanCommand()
{
$this->app->singleton('command.event.scan', function ($app)
{
return new EventScanCommand($app['files']);
return new EventScanCommand($app['files'], $this);
});
}

Expand All @@ -155,7 +155,7 @@ protected function registerRouteScanCommand()
{
$this->app->singleton('command.route.scan', function ($app)
{
return new RouteScanCommand($app['files']);
return new RouteScanCommand($app['files'], $this);
});
}

Expand All @@ -168,7 +168,7 @@ protected function registerModelScanCommand()
{
$this->app->singleton('command.model.scan', function ($app)
{
return new ModelScanCommand($app['files']);
return new ModelScanCommand($app['files'], $this);
});
}

Expand Down
19 changes: 13 additions & 6 deletions src/Console/EventScanCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace Collective\Annotations\Console;

use Collective\Annotations\AnnotationsServiceProvider;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Collective\Annotations\Events\Annotations\Scanner;
Expand Down Expand Up @@ -28,17 +29,25 @@ class EventScanCommand extends Command {
*/
protected $files;

/**
* The Service Provider instance.
*
* @var AnnotationsServiceProvider
*/
protected $provider;

/**
* Create a new event scan command instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @return void
* @param \Illuminate\Filesystem\Filesystem $files
* @param AnnotationsServiceProvider $provider
*/
public function __construct(Filesystem $files)
public function __construct(Filesystem $files, AnnotationsServiceProvider $provider)
{
parent::__construct();

$this->files = $files;
$this->provider = $provider;
}

/**
Expand All @@ -60,11 +69,9 @@ public function fire()
*/
protected function getEventDefinitions()
{
$provider = 'Collective\Annotations\AnnotationsServiceProvider';

$scanner = $this->laravel->make('annotations.event.scanner');

$scanner->setClassesToScan($this->laravel->getProvider($provider)->eventScans());
$scanner->setClassesToScan($this->provider->eventScans());

return '<?php '.PHP_EOL.PHP_EOL.$scanner->getEventDefinitions().PHP_EOL;
}
Expand Down
19 changes: 13 additions & 6 deletions src/Console/ModelScanCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace Collective\Annotations\Console;

use Collective\Annotations\AnnotationsServiceProvider;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Collective\Annotations\Routing\Annotations\Scanner;
Expand Down Expand Up @@ -29,17 +30,25 @@ class ModelScanCommand extends Command {
*/
protected $files;

/**
* The Serivce Provider instance.
*
* @var AnnotationsServiceProvider
*/
protected $provider;

/**
* Create a new event scan command instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @return void
* @param \Illuminate\Filesystem\Filesystem $files
* @param AnnotationsServiceProvider $provider
*/
public function __construct(Filesystem $files)
public function __construct(Filesystem $files, AnnotationsServiceProvider $provider)
{
parent::__construct();

$this->files = $files;
$this->provider = $provider;
}

/**
Expand All @@ -61,11 +70,9 @@ public function fire()
*/
protected function getRouteDefinitions()
{
$provider = 'Collective\Annotations\AnnotationsServiceProvider';

$scanner = $this->laravel->make('annotations.model.scanner');

$scanner->setClassesToScan($this->laravel->getProvider($provider)->modelScans());
$scanner->setClassesToScan($this->provider->modelScans());

return '<?php '.PHP_EOL.PHP_EOL.$scanner->getModelDefinitions().PHP_EOL;
}
Expand Down
20 changes: 13 additions & 7 deletions src/Console/RouteScanCommand.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php namespace Collective\Annotations\Console;

use Collective\Annotations\AnnotationsServiceProvider;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Collective\Annotations\Routing\Annotations\Scanner;
use Symfony\Component\Console\Input\InputOption;
use Illuminate\Console\AppNamespaceDetectorTrait;

Expand Down Expand Up @@ -31,17 +31,25 @@ class RouteScanCommand extends Command {
*/
protected $files;

/**
* The Service Provider instance.
*
* @var AnnotationsServiceProvider
*/
protected $provider;

/**
* Create a new event scan command instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @return void
* @param \Illuminate\Filesystem\Filesystem $files
* @param AnnotationsServiceProvider $provider
*/
public function __construct(Filesystem $files)
public function __construct(Filesystem $files, AnnotationsServiceProvider $provider)
{
parent::__construct();

$this->files = $files;
$this->provider = $provider;
}

/**
Expand All @@ -68,11 +76,9 @@ public function fire()
*/
protected function getRouteDefinitions()
{
$provider = 'Collective\Annotations\AnnotationsServiceProvider';

$scanner = $this->laravel->make('annotations.route.scanner');

$scanner->setClassesToScan($this->laravel->getProvider($provider)->routeScans());
$scanner->setClassesToScan($this->provider->routeScans());

return '<?php '.PHP_EOL.PHP_EOL.$scanner->getRouteDefinitions().PHP_EOL;
}
Expand Down

0 comments on commit 67519c3

Please sign in to comment.