@@ 8-37 (lines=30) @@ | ||
5 | use Doctrine\ORM\QueryBuilder; |
|
6 | use Rb\Specification\Doctrine\AbstractSpecification; |
|
7 | ||
8 | class IsInstanceOf extends AbstractSpecification |
|
9 | { |
|
10 | /** |
|
11 | * @var string |
|
12 | */ |
|
13 | private $className; |
|
14 | ||
15 | /** |
|
16 | * @param string $field |
|
17 | * @param string $className |
|
18 | * @param string $dqlAlias |
|
19 | */ |
|
20 | public function __construct($field, $className, $dqlAlias = null) |
|
21 | { |
|
22 | $this->className = $className; |
|
23 | ||
24 | parent::__construct($field, $dqlAlias); |
|
25 | } |
|
26 | ||
27 | /** |
|
28 | * {@inheritdoc} |
|
29 | */ |
|
30 | public function modify(QueryBuilder $queryBuilder, $dqlAlias) |
|
31 | { |
|
32 | return (string) $queryBuilder->expr()->isInstanceOf( |
|
33 | $this->createPropertyWithAlias($dqlAlias), |
|
34 | $this->className |
|
35 | ); |
|
36 | } |
|
37 | } |
|
38 |
@@ 8-37 (lines=30) @@ | ||
5 | use Doctrine\ORM\QueryBuilder; |
|
6 | use Rb\Specification\Doctrine\AbstractSpecification; |
|
7 | ||
8 | class IsMemberOf extends AbstractSpecification |
|
9 | { |
|
10 | /** |
|
11 | * @var string |
|
12 | */ |
|
13 | private $className; |
|
14 | ||
15 | /** |
|
16 | * @param string $field |
|
17 | * @param string $className |
|
18 | * @param string $dqlAlias |
|
19 | */ |
|
20 | public function __construct($field, $className, $dqlAlias = null) |
|
21 | { |
|
22 | $this->className = $className; |
|
23 | ||
24 | parent::__construct($field, $dqlAlias); |
|
25 | } |
|
26 | ||
27 | /** |
|
28 | * {@inheritdoc} |
|
29 | */ |
|
30 | public function modify(QueryBuilder $queryBuilder, $dqlAlias) |
|
31 | { |
|
32 | return (string) $queryBuilder->expr()->isMemberOf( |
|
33 | $this->createPropertyWithAlias($dqlAlias), |
|
34 | $this->className |
|
35 | ); |
|
36 | } |
|
37 | } |
|
38 |