mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
GenericDoc: add provider for AccompanyingCourseDocument, without filtering
This commit is contained in:
@@ -11,7 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocStoreBundle\GenericDoc;
|
||||
|
||||
use Nelmio\Alice\Throwable\Exception\FixtureBuilder\Denormalizer\UnexpectedValueException;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
|
||||
class FetchQuery implements FetchQueryInterface
|
||||
{
|
||||
@@ -21,42 +21,56 @@ class FetchQuery implements FetchQueryInterface
|
||||
private array $joins = [];
|
||||
|
||||
/**
|
||||
* @var list<mixed>
|
||||
* @var list<list<mixed>>
|
||||
*/
|
||||
private array $joinParams = [];
|
||||
|
||||
/**
|
||||
* @var list<string>
|
||||
* @var array<list<Types::*>>
|
||||
*/
|
||||
private array $joinTypes = [];
|
||||
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
private array $wheres = [];
|
||||
|
||||
/**
|
||||
* @var list<mixed>
|
||||
* @var array<list<mixed>>
|
||||
*/
|
||||
private array $whereParams = [];
|
||||
|
||||
/**
|
||||
* @var array<list<Types::*>>
|
||||
*/
|
||||
private array $whereTypes = [];
|
||||
|
||||
public function __construct(
|
||||
private readonly string $selectKeyString,
|
||||
private readonly string $selectIdentifierJsonB,
|
||||
private readonly string $selectDate,
|
||||
private string $from = '',
|
||||
private array $selectIdentifierParams = [],
|
||||
private array $selectIdentifierTypes = [],
|
||||
private array $selectDateParams = [],
|
||||
private array $selectDateTypes = [],
|
||||
) {
|
||||
}
|
||||
|
||||
public function addJoinClause(string $sql, array $params = []): int
|
||||
public function addJoinClause(string $sql, array $params = [], array $types = []): int
|
||||
{
|
||||
$this->joins[] = $sql;
|
||||
$this->joinParams[] = $params;
|
||||
$this->joinTypes[] = $types;
|
||||
|
||||
return count($this->joins) - 1;
|
||||
}
|
||||
|
||||
public function addWhereClause(string $sql, array $params = []): int
|
||||
public function addWhereClause(string $sql, array $params = [], array $types = []): int
|
||||
{
|
||||
$this->wheres[] = $sql;
|
||||
$this->whereParams[] = $params;
|
||||
$this->whereTypes[] = $types;
|
||||
|
||||
return count($this->wheres) - 1;
|
||||
}
|
||||
@@ -67,7 +81,7 @@ class FetchQuery implements FetchQueryInterface
|
||||
throw new \UnexpectedValueException("this index does not exists");
|
||||
}
|
||||
|
||||
unset($this->wheres[$index], $this->whereParams[$index]);
|
||||
unset($this->wheres[$index], $this->whereParams[$index], $this->whereTypes[$index]);
|
||||
|
||||
}
|
||||
|
||||
@@ -77,7 +91,7 @@ class FetchQuery implements FetchQueryInterface
|
||||
throw new \UnexpectedValueException("this index does not exists");
|
||||
}
|
||||
|
||||
unset($this->joins[$index], $this->joinParams[$index]);
|
||||
unset($this->joins[$index], $this->joinParams[$index], $this->joinTypes[$index]);
|
||||
|
||||
}
|
||||
|
||||
@@ -99,11 +113,21 @@ class FetchQuery implements FetchQueryInterface
|
||||
return $this->selectIdentifierParams;
|
||||
}
|
||||
|
||||
public function getSelectIdentifiersTypes(): array
|
||||
{
|
||||
return $this->selectIdentifierTypes;
|
||||
}
|
||||
|
||||
public function getSelectDate(): string
|
||||
{
|
||||
return $this->selectDate;
|
||||
}
|
||||
|
||||
public function getSelectDateTypes(): array
|
||||
{
|
||||
return $this->selectDateTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@@ -131,6 +155,17 @@ class FetchQuery implements FetchQueryInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getFromQueryTypes(): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($this->joinTypes as $types) {
|
||||
$result = [...$result, ...$types];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getWhereQuery(): string
|
||||
{
|
||||
return implode(' AND ', $this->wheres);
|
||||
@@ -150,19 +185,49 @@ class FetchQuery implements FetchQueryInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $selectIdentifierParams
|
||||
*/
|
||||
public function setSelectIdentifierParams(array $selectIdentifierParams): void
|
||||
public function getWhereQueryTypes(): array
|
||||
{
|
||||
$this->selectIdentifierParams = $selectIdentifierParams;
|
||||
$result = [];
|
||||
|
||||
foreach ($this->whereTypes as $types) {
|
||||
$result = [...$result, ...$types];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $selectDateParams
|
||||
*/
|
||||
public function setSelectDateParams(array $selectDateParams): void
|
||||
public function setSelectIdentifierParams(array $selectIdentifierParams): self
|
||||
{
|
||||
$this->selectIdentifierParams = $selectIdentifierParams;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSelectDateParams(array $selectDateParams): self
|
||||
{
|
||||
$this->selectDateParams = $selectDateParams;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFrom(string $from): self
|
||||
{
|
||||
$this->from = $from;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSelectIdentifierTypes(array $selectIdentifierTypes): self
|
||||
{
|
||||
$this->selectIdentifierTypes = $selectIdentifierTypes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSelectDateTypes(array $selectDateTypes): self
|
||||
{
|
||||
$this->selectDateTypes = $selectDateTypes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user