1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[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 Sonata\AdminBundle\Tests\App\Model; |
15
|
|
|
|
16
|
|
|
use Sonata\AdminBundle\Admin\FieldDescriptionInterface; |
17
|
|
|
use Sonata\AdminBundle\Datagrid\DatagridInterface; |
18
|
|
|
use Sonata\AdminBundle\Datagrid\ProxyQueryInterface; |
19
|
|
|
use Sonata\AdminBundle\Model\LockInterface; |
20
|
|
|
use Sonata\AdminBundle\Model\ModelManagerInterface; |
21
|
|
|
use Sonata\AdminBundle\Tests\App\Admin\FieldDescription; |
22
|
|
|
|
23
|
|
|
class ModelManager implements ModelManagerInterface, LockInterface |
24
|
|
|
{ |
25
|
|
|
private $repository; |
26
|
|
|
|
27
|
|
|
public function __construct(FooRepository $repository) |
28
|
|
|
{ |
29
|
|
|
$this->repository = $repository; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function getNewFieldDescriptionInstance($class, $name, array $options = []) |
33
|
|
|
{ |
34
|
|
|
if (!isset($options['route']['name'])) { |
35
|
|
|
$options['route']['name'] = 'edit'; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
if (!isset($options['route']['parameters'])) { |
39
|
|
|
$options['route']['parameters'] = []; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
$fieldDescription = new FieldDescription(); |
43
|
|
|
$fieldDescription->setName($name); |
44
|
|
|
$fieldDescription->setOptions($options); |
45
|
|
|
|
46
|
|
|
return $fieldDescription; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function create($object) |
50
|
|
|
{ |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function update($object) |
54
|
|
|
{ |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function delete($object) |
58
|
|
|
{ |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function findBy($class, array $criteria = []) |
62
|
|
|
{ |
63
|
|
|
return []; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function findOneBy($class, array $criteria = []) |
67
|
|
|
{ |
68
|
|
|
return null; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function find($class, $id) |
72
|
|
|
{ |
73
|
|
|
return $this->repository->byId($id); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function batchDelete($class, ProxyQueryInterface $queryProxy) |
77
|
|
|
{ |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function getParentFieldDescription($parentAssociationMapping, $class) |
81
|
|
|
{ |
82
|
|
|
throw new \BadMethodCallException('Not implemented.'); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function createQuery($class, $alias = 'o') |
86
|
|
|
{ |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function getModelIdentifier($class) |
|
|
|
|
90
|
|
|
{ |
91
|
|
|
return 'id'; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function getIdentifierValues($model) |
95
|
|
|
{ |
96
|
|
|
return []; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function getIdentifierFieldNames($class) |
100
|
|
|
{ |
101
|
|
|
return []; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function getNormalizedIdentifier($model) |
105
|
|
|
{ |
106
|
|
|
return $model->getId(); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function getUrlSafeIdentifier($model) |
110
|
|
|
{ |
111
|
|
|
return $this->getNormalizedIdentifier($model); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public function getModelInstance($class) |
115
|
|
|
{ |
116
|
|
|
return new Foo('test_id', 'foo_name'); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function getModelCollectionInstance($class) |
120
|
|
|
{ |
121
|
|
|
return []; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function collectionRemoveElement(&$collection, &$element) |
125
|
|
|
{ |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
public function collectionAddElement(&$collection, &$element) |
129
|
|
|
{ |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function collectionHasElement(&$collection, &$element) |
133
|
|
|
{ |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
public function collectionClear(&$collection) |
137
|
|
|
{ |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
public function getSortParameters(FieldDescriptionInterface $fieldDescription, DatagridInterface $datagrid) |
141
|
|
|
{ |
142
|
|
|
return []; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
public function getDefaultSortValues($class) |
146
|
|
|
{ |
147
|
|
|
return []; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
public function modelReverseTransform($class, array $array = []) |
151
|
|
|
{ |
152
|
|
|
throw new \BadMethodCallException('Not implemented.'); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
public function modelTransform($class, $instance) |
156
|
|
|
{ |
157
|
|
|
throw new \BadMethodCallException('Not implemented.'); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
public function executeQuery($query) |
161
|
|
|
{ |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
public function getDataSourceIterator(DatagridInterface $datagrid, array $fields, $firstResult = null, $maxResult = null) |
165
|
|
|
{ |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
public function getExportFields($class) |
169
|
|
|
{ |
170
|
|
|
return []; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
public function getPaginationParameters(DatagridInterface $datagrid, $page) |
174
|
|
|
{ |
175
|
|
|
return []; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
public function addIdentifiersToQuery($class, ProxyQueryInterface $query, array $idx) |
179
|
|
|
{ |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
public function getLockVersion($object) |
183
|
|
|
{ |
184
|
|
|
return null; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
public function lock($object, $expectedVersion) |
188
|
|
|
{ |
189
|
|
|
} |
190
|
|
|
} |
191
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.