1 | <?php |
||
18 | class EntityToIdTransformer implements DataTransformerInterface |
||
19 | { |
||
20 | protected $em; |
||
21 | private $class; |
||
22 | private $multiple; |
||
23 | |||
24 | public function __construct(EntityManager $em, $class, $property, $queryBuilder, $multiple) |
||
38 | |||
39 | public function transform($data) |
||
40 | { |
||
41 | if ($data instanceof Collection) { |
||
42 | return $this->reverseTransform($data); |
||
43 | } |
||
44 | |||
45 | if (null === $data) { |
||
46 | return; |
||
47 | } |
||
48 | |||
49 | if (!$this->multiple) { |
||
50 | return $this->transformSingleEntity($data); |
||
51 | } |
||
52 | |||
53 | if (is_array($data)) |
||
54 | return $data; |
||
55 | |||
56 | $return = []; |
||
57 | $data = explode('#&#', $data); |
||
58 | |||
59 | foreach ($data as $element) { |
||
60 | $return[] = $this->transformSingleEntity($element); |
||
61 | } |
||
62 | |||
63 | return $return; |
||
64 | } |
||
65 | |||
66 | protected function transformSingleEntity($data) |
||
74 | |||
75 | public function reverseTransform($data) |
||
93 | |||
94 | protected function reverseTransformSingleEntity($data) |
||
102 | } |
||
103 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.