Skip to content

Feature/command rework #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 0 additions & 77 deletions src/Console/Commands/ActionCommand.php

This file was deleted.

67 changes: 67 additions & 0 deletions src/Console/Commands/ActionMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

namespace Lomkit\Rest\Console\Commands;

use Illuminate\Console\GeneratorCommand;
use Symfony\Component\Console\Attribute\AsCommand;

#[AsCommand(name: 'rest:action')]
class ActionMakeCommand extends GeneratorCommand
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'rest:action';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new action class';

/**
* The type of class being generated.
*
* @var string
*/
protected $type = 'Action';

/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub(): string
{
return $this->resolveStubPath('/../stubs/action.stub');
}

/**
* Resolve the fully-qualified path to the stub.
*
* @param string $stub
*
* @return string
*/
protected function resolveStubPath($stub): string
{
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
? $customPath
: __DIR__.$stub;
}

/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
*
* @return string
*/
protected function getDefaultNamespace($rootNamespace): string
{
return $rootNamespace.'\Rest\Actions';
}
}
89 changes: 0 additions & 89 deletions src/Console/Commands/BaseControllerCommand.php

This file was deleted.

74 changes: 74 additions & 0 deletions src/Console/Commands/BaseControllerMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace Lomkit\Rest\Console\Commands;

use Illuminate\Console\GeneratorCommand;
use Symfony\Component\Console\Attribute\AsCommand;

#[AsCommand(name: 'rest:base-controller')]
class BaseControllerMakeCommand extends GeneratorCommand
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'rest:base-controller';

/**
* Indicates whether the command should be shown in the Artisan command list.
*
* @var bool
*/
protected $hidden = true;

/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new base controller class';

/**
* The type of class being generated.
*
* @var string
*/
protected $type = 'Base Controller';

/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub(): string
{
return $this->resolveStubPath('/../stubs/base-controller.stub');
}

/**
* Resolve the fully-qualified path to the stub.
*
* @param string $stub
*
* @return string
*/
protected function resolveStubPath(string $stub): string
{
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
? $customPath
: __DIR__.$stub;
}

/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
*
* @return string
*/
protected function getDefaultNamespace($rootNamespace): string
{
return $rootNamespace.'\Rest\Controllers';
}
}
79 changes: 0 additions & 79 deletions src/Console/Commands/BaseResourceCommand.php

This file was deleted.

Loading