Skip to content

Commit

Permalink
feat(laravel): use laravel cache setting (#6751)
Browse files Browse the repository at this point in the history
Closes: #6735
  • Loading branch information
toitzi authored Oct 25, 2024
1 parent ac6f667 commit cecd771
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 cecd771

Please sign in to comment.