1 | <?php |
||
21 | abstract class PackageServiceProvider extends ServiceProvider |
||
22 | { |
||
23 | /* ----------------------------------------------------------------- |
||
24 | | Traits |
||
25 | | ----------------------------------------------------------------- |
||
26 | */ |
||
27 | |||
28 | use HasAssets, |
||
29 | HasConfig, |
||
30 | HasFactories, |
||
31 | HasMigrations, |
||
32 | HasTranslations, |
||
33 | HasViews; |
||
34 | |||
35 | /* ----------------------------------------------------------------- |
||
36 | | Properties |
||
37 | | ----------------------------------------------------------------- |
||
38 | */ |
||
39 | |||
40 | /** |
||
41 | * Vendor name. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $vendor = 'arcanedev'; |
||
46 | |||
47 | /** |
||
48 | * Package name. |
||
49 | * |
||
50 | * @var string|null |
||
51 | */ |
||
52 | protected $package; |
||
53 | |||
54 | /** |
||
55 | * Package base path. |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | protected $basePath; |
||
60 | |||
61 | /* ----------------------------------------------------------------- |
||
62 | | Constructor |
||
63 | | ----------------------------------------------------------------- |
||
64 | */ |
||
65 | |||
66 | /** |
||
67 | * Create a new service provider instance. |
||
68 | * |
||
69 | * @param \Illuminate\Contracts\Foundation\Application $app |
||
70 | */ |
||
71 | 18 | public function __construct(Application $app) |
|
72 | { |
||
73 | 18 | parent::__construct($app); |
|
74 | |||
75 | 18 | $this->basePath = $this->resolveBasePath(); |
|
76 | 18 | } |
|
77 | |||
78 | /** |
||
79 | * Resolve the base path of the package. |
||
80 | * |
||
81 | * @return string |
||
82 | */ |
||
83 | 18 | protected function resolveBasePath() |
|
84 | { |
||
85 | 18 | return dirname( |
|
86 | 18 | (new ReflectionClass($this))->getFileName(), 2 |
|
87 | ); |
||
88 | } |
||
89 | |||
90 | /* ----------------------------------------------------------------- |
||
91 | | Getters & Setters |
||
92 | | ----------------------------------------------------------------- |
||
93 | */ |
||
94 | |||
95 | /** |
||
96 | * Get the base path of the package. |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | 18 | public function getBasePath() |
|
101 | { |
||
102 | 18 | return $this->basePath; |
|
103 | } |
||
104 | |||
105 | /** |
||
106 | * Get the vendor name. |
||
107 | * |
||
108 | * @return string |
||
109 | */ |
||
110 | 18 | protected function getVendorName(): string |
|
111 | { |
||
112 | 18 | return $this->vendor; |
|
113 | } |
||
114 | |||
115 | /** |
||
116 | * Get the package name. |
||
117 | * |
||
118 | * @return string|null |
||
119 | */ |
||
120 | 18 | protected function getPackageName(): ?string |
|
121 | { |
||
122 | 18 | return $this->package; |
|
123 | } |
||
124 | |||
125 | /* ----------------------------------------------------------------- |
||
126 | | Main Methods |
||
127 | | ----------------------------------------------------------------- |
||
128 | */ |
||
129 | |||
130 | /** |
||
131 | * Register the service provider. |
||
132 | */ |
||
133 | 18 | public function register() |
|
139 | |||
140 | /* ----------------------------------------------------------------- |
||
141 | | Package Methods |
||
142 | | ----------------------------------------------------------------- |
||
143 | */ |
||
144 | |||
145 | /** |
||
146 | * Publish all the package files. |
||
147 | */ |
||
148 | protected function publishAll(): void |
||
157 | |||
158 | /* ----------------------------------------------------------------- |
||
159 | | Check Methods |
||
160 | | ----------------------------------------------------------------- |
||
161 | */ |
||
162 | |||
163 | /** |
||
164 | * Check package name. |
||
165 | * |
||
166 | * @throws \Arcanedev\Support\Exceptions\PackageException |
||
167 | */ |
||
168 | 18 | protected function checkPackageName(): void |
|
174 | |||
175 | /* ----------------------------------------------------------------- |
||
176 | | Other Methods |
||
177 | | ----------------------------------------------------------------- |
||
178 | */ |
||
179 | |||
180 | /** |
||
181 | * Get the published tags. |
||
182 | * |
||
183 | * @param string $tag |
||
184 | * |
||
185 | * @return array |
||
186 | */ |
||
187 | protected function getPublishedTags(string $tag): array |
||
195 | } |
||
196 |