PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.11.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.11.0
2.11.0 2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 All 78 releases
← All changes | vendor/wpfluent/framework/src/WPFluent/Foundation/Application.php +35 -4 2.4.012.11.0 View file →
@@ -30,9 +30,9 @@
30 30 *
31 31 * @property \FluentCommunity\Framework\Foundation\Config $config
32 32 * @property \FluentCommunity\Framework\View\View $view
33 33 * @property \FluentCommunity\Framework\Cache\Cache $cache
34 - * @property \FluentCommunity\Framework\Http\Router\Router $router
34 + * @property \FluentCommunity\Framework\Http\Router $router
35 35 * @property \FluentCommunity\Framework\Http\Request\Request $request
36 36 * @property \FluentCommunity\Framework\Http\Response\Response $response
37 37 * @property \FluentCommunity\Framework\Validator\Validator $validator
38 38 * @property \FluentCommunity\Framework\Events\Dispatcher $events
@@ -204,8 +204,9 @@
204 204 {
205 205 $this->bindAppInstance();
206 206 $this->bindPathsAndUrls();
207 207 $this->loadConfigIfExists();
208 + $this->registerMiddleware();
208 209 $this->registerTextdomain();
209 210 $this->bindCoreComponents();
210 211 $this->requireCommonFiles($this);
211 212 $this->addRestApiInitAction($this);
@@ -270,17 +271,47 @@
270 271 * @return null
271 272 */
272 273 protected function loadConfigIfExists()
273 274 {
274 - $data = [];
275 + $files = [];
275 276
276 277 if (is_dir($this['path.config'])) {
277 278 foreach (glob($this['path.config'] . '*.php') as $file) {
278 - $data[basename($file, '.php')] = require($file);
279 + // middleware.php lives under app/Http/ now; it ships closures
280 + // that don't belong in Config storage.
281 + if (basename($file) === 'middleware.php') {
282 + continue;
283 + }
284 + $files[basename($file, '.php')] = $file;
279 285 }
280 286 }
281 287
282 - $this->instance('config', new Config($data));
288 + $this->instance('config', new Config([], $files));
289 + }
290 +
291 + /**
292 + * Register the HTTP middleware stack as a lazy container binding.
293 + *
294 + * Resolves from `app/Http/middleware.php` (canonical). Falls back to
295 + * `config/middleware.php` so un-migrated plugins keep working.
296 + *
297 + * @return void
298 + */
299 + protected function registerMiddleware()
300 + {
301 + $this->singleton('http.middleware', function ($app) {
302 + $new = $app['path.http'] . 'middleware.php';
303 + if (is_file($new)) {
304 + return require $new;
305 + }
306 +
307 + $legacy = $app['path.config'] . 'middleware.php';
308 + if (is_file($legacy)) {
309 + return require $legacy;
310 + }
311 +
312 + return [];
313 + });
283 314 }
284 315
285 316 /**
286 317 * Resolve the given type from the container.