Skip to content
This repository was archived by the owner on Apr 29, 2020. It is now read-only.

Commit 61dd437

Browse files
Added missing classes for Laravel 5.5 make commands support
1 parent 37d964a commit 61dd437

File tree

5 files changed

+150
-0
lines changed

5 files changed

+150
-0
lines changed

config/laravel-file-generator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
'console' => '\Console\Commands',
5454
'controller' => '\Http\Controllers',
5555
'event' => '\Events',
56+
'exception' => '\Exceptions',
5657
'job' => '\Jobs',
5758
'listener' => '\Listeners',
5859
'mail' => '\Mail',
@@ -63,6 +64,7 @@
6364
'policy' => '\Policies',
6465
'provider' => '\Providers',
6566
'request' => '\Http\Requests',
67+
'rules' => '\Rules',
6668
'seeder' => '',
6769
'test' => ''
6870
],
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace FerdinandFrank\LaravelFileGenerator\Console;
4+
5+
use FerdinandFrank\LaravelFileGenerator\StubHelper;
6+
7+
/**
8+
* ExceptionMakeCommand
9+
* -----------------------
10+
* Command to create a new exception class.
11+
*
12+
* @author Ferdinand Frank
13+
* @version 1.0
14+
* @package FerdinandFrank\LaravelFileGenerator\Console
15+
*/
16+
class ExceptionMakeCommand extends \Illuminate\Foundation\Console\ExceptionMakeCommand {
17+
18+
/**
19+
* Get the stub file for the generator.
20+
*
21+
* @return string
22+
*/
23+
protected function getStub() {
24+
if ($this->option('render')) {
25+
return $this->option('report')
26+
? StubHelper::find('/exception-render-report.stub')
27+
: StubHelper::find('/exception-render.stub');
28+
}
29+
30+
return $this->option('report')
31+
? StubHelper::find('/exception-report.stub')
32+
: StubHelper::find('/exception.stub');
33+
}
34+
35+
/**
36+
* Get the default namespace for the class.
37+
*
38+
* @param string $rootNamespace
39+
*
40+
* @return string
41+
*/
42+
protected function getDefaultNamespace($rootNamespace) {
43+
$namespace = config('laravel-file-generator.namespaces.exception');
44+
45+
return $namespace ? $rootNamespace . $namespace : parent::getDefaultNamespace($rootNamespace);
46+
}
47+
}

src/Console/FactoryMakeCommand.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace FerdinandFrank\LaravelFileGenerator\Console;
4+
5+
use FerdinandFrank\LaravelFileGenerator\StubHelper;
6+
7+
/**
8+
* FactoryMakeCommand
9+
* -----------------------
10+
* Command to create a new exception class.
11+
*
12+
* @author Ferdinand Frank
13+
* @version 1.0
14+
* @package FerdinandFrank\LaravelFileGenerator\Console
15+
*/
16+
class FactoryMakeCommand extends \Illuminate\Database\Console\Factories\FactoryMakeCommand {
17+
18+
/**
19+
* Get the stub file for the generator.
20+
*
21+
* @return string
22+
*/
23+
protected function getStub() {
24+
return StubHelper::find('/factory.stub');
25+
}
26+
}

src/Console/RuleMakeCommand.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace FerdinandFrank\LaravelFileGenerator\Console;
4+
5+
use FerdinandFrank\LaravelFileGenerator\StubHelper;
6+
7+
/**
8+
* RuleMakeCommand
9+
* -----------------------
10+
* Command to create a new rule class.
11+
*
12+
* @author Ferdinand Frank
13+
* @version 1.0
14+
* @package FerdinandFrank\LaravelFileGenerator\Console
15+
*/
16+
class RuleMakeCommand extends \Illuminate\Foundation\Console\RuleMakeCommand {
17+
18+
/**
19+
* Get the stub file for the generator.
20+
*
21+
* @return string
22+
*/
23+
protected function getStub() {
24+
return StubHelper::find('/rule.stub');
25+
}
26+
27+
/**
28+
* Get the default namespace for the class.
29+
*
30+
* @param string $rootNamespace
31+
*
32+
* @return string
33+
*/
34+
protected function getDefaultNamespace($rootNamespace) {
35+
$namespace = config('laravel-file-generator.namespaces.rules');
36+
37+
return $namespace ? $rootNamespace . $namespace : parent::getDefaultNamespace($rootNamespace);
38+
}
39+
}

src/Providers/ArtisanServiceProvider.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use FerdinandFrank\LaravelFileGenerator\Console\ApiResourceMakeCommand;
66
use FerdinandFrank\LaravelFileGenerator\Console\ControllerMakeCommand;
77
use FerdinandFrank\LaravelFileGenerator\Console\EventGenerateCommand;
8+
use FerdinandFrank\LaravelFileGenerator\Console\ExceptionMakeCommand;
9+
use FerdinandFrank\LaravelFileGenerator\Console\FactoryMakeCommand;
810
use FerdinandFrank\LaravelFileGenerator\Console\ObserverMakeCommand;
911
use FerdinandFrank\LaravelFileGenerator\Console\PolicyMakeCommand;
1012
use FerdinandFrank\LaravelFileGenerator\Console\ConsoleMakeCommand;
@@ -18,6 +20,7 @@
1820
use FerdinandFrank\LaravelFileGenerator\Console\ProviderMakeCommand;
1921
use FerdinandFrank\LaravelFileGenerator\Console\RequestMakeCommand;
2022
use FerdinandFrank\LaravelFileGenerator\Console\ResourceMakeCommand;
23+
use FerdinandFrank\LaravelFileGenerator\Console\RuleMakeCommand;
2124
use FerdinandFrank\LaravelFileGenerator\Console\SeederMakeCommand;
2225
use FerdinandFrank\LaravelFileGenerator\Console\TestMakeCommand;
2326
use Illuminate\Database\Console\Migrations\MigrateMakeCommand;
@@ -138,6 +141,28 @@ protected function registerEventMakeCommand() {
138141
});
139142
}
140143

144+
/**
145+
* Register the command.
146+
*
147+
* @return void
148+
*/
149+
protected function registerExceptionMakeCommand() {
150+
$this->app->singleton('command.exception.make', function ($app) {
151+
return new ExceptionMakeCommand($app['files']);
152+
});
153+
}
154+
155+
/**
156+
* Register the command.
157+
*
158+
* @return void
159+
*/
160+
protected function registerFactoryMakeCommand() {
161+
$this->app->singleton('command.factory.make', function ($app) {
162+
return new FactoryMakeCommand($app['files']);
163+
});
164+
}
165+
141166
/**
142167
* Register the command.
143168
*
@@ -255,6 +280,17 @@ protected function registerRequestMakeCommand() {
255280
});
256281
}
257282

283+
/**
284+
* Register the command.
285+
*
286+
* @return void
287+
*/
288+
protected function registerRuleMakeCommand() {
289+
$this->app->singleton('command.rule.make', function ($app) {
290+
return new RuleMakeCommand($app['files']);
291+
});
292+
}
293+
258294
/**
259295
* Register the command.
260296
*

0 commit comments

Comments
 (0)