Filter abstracts for common errors

Fixes #184
This commit is contained in:
Barry vd. Heuvel
2015-03-17 08:57:14 +01:00
parent a89273d7ad
commit f518de4ae1
+29 -8
View File
@@ -35,10 +35,10 @@ class MetaCommand extends Command {
*/
protected $description = 'Generate metadata for PhpStorm';
/** @var \Illuminate\Filesystem\Filesystem */
/** @var \Illuminate\Contracts\Filesystem\Filesystem */
protected $files;
/** @var \Illuminate\View\Factory */
/** @var \Illuminate\Contracts\View\Factory */
protected $view;
protected $methods = [
@@ -52,8 +52,8 @@ class MetaCommand extends Command {
/**
*
* @param \Illuminate\Filesystem\Filesystem $files
* @param \Illuminate\View\Factory $view
* @param \Illuminate\Contracts\Filesystem\Filesystem $files
* @param \Illuminate\Contracts\View\Factory $view
*/
public function __construct($files, $view) {
$this->files = $files;
@@ -68,11 +68,8 @@ class MetaCommand extends Command {
*/
public function fire()
{
$filename = $this->option('filename');
$bindings = array();
foreach ($this->laravel->getBindings() as $abstract => $options) {
foreach ($this->getAbstracts() as $abstract) {
try {
$concrete = $this->laravel->make($abstract);
if (is_object($concrete)) {
@@ -88,6 +85,7 @@ class MetaCommand extends Command {
'methods' => $this->methods,
])->render();
$filename = $this->option('filename');
$written = $this->files->put($filename, $content);
if ($written !== false) {
@@ -97,6 +95,29 @@ class MetaCommand extends Command {
}
}
/**
* Get a filtered list of abstracts from the Laravel Application.
*
* @return array
*/
protected function getAbstracts()
{
$abstracts = $this->laravel->getBindings();
// Remove the S3 cloud driver when not available
if (config('filesystems.cloud') === 's3' && !class_exists('League\Flysystem\AwsS3v2\AwsS3Adapter')) {
unset($abstracts['filesystem.cloud']);
}
// Remove Redis when not available
if (isset($abstracts['redis']) && !class_exists('Predis\Client')) {
unset($abstracts['redis']);
}
// Return the abstract names only
return array_keys($abstracts);
}
/**
* Get the console command options.
*