Refactor collection repositories: use one instance per databox

This commit is contained in:
Thibaud Fabre
2015-07-09 18:48:53 +02:00
parent 6b516618aa
commit 977e778b61
17 changed files with 407 additions and 214 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace Alchemy\Phrasea\Collection\Factory;
use Alchemy\Phrasea\Collection\CollectionRepository;
use Alchemy\Phrasea\Collection\CollectionRepositoryFactory;
use Alchemy\Phrasea\Collection\Repository\ArrayCacheCollectionRepository;
class ArrayCachedCollectionRepositoryFactory implements CollectionRepositoryFactory
{
/**
* @var CollectionRepositoryFactory
*/
private $collectionRepositoryFactory;
/**
* @param CollectionRepositoryFactory $collectionRepositoryFactory
*/
public function __construct(CollectionRepositoryFactory $collectionRepositoryFactory)
{
$this->collectionRepositoryFactory = $collectionRepositoryFactory;
}
/**
* @param int $databoxId
* @return CollectionRepository
*/
public function createRepositoryForDatabox($databoxId)
{
$repository = $this->collectionRepositoryFactory->createRepositoryForDatabox($databoxId);
return new ArrayCacheCollectionRepository($repository);
}
}