PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk All 48 releases
← All changes | vendor/wpfluent/framework/src/WPFluent/Foundation/Application.php +57 -7 1.3.21 → 1.6.5 View file →
@@ -20,12 +20,31 @@
20 20 use FluentCart\Framework\Foundation\ComponentBinder;
21 21 use FluentCart\Framework\Foundation\Concerns\FoundationTrait;
22 22
23 23 /**
24 - * @property \FluentCart\Framework\Foundation\Config $config
25 - * @property \FluentCart\Framework\Http\Router\Router $router
26 - * @property \FluentCart\Framework\Http\Request\Request $request
27 - * @property \FluentCart\Framework\Http\Response\Response $response
24 + * Application — service container with magic property access via __get.
25 + *
26 + * Properties below are bound in {@see ComponentBinder::bindComponents()} and
27 + * {@see Application::init()}/{@see Application::setAppLevelNamespace()}. Each
28 + * `@property` declaration teaches PHPStan about a runtime container binding so
29 + * `$app->view->render(...)` and similar access can be type-checked.
30 + *
31 + * @property \FluentCart\Framework\Foundation\Config $config
32 + * @property \FluentCart\Framework\View\View $view
33 + * @property \FluentCart\Framework\Cache\Cache $cache
34 + * @property \FluentCart\Framework\Http\Router $router
35 + * @property \FluentCart\Framework\Http\Request\Request $request
36 + * @property \FluentCart\Framework\Http\Response\Response $response
37 + * @property \FluentCart\Framework\Validator\Validator $validator
38 + * @property \FluentCart\Framework\Events\Dispatcher $events
39 + * @property \FluentCart\Framework\Encryption\Encrypter $encrypter
40 + * @property \FluentCart\Framework\Encryption\Encrypter $crypt
41 + * @property \FluentCart\Framework\Database\DatabaseManager $db
42 + * @property \FluentCart\Framework\Http\URL $url
43 + * @property \FluentCart\Framework\Support\Mail $mail
44 + * @property \FluentCart\Framework\Support\Pipeline $pipeline
45 + * @property string $__pluginfile__
46 + * @property string $__namespace__
28 47 */
29 48 class Application extends Container
30 49 {
31 50 use FoundationTrait;
@@ -185,8 +204,9 @@
185 204 {
186 205 $this->bindAppInstance();
187 206 $this->bindPathsAndUrls();
188 207 $this->loadConfigIfExists();
208 + $this->registerMiddleware();
189 209 $this->registerTextdomain();
190 210 $this->bindCoreComponents();
191 211 $this->requireCommonFiles($this);
192 212 $this->addRestApiInitAction($this);
@@ -251,17 +271,47 @@
251 271 * @return null
252 272 */
253 273 protected function loadConfigIfExists()
254 274 {
255 - $data = [];
275 + $files = [];
256 276
257 277 if (is_dir($this['path.config'])) {
258 278 foreach (glob($this['path.config'] . '*.php') as $file) {
259 - $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;
260 285 }
261 286 }
262 287
263 - $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 + });
264 314 }
265 315
266 316 /**
267 317 * Resolve the given type from the container.