‪TYPO3CMS  9.5
CompositeExpression.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
22 class ‪CompositeExpression extends \Doctrine\DBAL\Query\Expression\CompositeExpression
23 {
31  public function ‪__toString()
32  {
33  if ($this->count() === 0) {
34  return '';
35  }
36  return parent::__toString();
37  }
38 
46  public function ‪add($part)
47  {
48  // Due to a bug in Doctrine DBAL, we must add our own check here,
49  // which we luckily can, as we use a subclass anyway.
50  // @see https://github.com/doctrine/dbal/issues/2388
51  $isEmpty = $part instanceof self ? $part->count() === 0 : empty($part);
52  if (!$isEmpty) {
53  parent::add($part);
54  }
55 
56  return $this;
57  }
58 }
‪TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression\__toString
‪string __toString()
Definition: CompositeExpression.php:31
‪TYPO3\CMS\Core\Database\Query\Expression
Definition: CompositeExpression.php:3
‪TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression
Definition: CompositeExpression.php:23
‪TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression\add
‪Doctrine DBAL Query Expression CompositeExpression add($part)
Definition: CompositeExpression.php:46