Skip to content

Commit

Permalink
chore: the body of generated classes (Controllers) is validated
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleon4 committed Nov 18, 2024
1 parent d8a09fb commit daf3457
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/LionBundle/Commands/Lion/DB/CrudCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Lion\Command\Command;
use Lion\Database\Connection;
use Lion\Database\Driver;
use LogicException;
use Symfony\Component\Console\Exception\ExceptionInterface;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -113,9 +115,10 @@ protected function configure(): void
* @param OutputInterface $output [OutputInterface is the interface
* implemented by all Output classes]
*
* @return int [0 if everything went fine, or an exit code]
* @return int
*
* @throws LogicException [When this abstract method is not implemented]
* @throws LogicException|ExceptionInterface [When this abstract method is
* not implemented]
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
Expand Down Expand Up @@ -171,6 +174,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
* implemented by all Output classes]
*
* @return void
*
* @throws ExceptionInterface
*/
private function addDBRules(string $entity, OutputInterface $output): void
{
Expand All @@ -197,6 +202,8 @@ private function addDBRules(string $entity, OutputInterface $output): void
* implemented by all Output classes]
*
* @return void
*
* @throws ExceptionInterface
*/
private function addControllerAndModel(
string $driver,
Expand Down
10 changes: 7 additions & 3 deletions src/LionBundle/Commands/Lion/New/ControllerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Lion\Command\Command;
use Lion\Files\Store;
use Lion\Helpers\Str;
use LogicException;
use Symfony\Component\Console\Exception\ExceptionInterface;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -110,9 +112,10 @@ protected function configure(): void
* @param OutputInterface $output [OutputInterface is the interface
* implemented by all Output classes]
*
* @return int 0 if everything went fine, or an exit code
* @return int
*
* @throws LogicException When this abstract method is not implemented
* @throws LogicException [When this abstract method is not implemented]
* @throws ExceptionInterface
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
Expand Down Expand Up @@ -165,12 +168,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
);

if ('none' != $model) {
$factoryController->add("\nuse {$dataModel->namespace}\\{$dataModel->class};\n");
$factoryController->add("\nuse {$dataModel->namespace}\\{$dataModel->class};");
}

$factoryController
->add(
<<<EOT
use Lion\Database\Interface\DatabaseCapsuleInterface;
use stdClass;
Expand Down

0 comments on commit daf3457

Please sign in to comment.