47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Services\Comment\PostCommentService;
|
|
use App\Services\Post\CachedPostService;
|
|
use App\Services\CacheKeyBuilder;
|
|
use App\Services\Post\PostServiceInterface;
|
|
use App\Services\QueryRequestModifiers\Post\PostFilter;
|
|
use App\Services\QueryRequestModifiers\Post\PostOrder;
|
|
use Illuminate\Foundation\Application;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class PostServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
$this->app->singleton(PostFilter::class, function (Application $app) {
|
|
return new PostFilter();
|
|
});
|
|
|
|
$this->app->singleton(PostOrder::class, function (Application $app) {
|
|
return new PostOrder();
|
|
});
|
|
|
|
$this->app->singleton(PostServiceInterface::class, function (Application $app) {
|
|
return new CachedPostService(
|
|
$this->app->get(PostFilter::class),
|
|
$this->app->get(PostOrder::class),
|
|
$this->app->get(CacheKeyBuilder::class),
|
|
);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Bootstrap services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
}
|
|
}
|