Commit 84f3d94a authored by Bernhard Schussek's avatar Bernhard Schussek

Added extensions from NEOS CRM

parent 8e5557e0
......@@ -126,6 +126,7 @@ abstract class ORMRepository extends EntityRepository implements EditableReposit
return new EmptyCursor();
}
// Index by ID for the ID check below
$results = $this->createQueryBuilder('e', sprintf('e.%s', $this->idField))
->where(sprintf('e.%s IN (:ids)', $this->idField))
->setParameter('ids', array_map('strval', array_values($ids)))
......@@ -146,6 +147,25 @@ abstract class ORMRepository extends EntityRepository implements EditableReposit
return new ArrayCursor(array_values($results));
}
/**
* {@inheritdoc}
*/
public function getMultipleBy(array $fieldValues): Cursor
{
if (0 === count($fieldValues)) {
return new EmptyCursor();
}
$qb = $this->createQueryBuilder('e');
foreach ($fieldValues as $fieldName => $fieldValue) {
$qb->andWhere(sprintf('e.%s = :%s', $fieldName, $fieldName))
->setParameter($fieldName, $fieldValue);
}
return new ArrayCursor(array_values($qb->getQuery()->execute()));
}
/**
* {@inheritdoc}
*/
......@@ -434,7 +454,8 @@ abstract class ORMRepository extends EntityRepository implements EditableReposit
*/
protected function fetchFieldValues(string $fieldName, array $ids = []): array
{
$qb = $this->createQueryBuilder('c')->select(sprintf('c.%s, c.%s', $this->idField, $fieldName));
$qb = $this->createQueryBuilder('c')
->select(sprintf('c.%s, c.%s', $this->idField, $fieldName));
if (count($ids) > 0) {
$qb->where(sprintf('c.%s IN (:ids)', $this->idField))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment