Conditions | 5 |
Paths | 1 |
Total Lines | 33 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
36 | protected function createFunction(array $config, Field $field) |
||
37 | { |
||
38 | return function ($node, array $arguments, ResolveInfo $info) { |
||
39 | $resolveConfig = $this->getResolveConfig($info); |
||
40 | |||
41 | $resolveConfig = $resolveConfig + [ |
||
42 | 'array_params' => false, |
||
43 | ]; |
||
44 | |||
45 | if (!isset($resolveConfig['method'])) { |
||
46 | $resolveConfig['method'] = $info->returnType instanceof ListOfType ? |
||
47 | 'findBy' : |
||
48 | 'findOneBy'; |
||
49 | $resolveConfig['array_params'] = true; |
||
50 | } |
||
51 | |||
52 | $repository = $this->om->getRepository($resolveConfig['entity']); |
||
53 | |||
54 | $params = $arguments; |
||
55 | |||
56 | if ($resolveConfig['array_params']) { |
||
57 | $params = [$params]; |
||
58 | } |
||
59 | |||
60 | if (null !== $node) { |
||
61 | array_unshift($params, $node); |
||
62 | } |
||
63 | |||
64 | $result = call_user_func_array([$repository, $resolveConfig['method']], $params); |
||
65 | |||
66 | return $result; |
||
67 | }; |
||
68 | } |
||
69 | } |
||
70 |