- fix : better simple cache

This commit is contained in:
jygaulier
2020-10-30 12:46:19 +01:00
parent e36b0785ee
commit 341f076412
2 changed files with 9 additions and 11 deletions

View File

@@ -579,39 +579,37 @@ class databox extends base implements ThumbnailedElement
/** /**
* @return int[] * @return int[]
*/ */
private $_collection_unique_ids = null;
public function get_collection_unique_ids() public function get_collection_unique_ids()
{ {
static $_r = null; if($this->_collection_unique_ids === null) {
$this->_collection_unique_ids = [];
if($_r === null) {
$_r = [];
foreach ($this->get_collections() as $collection) { foreach ($this->get_collections() as $collection) {
$_r[] = $collection->get_base_id(); $this->_collection_unique_ids[] = $collection->get_base_id();
} }
} }
return $_r; return $this->_collection_unique_ids;
} }
/** /**
* @return collection[] * @return collection[]
*/ */
private $_collections = null;
public function get_collections() public function get_collections()
{ {
static $_r = null; if($this->_collections === null) {
if($_r === null) {
/** @var CollectionRepositoryRegistry $repositoryRegistry */ /** @var CollectionRepositoryRegistry $repositoryRegistry */
$repositoryRegistry = $this->app['repo.collections-registry']; $repositoryRegistry = $this->app['repo.collections-registry'];
$repository = $repositoryRegistry->getRepositoryByDatabox($this->get_sbas_id()); $repository = $repositoryRegistry->getRepositoryByDatabox($this->get_sbas_id());
$_r = array_filter($repository->findAll(), function (collection $collection) { $this->_collections = array_filter($repository->findAll(), function (collection $collection) {
return $collection->is_active(); return $collection->is_active();
}); });
} }
return $_r; return $this->_collections;
} }
/** /**

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB