mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 04:53:26 +00:00
Add lookup by order master to collection reference repository
This commit is contained in:
@@ -90,6 +90,15 @@ class ArrayCacheCollectionReferenceRepository implements CollectionReferenceRepo
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $subset
|
||||
* @return CollectionReference[]
|
||||
*/
|
||||
public function findHavingOrderMaster(array $subset = null)
|
||||
{
|
||||
return $this->repository->findHavingOrderMaster($subset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CollectionReference $reference
|
||||
* @return void
|
||||
|
@@ -36,6 +36,14 @@ interface CollectionReferenceRepository
|
||||
*/
|
||||
public function findByCollectionId($databoxId, $collectionId);
|
||||
|
||||
/**
|
||||
* Find Collection references having at least one Order Master
|
||||
*
|
||||
* @param array<int>|null $subset Restrict search to a subset of base ids.
|
||||
* @return CollectionReference[]
|
||||
*/
|
||||
public function findHavingOrderMaster(array $subset = null);
|
||||
|
||||
/**
|
||||
* @param CollectionReference $reference
|
||||
* @return void
|
||||
|
@@ -10,7 +10,6 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Collection\Reference;
|
||||
|
||||
use Alchemy\Phrasea\Core\Database\QueryBuilder;
|
||||
use Doctrine\DBAL\Connection;
|
||||
|
||||
class DbalCollectionReferenceRepository implements CollectionReferenceRepository
|
||||
@@ -107,6 +106,29 @@ class DbalCollectionReferenceRepository implements CollectionReferenceRepository
|
||||
return null;
|
||||
}
|
||||
|
||||
public function findHavingOrderMaster(array $subset = null)
|
||||
{
|
||||
$query = self::$selectQuery
|
||||
. ' WHERE EXISTS(SELECT 1 FROM basusr WHERE basusr.order_master = 1 AND basusr.base_id = bas.base_id)';
|
||||
|
||||
$parameters = [];
|
||||
$types = [];
|
||||
|
||||
if (null !== $subset) {
|
||||
if (empty($subset)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$query .= ' AND bas.base_id IN (:subset)';
|
||||
$parameters['subset'] = $subset;
|
||||
$types['subset'] = Connection::PARAM_INT_ARRAY;
|
||||
}
|
||||
|
||||
$rows = $this->connection->fetchAll($query, $parameters);
|
||||
|
||||
return $this->createManyReferences($rows);
|
||||
}
|
||||
|
||||
public function save(CollectionReference $collectionReference)
|
||||
{
|
||||
$query = self::$insertQuery;
|
||||
|
@@ -176,6 +176,7 @@ class RepositoriesServiceProvider implements ServiceProviderInterface
|
||||
|
||||
return new ArrayCacheCollectionReferenceRepository($repository);
|
||||
});
|
||||
|
||||
$app['repo.collections-registry'] = $app->share(function (PhraseaApplication $app) {
|
||||
$factory = new CollectionFactory($app);
|
||||
$connectionProvider = new DataboxConnectionProvider($app->getApplicationBox());
|
||||
|
Reference in New Issue
Block a user