Vous êtes connecté en tant que anonymous Se Deconnecter
Browse code

Application modulaire fonctionnelle !

Emmanuel ROY authored on 12/08/2019 15:10:25
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,313 +0,0 @@
1
-<?php
2
-
3
-namespace Illuminate\Support;
4
-
5
-use Illuminate\Console\Application as Artisan;
6
-use Illuminate\Contracts\Support\DeferrableProvider;
7
-
8
-abstract class ServiceProvider
9
-{
10
-    /**
11
-     * The application instance.
12
-     *
13
-     * @var \Illuminate\Contracts\Foundation\Application
14
-     */
15
-    protected $app;
16
-
17
-    /**
18
-     * Indicates if loading of the provider is deferred.
19
-     *
20
-     * @deprecated Implement the \Illuminate\Contracts\Support\DeferrableProvider interface instead. Will be removed in Laravel 6.0.
21
-     *
22
-     * @var bool
23
-     */
24
-    protected $defer = false;
25
-
26
-    /**
27
-     * The paths that should be published.
28
-     *
29
-     * @var array
30
-     */
31
-    public static $publishes = [];
32
-
33
-    /**
34
-     * The paths that should be published by group.
35
-     *
36
-     * @var array
37
-     */
38
-    public static $publishGroups = [];
39
-
40
-    /**
41
-     * Create a new service provider instance.
42
-     *
43
-     * @param  \Illuminate\Contracts\Foundation\Application  $app
44
-     * @return void
45
-     */
46
-    public function __construct($app)
47
-    {
48
-        $this->app = $app;
49
-    }
50
-
51
-    /**
52
-     * Register any application services.
53
-     *
54
-     * @return void
55
-     */
56
-    public function register()
57
-    {
58
-        //
59
-    }
60
-
61
-    /**
62
-     * Merge the given configuration with the existing configuration.
63
-     *
64
-     * @param  string  $path
65
-     * @param  string  $key
66
-     * @return void
67
-     */
68
-    protected function mergeConfigFrom($path, $key)
69
-    {
70
-        $config = $this->app['config']->get($key, []);
71
-
72
-        $this->app['config']->set($key, array_merge(require $path, $config));
73
-    }
74
-
75
-    /**
76
-     * Load the given routes file if routes are not already cached.
77
-     *
78
-     * @param  string  $path
79
-     * @return void
80
-     */
81
-    protected function loadRoutesFrom($path)
82
-    {
83
-        if (! $this->app->routesAreCached()) {
84
-            require $path;
85
-        }
86
-    }
87
-
88
-    /**
89
-     * Register a view file namespace.
90
-     *
91
-     * @param  string|array  $path
92
-     * @param  string  $namespace
93
-     * @return void
94
-     */
95
-    protected function loadViewsFrom($path, $namespace)
96
-    {
97
-        if (is_array($this->app->config['view']['paths'])) {
98
-            foreach ($this->app->config['view']['paths'] as $viewPath) {
99
-                if (is_dir($appPath = $viewPath.'/vendor/'.$namespace)) {
100
-                    $this->app['view']->addNamespace($namespace, $appPath);
101
-                }
102
-            }
103
-        }
104
-
105
-        $this->app['view']->addNamespace($namespace, $path);
106
-    }
107
-
108
-    /**
109
-     * Register a translation file namespace.
110
-     *
111
-     * @param  string  $path
112
-     * @param  string  $namespace
113
-     * @return void
114
-     */
115
-    protected function loadTranslationsFrom($path, $namespace)
116
-    {
117
-        $this->app['translator']->addNamespace($namespace, $path);
118
-    }
119
-
120
-    /**
121
-     * Register a JSON translation file path.
122
-     *
123
-     * @param  string  $path
124
-     * @return void
125
-     */
126
-    protected function loadJsonTranslationsFrom($path)
127
-    {
128
-        $this->app['translator']->addJsonPath($path);
129
-    }
130
-
131
-    /**
132
-     * Register a database migration path.
133
-     *
134
-     * @param  array|string  $paths
135
-     * @return void
136
-     */
137
-    protected function loadMigrationsFrom($paths)
138
-    {
139
-        $this->app->afterResolving('migrator', function ($migrator) use ($paths) {
140
-            foreach ((array) $paths as $path) {
141
-                $migrator->path($path);
142
-            }
143
-        });
144
-    }
145
-
146
-    /**
147
-     * Register paths to be published by the publish command.
148
-     *
149
-     * @param  array  $paths
150
-     * @param  mixed  $groups
151
-     * @return void
152
-     */
153
-    protected function publishes(array $paths, $groups = null)
154
-    {
155
-        $this->ensurePublishArrayInitialized($class = static::class);
156
-
157
-        static::$publishes[$class] = array_merge(static::$publishes[$class], $paths);
158
-
159
-        foreach ((array) $groups as $group) {
160
-            $this->addPublishGroup($group, $paths);
161
-        }
162
-    }
163
-
164
-    /**
165
-     * Ensure the publish array for the service provider is initialized.
166
-     *
167
-     * @param  string  $class
168
-     * @return void
169
-     */
170
-    protected function ensurePublishArrayInitialized($class)
171
-    {
172
-        if (! array_key_exists($class, static::$publishes)) {
173
-            static::$publishes[$class] = [];
174
-        }
175
-    }
176
-
177
-    /**
178
-     * Add a publish group / tag to the service provider.
179
-     *
180
-     * @param  string  $group
181
-     * @param  array  $paths
182
-     * @return void
183
-     */
184
-    protected function addPublishGroup($group, $paths)
185
-    {
186
-        if (! array_key_exists($group, static::$publishGroups)) {
187
-            static::$publishGroups[$group] = [];
188
-        }
189
-
190
-        static::$publishGroups[$group] = array_merge(
191
-            static::$publishGroups[$group], $paths
192
-        );
193
-    }
194
-
195
-    /**
196
-     * Get the paths to publish.
197
-     *
198
-     * @param  string  $provider
199
-     * @param  string  $group
200
-     * @return array
201
-     */
202
-    public static function pathsToPublish($provider = null, $group = null)
203
-    {
204
-        if (! is_null($paths = static::pathsForProviderOrGroup($provider, $group))) {
205
-            return $paths;
206
-        }
207
-
208
-        return collect(static::$publishes)->reduce(function ($paths, $p) {
209
-            return array_merge($paths, $p);
210
-        }, []);
211
-    }
212
-
213
-    /**
214
-     * Get the paths for the provider or group (or both).
215
-     *
216
-     * @param  string|null  $provider
217
-     * @param  string|null  $group
218
-     * @return array
219
-     */
220
-    protected static function pathsForProviderOrGroup($provider, $group)
221
-    {
222
-        if ($provider && $group) {
223
-            return static::pathsForProviderAndGroup($provider, $group);
224
-        } elseif ($group && array_key_exists($group, static::$publishGroups)) {
225
-            return static::$publishGroups[$group];
226
-        } elseif ($provider && array_key_exists($provider, static::$publishes)) {
227
-            return static::$publishes[$provider];
228
-        } elseif ($group || $provider) {
229
-            return [];
230
-        }
231
-    }
232
-
233
-    /**
234
-     * Get the paths for the provider and group.
235
-     *
236
-     * @param  string  $provider
237
-     * @param  string  $group
238
-     * @return array
239
-     */
240
-    protected static function pathsForProviderAndGroup($provider, $group)
241
-    {
242
-        if (! empty(static::$publishes[$provider]) && ! empty(static::$publishGroups[$group])) {
243
-            return array_intersect_key(static::$publishes[$provider], static::$publishGroups[$group]);
244
-        }
245
-
246
-        return [];
247
-    }
248
-
249
-    /**
250
-     * Get the service providers available for publishing.
251
-     *
252
-     * @return array
253
-     */
254
-    public static function publishableProviders()
255
-    {
256
-        return array_keys(static::$publishes);
257
-    }
258
-
259
-    /**
260
-     * Get the groups available for publishing.
261
-     *
262
-     * @return array
263
-     */
264
-    public static function publishableGroups()
265
-    {
266
-        return array_keys(static::$publishGroups);
267
-    }
268
-
269
-    /**
270
-     * Register the package's custom Artisan commands.
271
-     *
272
-     * @param  array|mixed  $commands
273
-     * @return void
274
-     */
275
-    public function commands($commands)
276
-    {
277
-        $commands = is_array($commands) ? $commands : func_get_args();
278
-
279
-        Artisan::starting(function ($artisan) use ($commands) {
280
-            $artisan->resolveCommands($commands);
281
-        });
282
-    }
283
-
284
-    /**
285
-     * Get the services provided by the provider.
286
-     *
287
-     * @return array
288
-     */
289
-    public function provides()
290
-    {
291
-        return [];
292
-    }
293
-
294
-    /**
295
-     * Get the events that trigger this service provider to register.
296
-     *
297
-     * @return array
298
-     */
299
-    public function when()
300
-    {
301
-        return [];
302
-    }
303
-
304
-    /**
305
-     * Determine if the provider is deferred.
306
-     *
307
-     * @return bool
308
-     */
309
-    public function isDeferred()
310
-    {
311
-        return $this->defer || $this instanceof DeferrableProvider;
312
-    }
313
-}
Browse code

