Skip to content

Commit

Permalink
feat(laravel): use laravel cache setting
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
toitzi authored and soyuka committed Oct 25, 2024
1 parent ac6f667 commit 31f6534
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Laravel/ApiPlatformProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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')
);
});

Expand All @@ -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');

Expand Down Expand Up @@ -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')
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down

0 comments on commit 31f6534

Please sign in to comment.