1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Happyr Doctrine Specification package. |
5
|
|
|
* |
6
|
|
|
* (c) Tobias Nyholm <[email protected]> |
7
|
|
|
* Kacper Gunia <[email protected]> |
8
|
|
|
* Peter Gribanov <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Happyr\DoctrineSpecification\Specification; |
15
|
|
|
|
16
|
|
|
use Doctrine\ORM\QueryBuilder; |
17
|
|
|
use Happyr\DoctrineSpecification\Filter\Filter; |
18
|
|
|
use Happyr\DoctrineSpecification\Query\QueryModifier; |
19
|
|
|
|
20
|
|
|
@trigger_error('The '.__NAMESPACE__.'\Having class is deprecated since version 1.1 and will be removed in 2.0, use \Happyr\DoctrineSpecification\Query\Having instead.', E_USER_DEPRECATED); |
|
|
|
|
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @deprecated This class is deprecated since version 1.1 and will be removed in 2.0, use \Happyr\DoctrineSpecification\Query\Having instead. |
24
|
|
|
*/ |
25
|
|
View Code Duplication |
class Having implements Specification |
|
|
|
|
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var Filter|QueryModifier|string |
29
|
|
|
*/ |
30
|
|
|
protected $child; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param Filter|QueryModifier|string $child |
34
|
|
|
*/ |
35
|
|
|
public function __construct($child) |
36
|
|
|
{ |
37
|
|
|
$this->child = $child; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param QueryBuilder $qb |
42
|
|
|
* @param string $dqlAlias |
43
|
|
|
*/ |
44
|
|
|
public function modify(QueryBuilder $qb, $dqlAlias) |
45
|
|
|
{ |
46
|
|
|
if ($this->child instanceof QueryModifier) { |
47
|
|
|
$this->child->modify($qb, $dqlAlias); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
if ($this->child instanceof Filter) { |
51
|
|
|
$qb->having($this->child->getFilter($qb, $dqlAlias)); |
52
|
|
|
} else { |
53
|
|
|
$qb->having($this->child); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param QueryBuilder $qb |
59
|
|
|
* @param string $dqlAlias |
60
|
|
|
* |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
|
|
public function getFilter(QueryBuilder $qb, $dqlAlias) |
64
|
|
|
{ |
65
|
|
|
return ''; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
If you suppress an error, we recommend checking for the error condition explicitly: