generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from savannabits/0.x-dev
New Feature: Provider Generation Command
- Loading branch information
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace Savannabits\Modular\Commands; | ||
|
||
use Illuminate\Console\GeneratorCommand; | ||
use Savannabits\Modular\Support\Concerns\GeneratesModularFiles; | ||
use Symfony\Component\Console\Attribute\AsCommand; | ||
use Symfony\Component\Console\Input\InputOption; | ||
|
||
#[AsCommand(name: 'modular:make-provider')] | ||
class ProviderMakeCommand extends GeneratorCommand | ||
{ | ||
use GeneratesModularFiles; | ||
|
||
/** | ||
* The console command name. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'modular:make-provider'; | ||
|
||
protected $description = 'Create a new Service provider class in a modular package'; | ||
|
||
protected $type = 'Provider'; | ||
|
||
public function handle(): ?bool | ||
{ | ||
$result = parent::handle(); | ||
|
||
if ($result === false) { | ||
return $result; | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* Get the stub file for the generator. | ||
*/ | ||
protected function getStub(): string | ||
{ | ||
return $this->resolveStubPath('/stubs/provider.stub'); | ||
} | ||
|
||
protected function getRelativeNamespace(): string | ||
{ | ||
return '\\Providers'; | ||
} | ||
|
||
/** | ||
* Get the console command arguments. | ||
*/ | ||
protected function getOptions(): array | ||
{ | ||
return [ | ||
['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the provider already exists'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters