feat: config
This commit is contained in:
35
app/Command/EventCommand.php
Normal file
35
app/Command/EventCommand.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\Devtool\Generator\GeneratorCommand;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
#[Command]
|
||||
class EventCommand extends GeneratorCommand
|
||||
{
|
||||
public function __construct(protected ContainerInterface $container)
|
||||
{
|
||||
parent::__construct('gen:event');
|
||||
}
|
||||
|
||||
public function configure()
|
||||
{
|
||||
$this->setDescription('Create a new event class');
|
||||
|
||||
parent::configure();
|
||||
}
|
||||
|
||||
protected function getStub(): string
|
||||
{
|
||||
return __DIR__ . '/stubs/event.stub';
|
||||
}
|
||||
|
||||
protected function getDefaultNamespace(): string
|
||||
{
|
||||
return 'App\\Event';
|
||||
}
|
||||
}
|
||||
15
app/Command/stubs/event.stub
Normal file
15
app/Command/stubs/event.stub
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace %NAMESPACE%;
|
||||
|
||||
class %CLASS%
|
||||
{
|
||||
public $xxx;
|
||||
|
||||
public function __construct($xxx)
|
||||
{
|
||||
$this->xxx = $xxx;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user