mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 03:53:13 +00:00
51 lines
1.0 KiB
PHP
51 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Alchemy\Phrasea\Collection\Repository;
|
|
|
|
use Alchemy\Phrasea\Collection\CollectionRepository;
|
|
|
|
class ArrayCacheCollectionRepository implements CollectionRepository
|
|
{
|
|
/**
|
|
* @var CollectionRepository
|
|
*/
|
|
private $collectionRepository;
|
|
|
|
/**
|
|
* @var \collection[]
|
|
*/
|
|
private $collectionCache = null;
|
|
|
|
public function __construct(CollectionRepository $collectionRepository)
|
|
{
|
|
$this->collectionRepository = $collectionRepository;
|
|
}
|
|
|
|
/**
|
|
* @return \collection[]
|
|
*/
|
|
public function findAll()
|
|
{
|
|
if ($this->collectionCache === null) {
|
|
$this->collectionCache = $this->collectionRepository->findAll();
|
|
}
|
|
|
|
return $this->collectionCache;
|
|
}
|
|
|
|
/**
|
|
* @param int $collectionId
|
|
* @return \collection|null
|
|
*/
|
|
public function find($collectionId)
|
|
{
|
|
$collections = $this->findAll();
|
|
|
|
if (isset($collections[$collectionId])) {
|
|
return $collections[$collectionId];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|