Skip to content

Commit cb8262b

Browse files
Feature/command rework (#173)
--------- Co-authored-by: Lucas GOSGNACH <[email protected]>
1 parent 88b1458 commit cb8262b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1152
-1060
lines changed

src/Console/Commands/ActionCommand.php

Lines changed: 0 additions & 77 deletions
This file was deleted.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
namespace Lomkit\Rest\Console\Commands;
4+
5+
use Illuminate\Console\GeneratorCommand;
6+
use Symfony\Component\Console\Attribute\AsCommand;
7+
8+
#[AsCommand(name: 'rest:action')]
9+
class ActionMakeCommand extends GeneratorCommand
10+
{
11+
/**
12+
* The console command name.
13+
*
14+
* @var string
15+
*/
16+
protected $name = 'rest:action';
17+
18+
/**
19+
* The console command description.
20+
*
21+
* @var string
22+
*/
23+
protected $description = 'Create a new action class';
24+
25+
/**
26+
* The type of class being generated.
27+
*
28+
* @var string
29+
*/
30+
protected $type = 'Action';
31+
32+
/**
33+
* Get the stub file for the generator.
34+
*
35+
* @return string
36+
*/
37+
protected function getStub(): string
38+
{
39+
return $this->resolveStubPath('/../stubs/action.stub');
40+
}
41+
42+
/**
43+
* Resolve the fully-qualified path to the stub.
44+
*
45+
* @param string $stub
46+
*
47+
* @return string
48+
*/
49+
protected function resolveStubPath($stub): string
50+
{
51+
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
52+
? $customPath
53+
: __DIR__.$stub;
54+
}
55+
56+
/**
57+
* Get the default namespace for the class.
58+
*
59+
* @param string $rootNamespace
60+
*
61+
* @return string
62+
*/
63+
protected function getDefaultNamespace($rootNamespace): string
64+
{
65+
return $rootNamespace.'\Rest\Actions';
66+
}
67+
}

src/Console/Commands/BaseControllerCommand.php

Lines changed: 0 additions & 89 deletions
This file was deleted.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
namespace Lomkit\Rest\Console\Commands;
4+
5+
use Illuminate\Console\GeneratorCommand;
6+
use Symfony\Component\Console\Attribute\AsCommand;
7+
8+
#[AsCommand(name: 'rest:base-controller')]
9+
class BaseControllerMakeCommand extends GeneratorCommand
10+
{
11+
/**
12+
* The console command name.
13+
*
14+
* @var string
15+
*/
16+
protected $name = 'rest:base-controller';
17+
18+
/**
19+
* Indicates whether the command should be shown in the Artisan command list.
20+
*
21+
* @var bool
22+
*/
23+
protected $hidden = true;
24+
25+
/**
26+
* The console command description.
27+
*
28+
* @var string
29+
*/
30+
protected $description = 'Create a new base controller class';
31+
32+
/**
33+
* The type of class being generated.
34+
*
35+
* @var string
36+
*/
37+
protected $type = 'Base Controller';
38+
39+
/**
40+
* Get the stub file for the generator.
41+
*
42+
* @return string
43+
*/
44+
protected function getStub(): string
45+
{
46+
return $this->resolveStubPath('/../stubs/base-controller.stub');
47+
}
48+
49+
/**
50+
* Resolve the fully-qualified path to the stub.
51+
*
52+
* @param string $stub
53+
*
54+
* @return string
55+
*/
56+
protected function resolveStubPath(string $stub): string
57+
{
58+
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
59+
? $customPath
60+
: __DIR__.$stub;
61+
}
62+
63+
/**
64+
* Get the default namespace for the class.
65+
*
66+
* @param string $rootNamespace
67+
*
68+
* @return string
69+
*/
70+
protected function getDefaultNamespace($rootNamespace): string
71+
{
72+
return $rootNamespace.'\Rest\Controllers';
73+
}
74+
}

src/Console/Commands/BaseResourceCommand.php

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)