2017-01-10 01:21:57 +00:00
|
|
|
<?php
|
2023-03-28 20:01:56 +00:00
|
|
|
declare(strict_types=1);
|
2017-01-10 01:21:57 +00:00
|
|
|
|
2023-03-28 20:01:56 +00:00
|
|
|
namespace App\Doctrine\DQL;
|
2017-01-10 01:21:57 +00:00
|
|
|
|
|
|
|
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
|
2023-03-28 20:01:56 +00:00
|
|
|
use Doctrine\ORM\Query\{Lexer, Parser, SqlWalker};
|
2017-01-10 01:21:57 +00:00
|
|
|
|
2023-03-28 20:01:56 +00:00
|
|
|
/** TODO: check if still needed */
|
2017-01-10 01:21:57 +00:00
|
|
|
class Day extends FunctionNode
|
|
|
|
{
|
|
|
|
public $dateExpression;
|
|
|
|
|
2023-03-28 20:01:56 +00:00
|
|
|
public function parse(Parser $parser): void
|
2017-01-10 01:21:57 +00:00
|
|
|
{
|
|
|
|
$parser->match(Lexer::T_IDENTIFIER);
|
|
|
|
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
|
|
|
|
|
|
|
$this->dateExpression = $parser->ArithmeticPrimary();
|
|
|
|
|
|
|
|
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
|
|
|
}
|
|
|
|
|
2023-03-28 20:01:56 +00:00
|
|
|
public function getSql(SqlWalker $sqlWalker): string
|
2017-01-10 01:21:57 +00:00
|
|
|
{
|
|
|
|
return 'date_trunc(\'day\', '.$this->dateExpression->dispatch($sqlWalker).')';
|
|
|
|
}
|
2023-03-28 20:01:56 +00:00
|
|
|
}
|