bootstrap generic doc manager and associated services

This commit is contained in:
2023-05-23 22:12:18 +02:00
parent 977299192f
commit afcd6e0605
10 changed files with 585 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\DocStoreBundle\GenericDoc;
final readonly class FetchQueryToSqlBuilder
{
private const SQL = <<<'SQL'
SELECT
'{{ key }}' AS key,
{{ identifiers }} AS identifiers,
{{ date }} AS doc_date
FROM {{ from }}
WHERE {{ where }}
SQL;
/**
* @param FetchQueryInterface $query
* @return array{sql: string, params: list<mixed>}
*/
public function toSql(FetchQueryInterface $query): array
{
$sql = strtr(self::SQL, [
'{{ key }}' => $query->getSelectKeyString(),
'{{ identifiers }}' => $query->getSelectIdentifierJsonB(),
'{{ date }}' => $query->getSelectDate(),
'{{ from }}' => $query->getFromQuery(),
'{{ where }}' => $query->getWhereQuery(),
]);
$params = [
...$query->getSelectIdentifierParams(),
...$query->getSelectDateParams(),
...$query->getFromQueryParams(),
...$query->getWhereQueryParams()
];
return ['sql' => $sql, 'params' => $params];
}
}