Completed
Push — master ( a4094f...b681a2 )
by Grégoire
16s queued 12s
created

ModelManager::getUrlSafeIdentifier()   A

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