1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Doctrine\ORM\Persisters\Collection\Expr; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
use Doctrine\Common\Collections\Expr\Comparison; |
8
|
|
|
use Doctrine\Common\Collections\Expr\CompositeExpression; |
9
|
|
|
use Doctrine\Common\Collections\Expr\ExpressionVisitor; |
10
|
|
|
use Doctrine\Common\Collections\Expr\Value; |
11
|
|
|
use Doctrine\DBAL\Platforms\AbstractPlatform; |
12
|
|
|
use Doctrine\ORM\Mapping\ClassMetadata; |
13
|
|
|
use Doctrine\ORM\Mapping\QuoteStrategy; |
14
|
|
|
|
15
|
|
|
class MappingVisitor extends ExpressionVisitor |
16
|
|
|
{ |
17
|
|
|
/** @var QuoteStrategy */ |
18
|
|
|
private $quoteStrategy; |
19
|
|
|
/** @var ClassMetadata */ |
20
|
|
|
private $metadata; |
21
|
|
|
/** @var AbstractPlatform */ |
22
|
|
|
private $platform; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* MappingVisitor constructor. |
26
|
|
|
* @param QuoteStrategy $quoteStrategy |
27
|
|
|
* @param ClassMetadata $metadata |
28
|
|
|
* @param AbstractPlatform $platform |
29
|
|
|
*/ |
30
|
15 |
|
public function __construct(QuoteStrategy $quoteStrategy, ClassMetadata $metadata, AbstractPlatform $platform) |
31
|
|
|
{ |
32
|
15 |
|
$this->quoteStrategy = $quoteStrategy; |
33
|
15 |
|
$this->metadata = $metadata; |
34
|
15 |
|
$this->platform = $platform; |
35
|
15 |
|
} |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Converts a comparison expression into the target query language output. |
40
|
|
|
* |
41
|
|
|
* @param Comparison $comparison |
42
|
|
|
* |
43
|
|
|
* @return mixed |
44
|
|
|
*/ |
45
|
14 |
|
public function walkComparison(Comparison $comparison) |
46
|
|
|
{ |
47
|
14 |
|
return new Comparison( |
48
|
14 |
|
$this->quoteStrategy->getColumnName($comparison->getField(), $this->metadata, $this->platform), |
49
|
14 |
|
$comparison->getOperator(), |
50
|
14 |
|
$comparison->getValue() |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Converts a value expression into the target query language part. |
56
|
|
|
* |
57
|
|
|
* @param Value $value |
58
|
|
|
* |
59
|
|
|
* @return mixed |
60
|
|
|
*/ |
61
|
1 |
|
public function walkValue(Value $value) |
62
|
|
|
{ |
63
|
1 |
|
return $value; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Converts a composite expression into the target query language output. |
68
|
|
|
* |
69
|
|
|
* @param CompositeExpression $expr |
70
|
|
|
* |
71
|
|
|
* @return mixed |
72
|
|
|
*/ |
73
|
1 |
|
public function walkCompositeExpression(CompositeExpression $expr) |
74
|
|
|
{ |
75
|
1 |
|
$expressions = []; |
76
|
1 |
|
foreach($expr->getExpressionList() as $expression) { |
77
|
1 |
|
$expressions[] = $this->dispatch($expression); |
78
|
|
|
} |
79
|
|
|
|
80
|
1 |
|
return new CompositeExpression($expr->getType(), $expressions); |
81
|
|
|
} |
82
|
|
|
} |