This repository has been archived by the owner on Sep 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
186 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 |
---|---|---|
|
@@ -26,6 +26,10 @@ | |
|
||
'model' => null, | ||
|
||
'observer' => null, | ||
|
||
'rule' => null, | ||
|
||
], | ||
|
||
]; |
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,89 @@ | ||
<?php | ||
|
||
namespace Signifly\Console\Commands; | ||
|
||
use Symfony\Component\Console\Input\InputOption; | ||
use Illuminate\Foundation\Console\ObserverMakeCommand; | ||
|
||
class ObserverCommand extends ObserverMakeCommand | ||
{ | ||
/** | ||
* The console command name. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'domain:observer'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Create a new observer class for a given domain'; | ||
|
||
/** | ||
* Get the default namespace for the class. | ||
* | ||
* @param string $rootNamespace | ||
* @return string | ||
*/ | ||
protected function getDefaultNamespace($rootNamespace) | ||
{ | ||
if ($domain = $this->option('domain')) { | ||
return "{$rootNamespace}\\{$domain}\\Observers"; | ||
} | ||
|
||
$defaultNamespace = config('domain-commands.default_namespace'); | ||
|
||
return "{$rootNamespace}\\{$defaultNamespace}\\Observers"; | ||
} | ||
|
||
/** | ||
* Get the destination class path. | ||
* | ||
* @param string $name | ||
* @return string | ||
*/ | ||
protected function getPath($name) | ||
{ | ||
return $this->laravel->basePath().'/app/'.str_replace('\\', '/', $name).'.php'; | ||
} | ||
|
||
/** | ||
* Get the stub file for the generator. | ||
* | ||
* @return string | ||
*/ | ||
protected function getStub() | ||
{ | ||
$stubPath = config('domain-commands.stubs.rule'); | ||
|
||
if (! is_null($stubPath) && is_string($stubPath)) { | ||
return $stubPath; | ||
} | ||
|
||
return parent::getStub(); | ||
} | ||
|
||
/** | ||
* Get the root namespace for the class. | ||
* | ||
* @return string | ||
*/ | ||
protected function rootNamespace() | ||
{ | ||
return 'Domain\\'; | ||
} | ||
|
||
/** | ||
* Get the console command options. | ||
* | ||
* @return array | ||
*/ | ||
protected function getOptions() | ||
{ | ||
return array_merge(parent::getOptions(), [ | ||
['domain', 'd', InputOption::VALUE_OPTIONAL, 'Set the domain of the model'], | ||
]); | ||
} | ||
} |
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,89 @@ | ||
<?php | ||
|
||
namespace Signifly\Console\Commands; | ||
|
||
use Symfony\Component\Console\Input\InputOption; | ||
use Illuminate\Foundation\Console\RuleMakeCommand; | ||
|
||
class RuleCommand extends RuleMakeCommand | ||
{ | ||
/** | ||
* The console command name. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'domain:rule'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Create a new validation rule for a given domain'; | ||
|
||
/** | ||
* Get the default namespace for the class. | ||
* | ||
* @param string $rootNamespace | ||
* @return string | ||
*/ | ||
protected function getDefaultNamespace($rootNamespace) | ||
{ | ||
if ($domain = $this->option('domain')) { | ||
return "{$rootNamespace}\\{$domain}\\Rules"; | ||
} | ||
|
||
$defaultNamespace = config('domain-commands.default_namespace'); | ||
|
||
return "{$rootNamespace}\\{$defaultNamespace}\\Rules"; | ||
} | ||
|
||
/** | ||
* Get the destination class path. | ||
* | ||
* @param string $name | ||
* @return string | ||
*/ | ||
protected function getPath($name) | ||
{ | ||
return $this->laravel->basePath().'/app/'.str_replace('\\', '/', $name).'.php'; | ||
} | ||
|
||
/** | ||
* Get the stub file for the generator. | ||
* | ||
* @return string | ||
*/ | ||
protected function getStub() | ||
{ | ||
$stubPath = config('domain-commands.stubs.rule'); | ||
|
||
if (! is_null($stubPath) && is_string($stubPath)) { | ||
return $stubPath; | ||
} | ||
|
||
return parent::getStub(); | ||
} | ||
|
||
/** | ||
* Get the root namespace for the class. | ||
* | ||
* @return string | ||
*/ | ||
protected function rootNamespace() | ||
{ | ||
return 'Domain\\'; | ||
} | ||
|
||
/** | ||
* Get the console command options. | ||
* | ||
* @return array | ||
*/ | ||
protected function getOptions() | ||
{ | ||
return array_merge(parent::getOptions(), [ | ||
['domain', 'd', InputOption::VALUE_OPTIONAL, 'Set the domain of the model'], | ||
]); | ||
} | ||
} |
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