initial commit

Emmanuel ROY authored on 09/08/2019 08:39:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,313 @@
1
+<?php
2
+
3
+namespace Illuminate\Support;
4
+
5
+use Illuminate\Console\Application as Artisan;
6
+use Illuminate\Contracts\Support\DeferrableProvider;
7
+
8
+abstract class ServiceProvider
9
+{
10
+    /**
11
+     * The application instance.
12
+     *
13
+     * @var \Illuminate\Contracts\Foundation\Application
14
+     */
15
+    protected $app;
16
+
17
+    /**
18
+     * Indicates if loading of the provider is deferred.
19
+     *
20
+     * @deprecated Implement the \Illuminate\Contracts\Support\DeferrableProvider interface instead. Will be removed in Laravel 6.0.
21
+     *
22
+     * @var bool
23
+     */
24
+    protected $defer = false;
25
+
26
+    /**
27
+     * The paths that should be published.
28
+     *
29
+     * @var array
30
+     */
31
+    public static $publishes = [];
32
+
33
+    /**
34
+     * The paths that should be published by group.
35
+     *
36
+     * @var array
37
+     */
38
+    public static $publishGroups = [];
39
+
40
+    /**
41
+     * Create a new service provider instance.
42
+     *
43
+     * @param  \Illuminate\Contracts\Foundation\Application  $app
44
+     * @return void
45
+     */
46
+    public function __construct($app)
47
+    {
48
+        $this->app = $app;
49
+    }
50
+
51
+    /**
52
+     * Register any application services.
53
+     *
54
+     * @return void
55
+     */
56
+    public function register()
57
+    {
58
+        //
59
+    }
60
+
61
+    /**
62
+     * Merge the given configuration with the existing configuration.
63
+     *
64
+     * @param  string  $path
65
+     * @param  string  $key
66
+     * @return void
67
+     */
68
+    protected function mergeConfigFrom($path, $key)
69
+    {
70
+        $config = $this->app['config']->get($key, []);
71
+
72
+        $this->app['config']->set($key, array_merge(require $path, $config));
73
+    }
74
+
75
+    /**
76
+     * Load the given routes file if routes are not already cached.
77
+     *
78
+     * @param  string  $path
79
+     * @return void
80
+     */
81
+    protected function loadRoutesFrom($path)
82
+    {
83
+        if (! $this->app->routesAreCached()) {
84
+            require $path;
85
+        }
86
+    }
87
+
88
+    /**
89
+     * Register a view file namespace.
90
+     *
91
+     * @param  string|array  $path
92
+     * @param  string  $namespace
93
+     * @return void
94
+     */
95
+    protected function loadViewsFrom($path, $namespace)
96
+    {
97
+        if (is_array($this->app->config['view']['paths'])) {
98
+            foreach ($this->app->config['view']['paths'] as $viewPath) {
99
+                if (is_dir($appPath = $viewPath.'/vendor/'.$namespace)) {
100
+                    $this->app['view']->addNamespace($namespace, $appPath);
101
+                }
102
+            }
103
+        }
104
+
105
+        $this->app['view']->addNamespace($namespace, $path);
106
+    }
107
+
108
+    /**
109
+     * Register a translation file namespace.
110
+     *
111
+     * @param  string  $path
112
+     * @param  string  $namespace
113
+     * @return void
114
+     */
115
+    protected function loadTranslationsFrom($path, $namespace)
116
+    {
117
+        $this->app['translator']->addNamespace($namespace, $path);
118
+    }
119
+
120
+    /**
121
+     * Register a JSON translation file path.
122
+     *
123
+     * @param  string  $path
124
+     * @return void
125
+     */
126
+    protected function loadJsonTranslationsFrom($path)
127
+    {
128
+        $this->app['translator']->addJsonPath($path);
129
+    }
130
+
131
+    /**
132
+     * Register a database migration path.
133
+     *
134
+     * @param  array|string  $paths
135
+     * @return void
136
+     */
137
+    protected function loadMigrationsFrom($paths)
138
+    {
139
+        $this->app->afterResolving('migrator', function ($migrator) use ($paths) {
140
+            foreach ((array) $paths as $path) {
141
+                $migrator->path($path);
142
+            }
143
+        });
144
+    }
145
+
146
+    /**
147
+     * Register paths to be published by the publish command.
148
+     *
149
+     * @param  array  $paths
150
+     * @param  mixed  $groups
151
+     * @return void
152
+     */
153
+    protected function publishes(array $paths, $groups = null)
154
+    {
155
+        $this->ensurePublishArrayInitialized($class = static::class);
156
+
157
+        static::$publishes[$class] = array_merge(static::$publishes[$class], $paths);
158
+
159
+        foreach ((array) $groups as $group) {
160
+            $this->addPublishGroup($group, $paths);
161
+        }
162
+    }
163
+
164
+    /**
165
+     * Ensure the publish array for the service provider is initialized.
166
+     *
167
+     * @param  string  $class
168
+     * @return void
169
+     */
170
+    protected function ensurePublishArrayInitialized($class)
171
+    {
172
+        if (! array_key_exists($class, static::$publishes)) {
173
+            static::$publishes[$class] = [];
174
+        }
175
+    }
176
+
177
+    /**
178
+     * Add a publish group / tag to the service provider.
179
+     *
180
+     * @param  string  $group
181
+     * @param  array  $paths
182
+     * @return void
183
+     */
184
+    protected function addPublishGroup($group, $paths)
185
+    {
186
+        if (! array_key_exists($group, static::$publishGroups)) {
187
+            static::$publishGroups[$group] = [];
188
+        }
189
+
190
+        static::$publishGroups[$group] = array_merge(
191
+            static::$publishGroups[$group], $paths
192
+        );
193
+    }
194
+
195
+    /**
196
+     * Get the paths to publish.
197
+     *
198
+     * @param  string  $provider
199
+     * @param  string  $group
200
+     * @return array
201
+     */
202
+    public static function pathsToPublish($provider = null, $group = null)
203
+    {
204
+        if (! is_null($paths = static::pathsForProviderOrGroup($provider, $group))) {
205
+            return $paths;
206
+        }
207
+
208
+        return collect(static::$publishes)->reduce(function ($paths, $p) {
209
+            return array_merge($paths, $p);
210
+        }, []);
211
+    }
212
+
213
+    /**
214
+     * Get the paths for the provider or group (or both).
215
+     *
216
+     * @param  string|null  $provider
217
+     * @param  string|null  $group
218
+     * @return array
219
+     */
220
+    protected static function pathsForProviderOrGroup($provider, $group)
221
+    {
222
+        if ($provider && $group) {
223
+            return static::pathsForProviderAndGroup($provider, $group);
224
+        } elseif ($group && array_key_exists($group, static::$publishGroups)) {
225
+            return static::$publishGroups[$group];
226
+        } elseif ($provider && array_key_exists($provider, static::$publishes)) {
227
+            return static::$publishes[$provider];
228
+        } elseif ($group || $provider) {
229
+            return [];
230
+        }
231
+    }
232
+
233
+    /**
234
+     * Get the paths for the provider and group.
235
+     *
236
+     * @param  string  $provider
237
+     * @param  string  $group
238
+     * @return array
239
+     */
240
+    protected static function pathsForProviderAndGroup($provider, $group)
241
+    {
242
+        if (! empty(static::$publishes[$provider]) && ! empty(static::$publishGroups[$group])) {
243
+            return array_intersect_key(static::$publishes[$provider], static::$publishGroups[$group]);
244
+        }
245
+
246
+        return [];
247
+    }
248
+
249
+    /**
250
+     * Get the service providers available for publishing.
251
+     *
252
+     * @return array
253
+     */
254
+    public static function publishableProviders()
255
+    {
256
+        return array_keys(static::$publishes);
257
+    }
258
+
259
+    /**
260
+     * Get the groups available for publishing.
261
+     *
262
+     * @return array
263
+     */
264
+    public static function publishableGroups()
265
+    {
266
+        return array_keys(static::$publishGroups);
267
+    }
268
+
269
+    /**
270
+     * Register the package's custom Artisan commands.
271
+     *
272
+     * @param  array|mixed  $commands
273
+     * @return void
274
+     */
275
+    public function commands($commands)
276
+    {
277
+        $commands = is_array($commands) ? $commands : func_get_args();
278
+
279
+        Artisan::starting(function ($artisan) use ($commands) {
280
+            $artisan->resolveCommands($commands);
281
+        });
282
+    }
283
+
284
+    /**
285
+     * Get the services provided by the provider.
286
+     *
287
+     * @return array
288
+     */
289
+    public function provides()
290
+    {
291
+        return [];
292
+    }
293
+
294
+    /**
295
+     * Get the events that trigger this service provider to register.
296
+     *
297
+     * @return array
298
+     */
299
+    public function when()
300
+    {
301
+        return [];
302
+    }
303
+
304
+    /**
305
+     * Determine if the provider is deferred.
306
+     *
307
+     * @return bool
308
+     */
309
+    public function isDeferred()
310
+    {
311
+        return $this->defer || $this instanceof DeferrableProvider;
312
+    }
313
+}