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