ModelManager::getLockVersion()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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
    /**
26
     * @var FooRepository
27
     */
28
    private $repository;
29
30
    public function __construct(FooRepository $repository)
31
    {
32
        $this->repository = $repository;
33
    }
34
35
    public function getNewFieldDescriptionInstance($class, $name, array $options = [])
36
    {
37
        if (!isset($options['route']['name'])) {
38
            $options['route']['name'] = 'edit';
39
        }
40
41
        if (!isset($options['route']['parameters'])) {
42
            $options['route']['parameters'] = [];
43
        }
44
45
        $fieldDescription = new FieldDescription();
46
        $fieldDescription->setName($name);
47
        $fieldDescription->setOptions($options);
48
49
        return $fieldDescription;
50
    }
51
52
    public function create($object): void
53
    {
54
    }
55
56
    public function update($object): void
57
    {
58
    }
59
60
    public function delete($object): void
61
    {
62
    }
63
64
    public function findBy($class, array $criteria = [])
65
    {
66
        return [];
67
    }
68
69
    public function findOneBy($class, array $criteria = [])
70
    {
71
        return null;
72
    }
73
74
    public function find($class, $id)
75
    {
76
        return $this->repository->byId($id);
77
    }
78
79
    public function batchDelete($class, ProxyQueryInterface $queryProxy): void
80
    {
81
    }
82
83
    public function getParentFieldDescription($parentAssociationMapping, $class): FieldDescriptionInterface
0 ignored issues
show
Unused Code introduced by
The parameter $parentAssociationMapping is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $class is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
84
    {
85
        throw new \BadMethodCallException('Not implemented.');
86
    }
87
88
    public function createQuery($class, $alias = 'o'): ProxyQueryInterface
89
    {
90
        throw new \BadMethodCallException('Not implemented.');
91
    }
92
93
    public function getModelIdentifier($class)
0 ignored issues
show
Unused Code introduced by
The parameter $class is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
94
    {
95
        return 'id';
96
    }
97
98
    public function getIdentifierValues($model)
99
    {
100
        return [];
101
    }
102
103
    public function getIdentifierFieldNames($class)
104
    {
105
        return [];
106
    }
107
108
    public function getNormalizedIdentifier($model)
109
    {
110
        return $model->getId();
111
    }
112
113
    public function getUrlSafeIdentifier($model)
114
    {
115
        return $this->getNormalizedIdentifier($model);
116
    }
117
118
    public function getModelInstance($class)
119
    {
120
        switch ($class) {
121
            case Translated::class:
122
                return new Translated();
123
            default:
124
                return new Foo('test_id', 'foo_name');
125
        }
126
    }
127
128
    public function getModelCollectionInstance($class)
129
    {
130
        return [];
131
    }
132
133
    public function collectionRemoveElement(&$collection, &$element): void
134
    {
135
    }
136
137
    public function collectionAddElement(&$collection, &$element): void
138
    {
139
    }
140
141
    public function collectionHasElement(&$collection, &$element): void
142
    {
143
    }
144
145
    public function collectionClear(&$collection): void
146
    {
147
    }
148
149
    public function getSortParameters(FieldDescriptionInterface $fieldDescription, DatagridInterface $datagrid)
0 ignored issues
show
Unused Code introduced by
The parameter $fieldDescription is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $datagrid is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
150
    {
151
        return [];
152
    }
153
154
    public function getDefaultSortValues($class)
155
    {
156
        return [];
157
    }
158
159
    public function getDefaultPerPageOptions(string $class): array
160
    {
161
        return [];
162
    }
163
164
    public function modelReverseTransform($class, array $array = []): object
165
    {
166
        throw new \BadMethodCallException('Not implemented.');
167
    }
168
169
    public function modelTransform($class, $instance): object
170
    {
171
        throw new \BadMethodCallException('Not implemented.');
172
    }
173
174
    public function executeQuery($query): void
175
    {
176
    }
177
178
    public function getDataSourceIterator(DatagridInterface $datagrid, array $fields, $firstResult = null, $maxResult = null): void
179
    {
180
    }
181
182
    public function getExportFields($class)
183
    {
184
        return [];
185
    }
186
187
    public function getPaginationParameters(DatagridInterface $datagrid, $page)
0 ignored issues
show
Unused Code introduced by
The parameter $datagrid is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $page is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
188
    {
189
        return [];
190
    }
191
192
    public function addIdentifiersToQuery($class, ProxyQueryInterface $query, array $idx): void
193
    {
194
    }
195
196
    public function getLockVersion($object)
197
    {
198
        return null;
199
    }
200
201
    public function lock($object, $expectedVersion)
202
    {
203
    }
204
}
205