-
Notifications
You must be signed in to change notification settings - Fork 3
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
19 changed files
with
542 additions
and
68 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
app | ||
composer.lock | ||
vendor | ||
*.php_cs.cache |
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
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
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,114 @@ | ||
<?php | ||
|
||
namespace Hariadi\Boilerplate\Commands; | ||
|
||
class AppEventCreatedCommand extends AppGeneratorCommand | ||
{ | ||
/** | ||
* The type of class being generated. | ||
* | ||
* @var string | ||
*/ | ||
protected $type = 'Created'; | ||
|
||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'event:created | ||
{name : The name of the class} | ||
{--E|event=* : Default created event}'; | ||
|
||
/** | ||
* Default events | ||
* | ||
* @var array | ||
*/ | ||
protected $events = ['created', 'updated', 'deleted']; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Create a new created event for model'; | ||
|
||
/** | ||
* The methods available. | ||
* | ||
* @var array | ||
*/ | ||
protected function getMethods() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* Get the stub file for the generator. | ||
* | ||
* @return string | ||
*/ | ||
protected function getStub() | ||
{ | ||
return __DIR__.'/stubs/event.stub'; | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
$events = $this->option('event'); | ||
|
||
if (empty($events)) { | ||
$events = $this->events; | ||
} | ||
|
||
if (parent::handle() !== false) { | ||
if (in_array('updated', $events)) { | ||
$this->call('event:updated', [ | ||
'name' => $this->argument('name'), | ||
]); | ||
} | ||
|
||
if (in_array('deleted', $events)) { | ||
$this->call('event:deleted', [ | ||
'name' => $this->argument('name'), | ||
]); | ||
} | ||
|
||
|
||
$this->call('app:listener', [ | ||
'name' => $this->argument('name') | ||
]); | ||
|
||
$this->info('You need to subscribe the listener to your EventServiceProvider manually'); | ||
} | ||
} | ||
|
||
/** | ||
* Get the intended name for class. | ||
* | ||
* @return string | ||
*/ | ||
protected function getClassName() | ||
{ | ||
return basename($this->getNameInput()) . $this->type; | ||
} | ||
|
||
/** | ||
* Get the default namespace for the class. | ||
* | ||
* @param string $rootNamespace | ||
* @return string | ||
*/ | ||
protected function getDefaultNamespace($rootNamespace) | ||
{ | ||
$namespace = $this->argument('name'); | ||
|
||
return $rootNamespace . '\Events\Backend' . '\\' . $namespace; | ||
} | ||
} |
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,80 @@ | ||
<?php | ||
|
||
namespace Hariadi\Boilerplate\Commands; | ||
|
||
class AppEventDeletedCommand extends AppGeneratorCommand | ||
{ | ||
/** | ||
* The type of class being generated. | ||
* | ||
* @var string | ||
*/ | ||
protected $type = 'Deleted'; | ||
|
||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'event:deleted {name : The name of the class}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Create a new deleted event for model'; | ||
|
||
/** | ||
* The methods available. | ||
* | ||
* @var array | ||
*/ | ||
protected function getMethods() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* Get the stub file for the generator. | ||
* | ||
* @return string | ||
*/ | ||
protected function getStub() | ||
{ | ||
return __DIR__.'/stubs/event.stub'; | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
parent::handle(); | ||
} | ||
|
||
/** | ||
* Get the intended name for class. | ||
* | ||
* @return string | ||
*/ | ||
protected function getClassName() | ||
{ | ||
return basename($this->getNameInput()) . $this->type; | ||
} | ||
|
||
/** | ||
* Get the default namespace for the class. | ||
* | ||
* @param string $rootNamespace | ||
* @return string | ||
*/ | ||
protected function getDefaultNamespace($rootNamespace) | ||
{ | ||
$namespace = $this->argument('name'); | ||
|
||
return $rootNamespace . '\Events\Backend' . '\\' . $namespace; | ||
} | ||
} |
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,88 @@ | ||
<?php | ||
|
||
namespace Hariadi\Boilerplate\Commands; | ||
|
||
class AppEventListenerCommand extends AppGeneratorCommand | ||
{ | ||
/** | ||
* The type of class being generated. | ||
* | ||
* @var string | ||
*/ | ||
protected $type = 'EventListener'; | ||
|
||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'app:listener {name : The name of the class}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Create a new event listener for model'; | ||
|
||
/** | ||
* The methods available. | ||
* | ||
* @var array | ||
*/ | ||
protected function getMethods() | ||
{ | ||
return ['created', 'updated', 'deleted']; | ||
} | ||
|
||
/** | ||
* Get the stub file for the generator. | ||
* | ||
* @return string | ||
*/ | ||
protected function getStub() | ||
{ | ||
return __DIR__.'/stubs/listener.stub'; | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
// $event = $this->option('event'); | ||
|
||
// if ($event != 'created') { | ||
// $this->methods = [$event]; | ||
// } | ||
|
||
// dd($this->methods); | ||
|
||
parent::handle(); | ||
} | ||
|
||
/** | ||
* Get the intended name for class. | ||
* | ||
* @return string | ||
*/ | ||
protected function getClassName() | ||
{ | ||
return basename($this->getNameInput()) . $this->type; | ||
} | ||
|
||
/** | ||
* Get the default namespace for the class. | ||
* | ||
* @param string $rootNamespace | ||
* @return string | ||
*/ | ||
protected function getDefaultNamespace($rootNamespace) | ||
{ | ||
$namespace = $this->argument('name'); | ||
|
||
return $rootNamespace . '\Listeners\Backend' . '\\' . $namespace; | ||
} | ||
} |
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,80 @@ | ||
<?php | ||
|
||
namespace Hariadi\Boilerplate\Commands; | ||
|
||
class AppEventUpdatedCommand extends AppGeneratorCommand | ||
{ | ||
/** | ||
* The type of class being generated. | ||
* | ||
* @var string | ||
*/ | ||
protected $type = 'Updated'; | ||
|
||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'event:updated {name : The name of the class}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Create a new updated event for model'; | ||
|
||
/** | ||
* The methods available. | ||
* | ||
* @var array | ||
*/ | ||
protected function getMethods() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* Get the stub file for the generator. | ||
* | ||
* @return string | ||
*/ | ||
protected function getStub() | ||
{ | ||
return __DIR__.'/stubs/event.stub'; | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
parent::handle(); | ||
} | ||
|
||
/** | ||
* Get the intended name for class. | ||
* | ||
* @return string | ||
*/ | ||
protected function getClassName() | ||
{ | ||
return basename($this->getNameInput()) . $this->type; | ||
} | ||
|
||
/** | ||
* Get the default namespace for the class. | ||
* | ||
* @param string $rootNamespace | ||
* @return string | ||
*/ | ||
protected function getDefaultNamespace($rootNamespace) | ||
{ | ||
$namespace = $this->argument('name'); | ||
|
||
return $rootNamespace . '\Events\Backend' . '\\' . $namespace; | ||
} | ||
} |
Oops, something went wrong.