First Commit

This commit is contained in:
marco
2026-09-01 10:46:29 -03:00
commit bf96b77e9c
10000 changed files with 3508600 additions and 0 deletions
+92
View File
@@ -0,0 +1,92 @@
<?php
namespace App\Console\Commands;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ModuleMakeProviderCommand extends Command
{
protected static $defaultName = 'module:make-provider';
protected static $defaultDescription = 'Cria um novo Service Provider para um módulo específico';
protected function configure(): void
{
$this
->addArgument('module', InputArgument::REQUIRED, 'O nome do módulo')
->addArgument('name', InputArgument::REQUIRED, 'O nome do Service Provider (ex: EventServiceProvider)');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$moduleName = $input->getArgument('module');
$name = $input->getArgument('name');
if (!str_ends_with($name, 'ServiceProvider')) {
$name .= 'ServiceProvider';
}
$modulePath = dirname(__DIR__, 3) . '/modules/' . $moduleName;
$directory = $modulePath . '/Providers';
$filePath = $directory . '/' . $name . '.php';
if (!is_dir($modulePath)) {
$output->writeln("<error>Módulo '{$moduleName}' não encontrado.</error>");
return Command::FAILURE;
}
if (file_exists($filePath)) {
$output->writeln("<error>O Service Provider '{$name}' já existe!</error>");
return Command::FAILURE;
}
if (!is_dir($directory)) {
mkdir($directory, 0755, true);
}
$year = date('Y');
$moduleNamespace = "Modules\\" . ucfirst($moduleName);
$template = <<<PHP
<?php
/**
* SysCMS - Content Management System
*
* Copyright (c) {$year} Marco Costa
* All rights reserved.
*/
namespace {$moduleNamespace}\Providers;
class {$name}
{
/**
* Register the service provider.
*/
public function register()
{
// Register services in the container
}
/**
* Boot the service provider.
*/
public function boot()
{
// Boot logic
}
}
PHP;
if (file_put_contents($filePath, $template)) {
$output->writeln("<info>Service Provider '{$name}' criado com sucesso em modules/{$moduleName}/Providers/</info>");
$output->writeln("<comment>Lembre-se de registrar o provider no arquivo module.json se necessário.</comment>");
return Command::SUCCESS;
} else {
$output->writeln("<error>Falha ao criar o arquivo do Service Provider.</error>");
return Command::FAILURE;
}
}
}