File tree Expand file tree Collapse file tree 1 file changed +69
-0
lines changed Expand file tree Collapse file tree 1 file changed +69
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Coderflex \LaravelPresenter \Console ;
4+
5+ use Illuminate \Console \GeneratorCommand ;
6+
7+ class PresenterMakeCommand extends GeneratorCommand
8+ {
9+ public $ name = 'presenter:make ' ;
10+
11+ public $ description = '(Deprecated) Create a new presenter class ' ;
12+
13+ /**
14+ * The type of class being generated.
15+ *
16+ * @var string
17+ */
18+ protected $ type = 'Presenter ' ;
19+
20+ /**
21+ * Determine if the class already exists.
22+ *
23+ * @param string $rawName
24+ * @return bool
25+ */
26+ protected function alreadyExists ($ rawName )
27+ {
28+ return class_exists ($ rawName ) ||
29+ $ this ->files ->exists ($ this ->getPath ($ this ->qualifyClass ($ rawName )));
30+ }
31+
32+ /**
33+ * Get the stub file for the generator.
34+ *
35+ * @return string
36+ */
37+ protected function getStub ()
38+ {
39+ return $ this ->resolveStubPath ('/stubs/presenter.stub ' );
40+ }
41+
42+ /**
43+ * Resolve the fully-qualified path to the stub.
44+ *
45+ * @param string $stub
46+ * @return string
47+ */
48+ protected function resolveStubPath ($ stub )
49+ {
50+ return file_exists ($ customPath = $ this ->laravel ->basePath (trim ($ stub , '/ ' )))
51+ ? $ customPath
52+ : __DIR__ . $ stub ;
53+ }
54+
55+ /**
56+ * Get the default namespace for the class.
57+ *
58+ * @param string $rootNamespace
59+ * @return string
60+ */
61+ protected function getDefaultNamespace ($ rootNamespace )
62+ {
63+ $ configNamespace = config ('laravel-presenter.presenter_namespace ' );
64+
65+ return is_null ($ configNamespace )
66+ ? $ rootNamespace . '\Presenters '
67+ : $ configNamespace ;
68+ }
69+ }
You can’t perform that action at this time.
0 commit comments