mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-19 16:54:25 +00:00
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Chill\MainBundle\Doctrine\DQL;
|
|
|
|
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
|
|
use Doctrine\ORM\Query\Lexer;
|
|
use Doctrine\ORM\Query\Parser;
|
|
use Doctrine\ORM\Query\SqlWalker;
|
|
|
|
class JsonbExistsInArray extends FunctionNode
|
|
{
|
|
private $expr1;
|
|
|
|
private $expr2;
|
|
|
|
public function getSql(SqlWalker $sqlWalker): string
|
|
{
|
|
return sprintf(
|
|
'%s ?? %s',
|
|
$this->expr1->dispatch($sqlWalker),
|
|
$sqlWalker->walkInputParameter($this->expr2)
|
|
);
|
|
}
|
|
|
|
public function parse(Parser $parser): void
|
|
{
|
|
$parser->match(Lexer::T_IDENTIFIER);
|
|
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
|
$this->expr1 = $parser->StringPrimary();
|
|
$parser->match(Lexer::T_COMMA);
|
|
$this->expr2 = $parser->InputParameter();
|
|
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
|
|
}
|
|
}
|