@@ 13-85 (lines=73) @@ | ||
10 | * @author PyroCMS, Inc. <[email protected]> |
|
11 | * @author Ryan Thompson <[email protected]> |
|
12 | */ |
|
13 | class WriteAddonClass |
|
14 | { |
|
15 | ||
16 | /** |
|
17 | * The addon path. |
|
18 | * |
|
19 | * @var string |
|
20 | */ |
|
21 | private $path; |
|
22 | ||
23 | /** |
|
24 | * The addon type. |
|
25 | * |
|
26 | * @var string |
|
27 | */ |
|
28 | private $type; |
|
29 | ||
30 | /** |
|
31 | * The addon slug. |
|
32 | * |
|
33 | * @var string |
|
34 | */ |
|
35 | private $slug; |
|
36 | ||
37 | /** |
|
38 | * The vendor slug. |
|
39 | * |
|
40 | * @var string |
|
41 | */ |
|
42 | private $vendor; |
|
43 | ||
44 | /** |
|
45 | * Create a new WriteAddonClass instance. |
|
46 | * |
|
47 | * @param $path |
|
48 | * @param $type |
|
49 | * @param $slug |
|
50 | * @param $vendor |
|
51 | */ |
|
52 | public function __construct($path, $type, $slug, $vendor) |
|
53 | { |
|
54 | $this->path = $path; |
|
55 | $this->slug = $slug; |
|
56 | $this->type = $type; |
|
57 | $this->vendor = $vendor; |
|
58 | } |
|
59 | ||
60 | /** |
|
61 | * Handle the command. |
|
62 | * |
|
63 | * @param Parser $parser |
|
64 | * @param Filesystem $filesystem |
|
65 | */ |
|
66 | public function handle(Parser $parser, Filesystem $filesystem) |
|
67 | { |
|
68 | $slug = ucfirst(camel_case($this->slug)); |
|
69 | $type = ucfirst(camel_case($this->type)); |
|
70 | $vendor = ucfirst(camel_case($this->vendor)); |
|
71 | ||
72 | $addon = $slug . $type; |
|
73 | $namespace = "{$vendor}\\{$addon}"; |
|
74 | ||
75 | $path = "{$this->path}/src/{$addon}.php"; |
|
76 | ||
77 | $template = $filesystem->get( |
|
78 | base_path("vendor/anomaly/streams-platform/resources/stubs/addons/{$this->type}.stub") |
|
79 | ); |
|
80 | ||
81 | $filesystem->makeDirectory(dirname($path), 0755, true, true); |
|
82 | ||
83 | $filesystem->put($path, $parser->parse($template, compact('namespace', 'addon'))); |
|
84 | } |
|
85 | } |
|
86 |
@@ 13-86 (lines=74) @@ | ||
10 | * @author PyroCMS, Inc. <[email protected]> |
|
11 | * @author Ryan Thompson <[email protected]> |
|
12 | */ |
|
13 | class WriteAddonServiceProvider |
|
14 | { |
|
15 | ||
16 | /** |
|
17 | * The addon path. |
|
18 | * |
|
19 | * @var string |
|
20 | */ |
|
21 | private $path; |
|
22 | ||
23 | /** |
|
24 | * The addon type. |
|
25 | * |
|
26 | * @var string |
|
27 | */ |
|
28 | private $type; |
|
29 | ||
30 | /** |
|
31 | * The addon slug. |
|
32 | * |
|
33 | * @var string |
|
34 | */ |
|
35 | private $slug; |
|
36 | ||
37 | /** |
|
38 | * The vendor slug. |
|
39 | * |
|
40 | * @var string |
|
41 | */ |
|
42 | private $vendor; |
|
43 | ||
44 | /** |
|
45 | * Create a new WriteAddonServiceProvider instance. |
|
46 | * |
|
47 | * @param $path |
|
48 | * @param $type |
|
49 | * @param $slug |
|
50 | * @param $vendor |
|
51 | */ |
|
52 | public function __construct($path, $type, $slug, $vendor) |
|
53 | { |
|
54 | $this->path = $path; |
|
55 | $this->slug = $slug; |
|
56 | $this->type = $type; |
|
57 | $this->vendor = $vendor; |
|
58 | } |
|
59 | ||
60 | /** |
|
61 | * Handle the command. |
|
62 | * |
|
63 | * @param Parser $parser |
|
64 | * @param Filesystem $filesystem |
|
65 | */ |
|
66 | public function handle(Parser $parser, Filesystem $filesystem) |
|
67 | { |
|
68 | $slug = ucfirst(camel_case($this->slug)); |
|
69 | $type = ucfirst(camel_case($this->type)); |
|
70 | $vendor = ucfirst(camel_case($this->vendor)); |
|
71 | ||
72 | $addon = $slug . $type; |
|
73 | $provider = $addon . 'ServiceProvider'; |
|
74 | $namespace = "{$vendor}\\{$addon}"; |
|
75 | ||
76 | $path = "{$this->path}/src/{$provider}.php"; |
|
77 | ||
78 | $template = $filesystem->get( |
|
79 | base_path('vendor/anomaly/streams-platform/resources/stubs/addons/provider.stub') |
|
80 | ); |
|
81 | ||
82 | $filesystem->makeDirectory(dirname($path), 0755, true, true); |
|
83 | ||
84 | $filesystem->put($path, $parser->parse($template, compact('namespace', 'provider'))); |
|
85 | } |
|
86 | } |
|
87 |
@@ 13-86 (lines=74) @@ | ||
10 | * @author PyroCMS, Inc. <[email protected]> |
|
11 | * @author Ryan Thompson <[email protected]> |
|
12 | */ |
|
13 | class WriteAddonTestCase |
|
14 | { |
|
15 | ||
16 | /** |
|
17 | * The addon path. |
|
18 | * |
|
19 | * @var string |
|
20 | */ |
|
21 | private $path; |
|
22 | ||
23 | /** |
|
24 | * The addon type. |
|
25 | * |
|
26 | * @var string |
|
27 | */ |
|
28 | private $type; |
|
29 | ||
30 | /** |
|
31 | * The addon slug. |
|
32 | * |
|
33 | * @var string |
|
34 | */ |
|
35 | private $slug; |
|
36 | ||
37 | /** |
|
38 | * The vendor slug. |
|
39 | * |
|
40 | * @var string |
|
41 | */ |
|
42 | private $vendor; |
|
43 | ||
44 | /** |
|
45 | * Create a new WriteAddonTestCase instance. |
|
46 | * |
|
47 | * @param $path |
|
48 | * @param $type |
|
49 | * @param $slug |
|
50 | * @param $vendor |
|
51 | */ |
|
52 | public function __construct($path, $type, $slug, $vendor) |
|
53 | { |
|
54 | $this->path = $path; |
|
55 | $this->slug = $slug; |
|
56 | $this->type = $type; |
|
57 | $this->vendor = $vendor; |
|
58 | } |
|
59 | ||
60 | /** |
|
61 | * Handle the command. |
|
62 | * |
|
63 | * @param Parser $parser |
|
64 | * @param Filesystem $filesystem |
|
65 | */ |
|
66 | public function handle(Parser $parser, Filesystem $filesystem) |
|
67 | { |
|
68 | $slug = ucfirst(camel_case($this->slug)); |
|
69 | $type = ucfirst(camel_case($this->type)); |
|
70 | $vendor = ucfirst(camel_case($this->vendor)); |
|
71 | ||
72 | $addon = $slug . $type; |
|
73 | $namespace = "{$vendor}\\{$addon}"; |
|
74 | $class = $slug . $type . 'TestCase'; |
|
75 | ||
76 | $path = "{$this->path}/tests/Feature/{$addon}Test.php"; |
|
77 | ||
78 | $template = $filesystem->get( |
|
79 | base_path("vendor/anomaly/streams-platform/resources/stubs/addons/test.stub") |
|
80 | ); |
|
81 | ||
82 | $filesystem->makeDirectory(dirname($path), 0755, true, true); |
|
83 | ||
84 | $filesystem->put($path, $parser->parse($template, compact('namespace', 'class'))); |
|
85 | } |
|
86 | } |
|
87 |