Skip to content

Commit

Permalink
Merge pull request #102 from koriym/bind-etag-pool
Browse files Browse the repository at this point in the history
Bind default EtagPool
  • Loading branch information
koriym committed Nov 6, 2021
2 parents 316c156 + d88e63b commit aadba83
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/QueryRepositoryModule.php
Expand Up @@ -4,6 +4,7 @@

namespace BEAR\QueryRepository;

use BEAR\RepositoryModule\Annotation\EtagPool;
use BEAR\Resource\NamedParameter;
use BEAR\Resource\NamedParameterInterface;
use Psr\Cache\CacheItemPoolInterface;
Expand All @@ -21,6 +22,8 @@ protected function configure(): void
{
// Null cache default
$this->bind(CacheItemPoolInterface::class)->annotatedWith(Shared::class)->to(NullAdapter::class)->in(Scope::SINGLETON);

$this->bind(CacheItemPoolInterface::class)->annotatedWith(EtagPool::class)->to(NullAdapter::class)->in(Scope::SINGLETON);
// core
$this->bind(QueryRepositoryInterface::class)->to(QueryRepository::class)->in(Scope::SINGLETON);
$this->bind(CacheDependencyInterface::class)->to(CacheDependency::class);
Expand Down
15 changes: 13 additions & 2 deletions tests/ModuleFactory.php
Expand Up @@ -4,15 +4,26 @@

namespace BEAR\QueryRepository;

use BEAR\RepositoryModule\Annotation\EtagPool;
use BEAR\Resource\Module\ResourceModule;
use Ray\PsrCacheModule\Psr6ArrayModule;
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 Psr6ArrayModule());
$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;
}
Expand Down

0 comments on commit aadba83

Please sign in to comment.