Stump Assets
  • Namespace
  • Class
  • Tree
  • Todo
  • Download

Namespaces

  • Skimia
    • Assets
      • Console
        • Commands
      • Events
      • Providers
      • Scanner

Classes

  • Skimia\Assets\AssetsServiceProvider
  • Skimia\Assets\Console\Commands\DumpCollectionsCommand
  • Skimia\Assets\Console\Commands\FlushPipelineCommand
  • Skimia\Assets\Events\BeforeMergeCollectionFiles
  • Skimia\Assets\Manager
  • Skimia\Assets\Providers\StolzAssetsServiceProvider
  • Skimia\Assets\Scanner\Scanner
  • Skimia\Assets\Scanner\ScannerServiceProvider
  1 <?php
  2 
  3 namespace Skimia\Assets\Console\Commands;
  4 
  5 use Illuminate\Console\Command;
  6 use Illuminate\Contracts\Bus\SelfHandling;
  7 use Config;
  8 use Skimia\Foundation\Testing\TestablePromptCommandInterface;
  9 use Skimia\Foundation\Testing\Traits\TestableCommandTrait;
 10 
 11 class DumpCollectionsCommand extends Command implements SelfHandling,TestablePromptCommandInterface
 12 {
 13     use TestableCommandTrait;
 14     /**
 15      * The console command name.
 16      *
 17      * @var string
 18      */
 19     protected $name = 'asset:dump-collections';
 20 
 21     /**
 22      * The name and signature of the console command.
 23      *
 24      * @var string
 25      */
 26     protected $signature = 'asset:dump-collections {--s|silent}';
 27 
 28     /**
 29      * The console command description.
 30      *
 31      * @var string
 32      */
 33     protected $description = 'Regenerate collection & copy files to public dir.';
 34 
 35     /**
 36      * Class constructor.
 37      *
 38      * @param \Illuminate\Contracts\Config\Repository $config
 39      *
 40      * @return void
 41      */
 42     public function __construct()//Config $config(See NOTE below)
 43     {
 44         parent::__construct();
 45 
 46         // NOTE: Dependency injection for Artisan commands constructor was not introduced until Laravel 5.1 (LST).
 47         // In order to keep compatibility with Laravel 5.0 we manually resolve the dependencies
 48 
 49         //$this->app = $app;
 50         //$this->config = $config;
 51 
 52         $this->app = app();
 53         $this->config = app(Config::class);
 54     }
 55 
 56     /**
 57      * Execute the command.
 58      *
 59      * @return void
 60      */
 61     public function fire()
 62     {
 63         $this->comment('Regeneration of assets collections...');
 64         $directories = $this->getDirectories();
 65         if (empty($directories)) {
 66             $this->comment('no directories to scan, abort');
 67 
 68             return;
 69         }
 70 
 71         //dd($directories);
 72         $scanner = $this->getScanner();
 73 
 74         $scanner->setDirectoriesToScan($directories);
 75 
 76         $scanner->scan();
 77         $added = $scanner->getNewlyBuildedCollections();
 78         $removed = $scanner->getRemovedBuildedCollections();
 79         if (count($added) > 0) {
 80             $this->comment('added collections : '.implode(', ', $added));
 81         }
 82         if (count($removed) > 0) {
 83             $this->comment('removed collections : '.implode(', ', $removed));
 84         }
 85         if ((count($added) + count($removed)) > 0 && $this->option('silent') !== true) {
 86             $update = $this->ask('Update Assets groups with the new or removed collections ? y/n', 'y');
 87             $this->comment('sorry in the new release ;)');
 88         }
 89         $this->comment('done');
 90     }
 91 
 92     /**
 93      * @codeCoverageIgnore
 94      */
 95     protected function getDirectories()
 96     {
 97         return $this->app['config']->get('assets.directories', []);
 98     }
 99 
100     /**
101      * @return Scanner
102      * @codeCoverageIgnore
103      */
104     protected function getScanner()
105     {
106         return $this->app->make('skimia.assets.scanner');
107     }
108 }
109 
Stump Assets API documentation generated by ApiGen