Ported Day DQL extension.

This commit is contained in:
Alexey Skobkin 2023-03-28 23:01:56 +03:00
parent 441fdc06b3
commit 2029adc48d
No known key found for this signature in database
GPG key ID: 5D5CEF6F221278E7

View file

@ -1,15 +1,17 @@
<?php
declare(strict_types=1);
namespace src\PointToolsBundle\DQL;
namespace App\Doctrine\DQL;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\{Lexer, Parser, SqlWalker};
/** TODO: check if still needed */
class Day extends FunctionNode
{
public $dateExpression;
public function parse(\Doctrine\ORM\Query\Parser $parser)
public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
@ -19,7 +21,7 @@ class Day extends FunctionNode
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
public function getSql(SqlWalker $sqlWalker): string
{
return 'date_trunc(\'day\', '.$this->dateExpression->dispatch($sqlWalker).')';
}