Conditions | 4 |
Paths | 3 |
Total Lines | 24 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
28 | public function createQuery(string $classFqn, string $name) |
||
29 | { |
||
30 | if (null === $metadata = $this->metadataFactory->getMetadataForClass($classFqn)) { |
||
31 | throw new \InvalidArgumentException('Could not locate grid metadata'); |
||
32 | } |
||
33 | |||
34 | $queries = $metadata->getQueries(); |
||
35 | |||
36 | if (!isset($queries[$name])) { |
||
37 | throw new \InvalidArgumentException(sprintf( |
||
38 | 'Query "%s" for "%s" is not known. Known queries: "%s"', |
||
39 | $name, $classFqn, implode('", "', array_keys($queries)) |
||
40 | )); |
||
41 | } |
||
42 | |||
43 | $query = $queries[$name]; |
||
44 | |||
45 | return $this->converter->__invoke([ |
||
46 | 'from' => $classFqn, |
||
47 | 'selects' => $query->getSelects(), |
||
48 | 'joins' => $query->getJoins(), |
||
49 | 'criteria' => $query->getCriteria() ?: null, |
||
50 | ]); |
||
51 | } |
||
52 | } |
||
53 |