mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 23:13:15 +00:00
Remove one N+1 by fetching TechnicalDataSets
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2016 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Media;
|
||||
|
||||
class RecordTechnicalDataSetRepositoryProvider
|
||||
{
|
||||
/**
|
||||
* @var RecordTechnicalDataSetRepository[]
|
||||
*/
|
||||
private $repositories = [];
|
||||
|
||||
/**
|
||||
* @var RecordTechnicalDataSetRepositoryFactory
|
||||
*/
|
||||
private $factory;
|
||||
|
||||
public function __construct(RecordTechnicalDataSetRepositoryFactory $factory)
|
||||
{
|
||||
$this->factory = $factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $databoxId
|
||||
* @return RecordTechnicalDataSetRepository
|
||||
*/
|
||||
public function getRepositoryFor($databoxId)
|
||||
{
|
||||
if (!isset($this->repositories[$databoxId])) {
|
||||
$this->repositories[$databoxId] = $this->factory->createRepositoryForDatabox($databoxId);
|
||||
}
|
||||
|
||||
return $this->repositories[$databoxId];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user