@@ -187,6 +187,7 @@ |
||
187 | 187 | |
188 | 188 | /** |
189 | 189 | * {@inheritdoc} |
190 | + * @param string $field |
|
190 | 191 | */ |
191 | 192 | private function getFieldName($field) |
192 | 193 | { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | { |
77 | 77 | $this->queryBuilder->setParameter($field, $value); |
78 | 78 | |
79 | - return $this->queryBuilder->expr()->eq($this->getFieldName($field), ':'.$field); |
|
79 | + return $this->queryBuilder->expr()->eq($this->getFieldName($field), ':' . $field); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | { |
87 | 87 | $this->queryBuilder->setParameter($field, $value); |
88 | 88 | |
89 | - return $this->queryBuilder->expr()->neq($this->getFieldName($field), ':'.$field); |
|
89 | + return $this->queryBuilder->expr()->neq($this->getFieldName($field), ':' . $field); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function lessThan($field, $value) |
96 | 96 | { |
97 | - $this->queryBuilder->andWhere($this->getFieldName($field).' < :'.$field)->setParameter($field, $value); |
|
97 | + $this->queryBuilder->andWhere($this->getFieldName($field) . ' < :' . $field)->setParameter($field, $value); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function lessThanOrEqual($field, $value) |
104 | 104 | { |
105 | - $this->queryBuilder->andWhere($this->getFieldName($field).' =< :'.$field)->setParameter($field, $value); |
|
105 | + $this->queryBuilder->andWhere($this->getFieldName($field) . ' =< :' . $field)->setParameter($field, $value); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function greaterThan($field, $value) |
112 | 112 | { |
113 | - $this->queryBuilder->andWhere($this->getFieldName($field).' > :'.$field)->setParameter($field, $value); |
|
113 | + $this->queryBuilder->andWhere($this->getFieldName($field) . ' > :' . $field)->setParameter($field, $value); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function greaterThanOrEqual($field, $value) |
120 | 120 | { |
121 | - $this->queryBuilder->andWhere($this->getFieldName($field).' => :%s'.$field)->setParameter($field, $value); |
|
121 | + $this->queryBuilder->andWhere($this->getFieldName($field) . ' => :%s' . $field)->setParameter($field, $value); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | private function getFieldName($field) |
192 | 192 | { |
193 | 193 | if (false === strpos($field, '.')) { |
194 | - return $this->queryBuilder->getRootAlias().'.'.$field; |
|
194 | + return $this->queryBuilder->getRootAlias() . '.' . $field; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | return $field; |
@@ -175,6 +175,9 @@ |
||
175 | 175 | return Driver::QB_SOURCE_ALIAS . '.' . $field; |
176 | 176 | } |
177 | 177 | |
178 | + /** |
|
179 | + * @param string $field |
|
180 | + */ |
|
178 | 181 | private function getInConstraint(AbstractNode $parentNode, $field, array $values) |
179 | 182 | { |
180 | 183 | $orNode = $parentNode->orx(); |
@@ -11,14 +11,13 @@ |
||
11 | 11 | |
12 | 12 | namespace Sylius\Bundle\GridBundle\Doctrine\PHPCRODM; |
13 | 13 | |
14 | -use Sylius\Component\Grid\Data\ExpressionBuilderInterface; |
|
15 | -use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder; |
|
16 | -use Doctrine\Common\Collections\Expr\CompositeExpression; |
|
17 | 14 | use Doctrine\Common\Collections\Expr\Comparison; |
15 | +use Doctrine\Common\Collections\Expr\CompositeExpression; |
|
16 | +use Doctrine\Common\Collections\Expr\Expression; |
|
18 | 17 | use Doctrine\Common\Collections\Expr\Value; |
19 | 18 | use Doctrine\ODM\PHPCR\Query\Builder\AbstractNode; |
20 | 19 | use Doctrine\ODM\PHPCR\Query\Builder\OperandFactory; |
21 | -use Doctrine\Common\Collections\Expr\Expression; |
|
20 | +use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder; |
|
22 | 21 | use Sylius\Bundle\GridBundle\Doctrine\PHPCRODM\ExtraComparison; |
23 | 22 | |
24 | 23 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function walkCompositeExpression(CompositeExpression $expr, AbstractNode $parentNode) |
107 | 107 | { |
108 | - switch($expr->getType()) { |
|
108 | + switch ($expr->getType()) { |
|
109 | 109 | case CompositeExpression::TYPE_AND: |
110 | 110 | $node = $parentNode->andX(); |
111 | 111 | break; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | break; |
129 | 129 | } |
130 | 130 | |
131 | - switch($expr->getType()) { |
|
131 | + switch ($expr->getType()) { |
|
132 | 132 | case CompositeExpression::TYPE_AND: |
133 | 133 | $parentNode = $parentNode->andX(); |
134 | 134 | break; |
@@ -15,7 +15,6 @@ |
||
15 | 15 | use Doctrine\ORM\EntityRepository; |
16 | 16 | use Doctrine\ORM\QueryBuilder; |
17 | 17 | use PhpSpec\ObjectBehavior; |
18 | -use Prophecy\Argument; |
|
19 | 18 | use Sylius\Bundle\GridBundle\Doctrine\ORM\DataSource; |
20 | 19 | use Sylius\Bundle\GridBundle\Doctrine\ORM\Driver; |
21 | 20 | use Sylius\Component\Grid\Data\DriverInterface; |
@@ -11,14 +11,13 @@ |
||
11 | 11 | |
12 | 12 | namespace spec\Sylius\Bundle\GridBundle\Doctrine\PHPCRODM; |
13 | 13 | |
14 | -use PhpSpec\ObjectBehavior; |
|
15 | -use Prophecy\Argument; |
|
16 | -use Sylius\Component\Grid\Data\DriverInterface; |
|
17 | -use Sylius\Component\Grid\Parameters; |
|
18 | 14 | use Doctrine\ODM\PHPCR\DocumentManagerInterface; |
19 | 15 | use Doctrine\ODM\PHPCR\DocumentRepository; |
20 | 16 | use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder; |
17 | +use PhpSpec\ObjectBehavior; |
|
21 | 18 | use Sylius\Bundle\GridBundle\Doctrine\PHPCRODM\DataSource; |
19 | +use Sylius\Component\Grid\Data\DriverInterface; |
|
20 | +use Sylius\Component\Grid\Parameters; |
|
22 | 21 | |
23 | 22 | /** |
24 | 23 | * @mixin Driver |
@@ -11,11 +11,10 @@ |
||
11 | 11 | |
12 | 12 | namespace spec\Sylius\Bundle\GridBundle\Doctrine\PHPCRODM; |
13 | 13 | |
14 | -use PhpSpec\ObjectBehavior; |
|
15 | -use Prophecy\Argument; |
|
14 | +use Doctrine\Common\Collections\Expr\Comparison; |
|
16 | 15 | use Doctrine\Common\Collections\ExpressionBuilder as CollectionsExpressionBuilder; |
16 | +use PhpSpec\ObjectBehavior; |
|
17 | 17 | use Sylius\Bundle\GridBundle\Doctrine\PHPCRODM\ExpressionBuilder; |
18 | -use Doctrine\Common\Collections\Expr\Comparison; |
|
19 | 18 | use Sylius\Bundle\GridBundle\Doctrine\PHPCRODM\ExtraComparison; |
20 | 19 | |
21 | 20 | class ExpressionBuilderSpec extends ObjectBehavior |
@@ -33,8 +33,7 @@ discard block |
||
33 | 33 | function it_builds_andx( |
34 | 34 | Comparison $comparison, |
35 | 35 | CollectionsExpressionBuilder $expressionBuilder |
36 | - ) |
|
37 | - { |
|
36 | + ) { |
|
38 | 37 | $this->andX([$comparison]); |
39 | 38 | $expressionBuilder->andX([$comparison])->shouldHaveBeenCalled(); |
40 | 39 | } |
@@ -42,64 +41,56 @@ discard block |
||
42 | 41 | function it_builds_orx( |
43 | 42 | Comparison $comparison, |
44 | 43 | CollectionsExpressionBuilder $expressionBuilder |
45 | - ) |
|
46 | - { |
|
44 | + ) { |
|
47 | 45 | $this->orX([$comparison]); |
48 | 46 | $expressionBuilder->orX([$comparison])->shouldHaveBeenCalled(); |
49 | 47 | } |
50 | 48 | |
51 | 49 | function it_builds_equals( |
52 | 50 | CollectionsExpressionBuilder $expressionBuilder |
53 | - ) |
|
54 | - { |
|
51 | + ) { |
|
55 | 52 | $this->equals('o.foo', 'value'); |
56 | 53 | $expressionBuilder->eq('o.foo', 'value')->shouldHaveBeenCalled(); |
57 | 54 | } |
58 | 55 | |
59 | 56 | function it_builds_not_equals( |
60 | 57 | CollectionsExpressionBuilder $expressionBuilder |
61 | - ) |
|
62 | - { |
|
58 | + ) { |
|
63 | 59 | $this->notEquals('o.foo', 'value'); |
64 | 60 | $expressionBuilder->neq('o.foo', 'value')->shouldHaveBeenCalled(); |
65 | 61 | } |
66 | 62 | |
67 | 63 | function it_builds_less_than_or_equal( |
68 | 64 | CollectionsExpressionBuilder $expressionBuilder |
69 | - ) |
|
70 | - { |
|
65 | + ) { |
|
71 | 66 | $this->lessThanOrEqual('o.foo', 'value'); |
72 | 67 | $expressionBuilder->lte('o.foo', 'value')->shouldHaveBeenCalled(); |
73 | 68 | } |
74 | 69 | |
75 | 70 | function it_builds_greater_than( |
76 | 71 | CollectionsExpressionBuilder $expressionBuilder |
77 | - ) |
|
78 | - { |
|
72 | + ) { |
|
79 | 73 | $this->greaterThan('o.foo', 'value'); |
80 | 74 | $expressionBuilder->gt('o.foo', 'value')->shouldHaveBeenCalled(); |
81 | 75 | } |
82 | 76 | |
83 | 77 | function it_builds_greater_than_or_equal( |
84 | 78 | CollectionsExpressionBuilder $expressionBuilder |
85 | - ) |
|
86 | - { |
|
79 | + ) { |
|
87 | 80 | $this->greaterThanOrequal('o.foo', 'value'); |
88 | 81 | $expressionBuilder->gte('o.foo', 'value')->shouldHaveBeenCalled(); |
89 | 82 | } |
90 | 83 | |
91 | 84 | function it_builds_in( |
92 | 85 | CollectionsExpressionBuilder $expressionBuilder |
93 | - ) |
|
94 | - { |
|
86 | + ) { |
|
95 | 87 | $this->in('o.foo', ['value']); |
96 | 88 | $expressionBuilder->in('o.foo', ['value'])->shouldHaveBeenCalled(); |
97 | 89 | } |
98 | 90 | |
99 | 91 | function it_builds_not_in( |
100 | 92 | CollectionsExpressionBuilder $expressionBuilder |
101 | - ) |
|
102 | - { |
|
93 | + ) { |
|
103 | 94 | $this->notIn('o.foo', ['value']); |
104 | 95 | $expressionBuilder->notIn('o.foo', ['value'])->shouldHaveBeenCalled(); |
105 | 96 | } |
@@ -120,8 +111,7 @@ discard block |
||
120 | 111 | |
121 | 112 | function it_builds_like( |
122 | 113 | CollectionsExpressionBuilder $expressionBuilder |
123 | - ) |
|
124 | - { |
|
114 | + ) { |
|
125 | 115 | $this->like('o.foo', 'value'); |
126 | 116 | $expressionBuilder->contains('o.foo', 'value')->shouldHaveBeenCalled(); |
127 | 117 | } |
@@ -12,7 +12,6 @@ |
||
12 | 12 | namespace spec\Sylius\Bundle\GridBundle\FieldTypes; |
13 | 13 | |
14 | 14 | use PhpSpec\ObjectBehavior; |
15 | -use Prophecy\Argument; |
|
16 | 15 | use Sylius\Bundle\GridBundle\FieldTypes\TwigFieldType; |
17 | 16 | use Sylius\Component\Grid\DataExtractor\DataExtractorInterface; |
18 | 17 | use Sylius\Component\Grid\Definition\Field; |
@@ -12,7 +12,6 @@ |
||
12 | 12 | namespace spec\Sylius\Bundle\GridBundle\Templating\Helper; |
13 | 13 | |
14 | 14 | use PhpSpec\ObjectBehavior; |
15 | -use Prophecy\Argument; |
|
16 | 15 | use Sylius\Bundle\GridBundle\Templating\Helper\GridHelper; |
17 | 16 | use Sylius\Component\Grid\Definition\Action; |
18 | 17 | use Sylius\Component\Grid\Definition\Field; |
@@ -12,7 +12,6 @@ |
||
12 | 12 | namespace spec\Sylius\Bundle\GridBundle\Twig; |
13 | 13 | |
14 | 14 | use PhpSpec\ObjectBehavior; |
15 | -use Prophecy\Argument; |
|
16 | 15 | use Sylius\Bundle\GridBundle\Templating\Helper\GridHelper; |
17 | 16 | use Sylius\Bundle\GridBundle\Twig\GridExtension; |
18 | 17 | use Sylius\Component\Grid\Definition\Action; |
@@ -11,15 +11,12 @@ |
||
11 | 11 | |
12 | 12 | namespace Sylius\Bundle\GridBundle\Tests\DependencyInjection; |
13 | 13 | |
14 | -use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder; |
|
15 | -use Sylius\Bundle\GridBundle\Doctrine\PHPCRODM\ExpressionVisitor; |
|
16 | 14 | use Doctrine\Common\Collections\Expr\Comparison; |
17 | -use Doctrine\ODM\PHPCR\Query\Builder\AbstractNode; |
|
18 | -use Doctrine\ODM\PHPCR\Query\Builder\AbstractLeafNode; |
|
15 | +use Doctrine\Common\Collections\Expr\CompositeExpression; |
|
19 | 16 | use Doctrine\ODM\PHPCR\Query\Builder\OperandDynamicField; |
20 | -use Doctrine\ODM\PHPCR\Query\Builder\ConstraintComparison; |
|
21 | 17 | use Doctrine\ODM\PHPCR\Query\Builder\OperandStaticLiteral; |
22 | -use Doctrine\Common\Collections\Expr\CompositeExpression; |
|
18 | +use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder; |
|
19 | +use Sylius\Bundle\GridBundle\Doctrine\PHPCRODM\ExpressionVisitor; |
|
23 | 20 | use Sylius\Bundle\GridBundle\Doctrine\PHPCRODM\ExtraComparison; |
24 | 21 | |
25 | 22 | require(__DIR__ . '/QueryBuilderWalker.php'); |
@@ -108,17 +108,17 @@ discard block |
||
108 | 108 | return [ |
109 | 109 | [ |
110 | 110 | Comparison::IN, |
111 | - [ 'one' ], |
|
111 | + ['one'], |
|
112 | 112 | 'ConstraintOrx ( jcr.operator.equal.to ( OperandDynamicField(o.hello) OperandStaticLiteral("one") ) )' |
113 | 113 | ], |
114 | 114 | [ |
115 | 115 | Comparison::IN, |
116 | - [ 'one', 'two', 'three' ], |
|
116 | + ['one', 'two', 'three'], |
|
117 | 117 | 'ConstraintOrx ( jcr.operator.equal.to ( OperandDynamicField(o.hello) OperandStaticLiteral("one") ) jcr.operator.equal.to ( OperandDynamicField(o.hello) OperandStaticLiteral("two") ) jcr.operator.equal.to ( OperandDynamicField(o.hello) OperandStaticLiteral("three") ) )', |
118 | 118 | ], |
119 | 119 | [ |
120 | 120 | Comparison::NIN, |
121 | - [ 'one' ], |
|
121 | + ['one'], |
|
122 | 122 | 'ConstraintNot ( ConstraintOrx ( jcr.operator.equal.to ( OperandDynamicField(o.hello) OperandStaticLiteral("one") ) ) )' |
123 | 123 | ], |
124 | 124 | ]; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $expr2 = new Comparison('number', Comparison::GT, 8); |
134 | 134 | $expr = new CompositeExpression( |
135 | 135 | $type, |
136 | - [ $expr1, $expr2 ] |
|
136 | + [$expr1, $expr2] |
|
137 | 137 | ); |
138 | 138 | |
139 | 139 | $this->visitor->dispatch($expr); |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | public function provideComposite() |
154 | 154 | { |
155 | 155 | return [ |
156 | - [ CompositeExpression::TYPE_AND, 'ConstraintAndx' ], |
|
157 | - [ CompositeExpression::TYPE_OR, 'ConstraintOrx' ] |
|
156 | + [CompositeExpression::TYPE_AND, 'ConstraintAndx'], |
|
157 | + [CompositeExpression::TYPE_OR, 'ConstraintOrx'] |
|
158 | 158 | ]; |
159 | 159 | } |
160 | 160 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $expr3 = new Comparison('date', Comparison::GT, '2015-12-10'); |
167 | 167 | $expr = new CompositeExpression( |
168 | 168 | $type, |
169 | - [ $expr1, $expr2, $expr3 ] |
|
169 | + [$expr1, $expr2, $expr3] |
|
170 | 170 | ); |
171 | 171 | |
172 | 172 | $this->visitor->dispatch($expr); |
@@ -197,12 +197,12 @@ discard block |
||
197 | 197 | $expr4 = new Comparison('date', Comparison::LT, '2016-12-10'); |
198 | 198 | $expr5 = new Comparison('date', Comparison::NEQ, '2016-12-10'); |
199 | 199 | |
200 | - $comp2 = new CompositeExpression(CompositeExpression::TYPE_AND, [ $expr2, $expr5 ]); |
|
201 | - $comp1 = new CompositeExpression(CompositeExpression::TYPE_OR, [ $expr1, $comp2 ]); |
|
200 | + $comp2 = new CompositeExpression(CompositeExpression::TYPE_AND, [$expr2, $expr5]); |
|
201 | + $comp1 = new CompositeExpression(CompositeExpression::TYPE_OR, [$expr1, $comp2]); |
|
202 | 202 | |
203 | 203 | $expr = new CompositeExpression( |
204 | 204 | $type, |
205 | - [ $comp1, $expr3, $expr4 ] |
|
205 | + [$comp1, $expr3, $expr4] |
|
206 | 206 | ); |
207 | 207 | |
208 | 208 | $this->visitor->dispatch($expr); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | OperandDynamicField(o.number) OperandStaticLiteral("8") |
147 | 147 | ) |
148 | 148 | ) |
149 | -EOT |
|
149 | +eot |
|
150 | 150 | ); |
151 | 151 | } |
152 | 152 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | ) |
185 | 185 | ) |
186 | 186 | ) |
187 | -EOT |
|
187 | +eot |
|
188 | 188 | ); |
189 | 189 | } |
190 | 190 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | ) |
231 | 231 | ) |
232 | 232 | ) |
233 | -EOT |
|
233 | +eot |
|
234 | 234 | ); |
235 | 235 | } |
236 | 236 |