Skeleton is ready
This commit is contained in:
15
app/Kernel/Feature/HasCommandsList.php
Normal file
15
app/Kernel/Feature/HasCommandsList.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Kernel\Feature;
|
||||
|
||||
trait HasCommandsList
|
||||
{
|
||||
public function registerCommands(): void
|
||||
{
|
||||
if (isset($this->commandsList) && method_exists($this, 'commands')) {
|
||||
$this->commands($this->commandsList);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
app/Kernel/Feature/HasEventListeners.php
Normal file
25
app/Kernel/Feature/HasEventListeners.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Kernel\Feature;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
trait HasEventListeners
|
||||
{
|
||||
public function registerListeners(): void
|
||||
{
|
||||
if (isset($this->eventListeners)) {
|
||||
/**
|
||||
* @var string $event
|
||||
* @var array<int,string> $listeners
|
||||
*/
|
||||
foreach ($this->eventListeners as $event => $listeners) {
|
||||
foreach ($listeners as $listener) {
|
||||
Event::listen($event, $listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user