Skip to content

Commit 5acfa75

Browse files
committed
feat(laravel): use laravel cache setting
Make use of the default laravel cache setting, makes it possible for developers to configure where data should be cached Closes: #6735 Signed-off-by: Tobias Oitzinger <[email protected]>
1 parent 034fcbc commit 5acfa75

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/Laravel/ApiPlatformProvider.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function register(): void
279279
});
280280

281281
$this->app->extend(PropertyMetadataFactoryInterface::class, function (PropertyInfoPropertyMetadataFactory $inner, Application $app) {
282-
/** @var ConfigRepository */
282+
/** @var ConfigRepository $config */
283283
$config = $app['config'];
284284

285285
return new CachePropertyMetadataFactory(
@@ -295,12 +295,12 @@ public function register(): void
295295
$app->make(ResourceClassResolverInterface::class)
296296
),
297297
),
298-
true === $config->get('app.debug') ? 'array' : 'file'
298+
true === $config->get('app.debug') ? 'array' : $config->get('cache.default', 'file')
299299
);
300300
});
301301

302302
$this->app->singleton(PropertyNameCollectionFactoryInterface::class, function (Application $app) {
303-
/** @var ConfigRepository */
303+
/** @var ConfigRepository $config */
304304
$config = $app['config'];
305305

306306
return new CachePropertyNameCollectionMetadataFactory(
@@ -313,7 +313,7 @@ public function register(): void
313313
)
314314
)
315315
),
316-
true === $config->get('app.debug') ? 'array' : 'file'
316+
true === $config->get('app.debug') ? 'array' : $config->get('cache.default', 'file')
317317
);
318318
});
319319

@@ -327,7 +327,7 @@ public function register(): void
327327

328328
// TODO: add cached metadata factories
329329
$this->app->singleton(ResourceMetadataCollectionFactoryInterface::class, function (Application $app) {
330-
/** @var ConfigRepository */
330+
/** @var ConfigRepository $config */
331331
$config = $app['config'];
332332
$formats = $config->get('api-platform.formats');
333333

@@ -382,7 +382,7 @@ public function register(): void
382382
$app->make('filters')
383383
)
384384
),
385-
true === $config->get('app.debug') ? 'array' : 'file'
385+
true === $config->get('app.debug') ? 'array' : $config->get('cache.default', 'file')
386386
);
387387
});
388388

src/Laravel/workbench/app/Providers/WorkbenchServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function register(): void
3232
{
3333
$config = $this->app['config'];
3434
$config->set('api-platform.resources', [app_path('Models'), app_path('ApiResource')]);
35+
$config->set('cache.default', 'null');
3536
}
3637

3738
/**

0 commit comments

Comments
 (0)