-
Notifications
You must be signed in to change notification settings - Fork 9
/
ModuleFactory.php
30 lines (25 loc) · 980 Bytes
/
ModuleFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
declare(strict_types=1);
namespace BEAR\QueryRepository;
use BEAR\RepositoryModule\Annotation\EtagPool;
use BEAR\Resource\Module\ResourceModule;
use Psr\Cache\CacheItemPoolInterface;
use Ray\Di\AbstractModule;
use Ray\Di\Scope;
use Ray\PsrCacheModule\Annotation\Shared;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
final class ModuleFactory
{
public static function getInstance(string $namespace): QueryRepositoryModule
{
$module = new QueryRepositoryModule(new ResourceModule($namespace));
$module->override(new class extends AbstractModule{
protected function configure(): void
{
$this->bind(CacheItemPoolInterface::class)->annotatedWith(Shared::class)->to(ArrayAdapter::class)->in(Scope::SINGLETON);
$this->bind(CacheItemPoolInterface::class)->annotatedWith(EtagPool::class)->to(ArrayAdapter::class)->in(Scope::SINGLETON);
}
});
return $module;
}
}