Skip to content

Commit

Permalink
Merge pull request #4 from apantle/fix-decorated-clear-command-call
Browse files Browse the repository at this point in the history
Fix decorated clear command call
  • Loading branch information
dinhquochan committed Aug 30, 2020
2 parents edb6127 + 3244fe5 commit 221f457
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 4 additions & 9 deletions src/Console/TwigViewClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\Console\ViewClearCommand;
use RuntimeException;

class TwigViewClearCommand extends Command
Expand All @@ -15,25 +14,18 @@ class TwigViewClearCommand extends Command
/** @var string */
protected $description = 'Clear all compiled view files';

/** @var \Illuminate\Foundation\Console\ViewClearCommand */
protected $viewClearCommand;

/** @var \Illuminate\Filesystem\Filesystem */
protected $files;

public function __construct(ViewClearCommand $viewClearCommand, Filesystem $files)
public function __construct(Filesystem $files)
{
parent::__construct();

$this->viewClearCommand = $viewClearCommand;

$this->files = $files;
}

public function handle()
{
$this->viewClearCommand->handle();

$path = $this->laravel['config']['view.compiled'];

if (! $path) {
Expand All @@ -45,6 +37,9 @@ public function handle()
$this->files->deleteDirectory($view);
continue;
}
if ($this->files->isFile($view)) {
$this->files->delete($view);
}
}

$this->info('Compiled twig views cleared!');
Expand Down
2 changes: 1 addition & 1 deletion src/TwigServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected function registerViewExtensions()
protected function registerCommands()
{
$this->app->extend('command.view.clear', function ($abstract, $app) {
return new TwigViewClearCommand($abstract, $app['files']);
return new TwigViewClearCommand($app['files']);
});
}
}

0 comments on commit 221f457

Please sign in to comment.