From cecd77149795c1a455ac72bc3ed0606413e69900 Mon Sep 17 00:00:00 2001 From: Tobias Oitzinger <42447585+toitzi@users.noreply.github.com> Date: Fri, 25 Oct 2024 09:40:55 +0200 Subject: [PATCH] feat(laravel): use laravel cache setting (#6751) Closes: #6735 --- src/Laravel/ApiPlatformProvider.php | 12 ++++++------ .../app/Providers/WorkbenchServiceProvider.php | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Laravel/ApiPlatformProvider.php b/src/Laravel/ApiPlatformProvider.php index 0a9272b5572..a9725ebdbea 100644 --- a/src/Laravel/ApiPlatformProvider.php +++ b/src/Laravel/ApiPlatformProvider.php @@ -297,7 +297,7 @@ public function register(): void }); $this->app->extend(PropertyMetadataFactoryInterface::class, function (PropertyInfoPropertyMetadataFactory $inner, Application $app) { - /** @var ConfigRepository */ + /** @var ConfigRepository $config */ $config = $app['config']; return new CachePropertyMetadataFactory( @@ -313,12 +313,12 @@ public function register(): void $app->make(ResourceClassResolverInterface::class) ), ), - true === $config->get('app.debug') ? 'array' : 'file' + true === $config->get('app.debug') ? 'array' : $config->get('cache.default', 'file') ); }); $this->app->singleton(PropertyNameCollectionFactoryInterface::class, function (Application $app) { - /** @var ConfigRepository */ + /** @var ConfigRepository $config */ $config = $app['config']; return new CachePropertyNameCollectionMetadataFactory( @@ -331,7 +331,7 @@ public function register(): void ) ) ), - true === $config->get('app.debug') ? 'array' : 'file' + true === $config->get('app.debug') ? 'array' : $config->get('cache.default', 'file') ); }); @@ -345,7 +345,7 @@ public function register(): void // TODO: add cached metadata factories $this->app->singleton(ResourceMetadataCollectionFactoryInterface::class, function (Application $app) { - /** @var ConfigRepository */ + /** @var ConfigRepository $config */ $config = $app['config']; $formats = $config->get('api-platform.formats'); @@ -401,7 +401,7 @@ public function register(): void $app->make('filters') ) ), - true === $config->get('app.debug') ? 'array' : 'file' + true === $config->get('app.debug') ? 'array' : $config->get('cache.default', 'file') ); }); diff --git a/src/Laravel/workbench/app/Providers/WorkbenchServiceProvider.php b/src/Laravel/workbench/app/Providers/WorkbenchServiceProvider.php index a6237450d1c..eb0d9f4d5ce 100644 --- a/src/Laravel/workbench/app/Providers/WorkbenchServiceProvider.php +++ b/src/Laravel/workbench/app/Providers/WorkbenchServiceProvider.php @@ -32,6 +32,7 @@ public function register(): void { $config = $this->app['config']; $config->set('api-platform.resources', [app_path('Models'), app_path('ApiResource')]); + $config->set('cache.default', 'null'); } /**