Conditions | 3 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
15 | public function getNames(?string $site = null): array |
||
16 | { |
||
17 | $connection = $this->getEntityManager()->getConnection(); |
||
|
|||
18 | $table = $this->getClassMetadata()->getTableName(); |
||
19 | $table = $connection->quoteIdentifier($table); |
||
20 | |||
21 | $where = $site ? ' WHERE site = ' . $connection->quote($site) : ''; |
||
22 | $sql = 'SELECT id, name FROM ' . $table . $where . ' ORDER BY name ASC'; |
||
23 | |||
24 | $records = $connection->executeQuery($sql)->fetchAllAssociative(); |
||
25 | |||
26 | $result = []; |
||
27 | foreach ($records as $r) { |
||
28 | $result[$r['name']] = $r['id']; |
||
29 | } |
||
30 | |||
31 | return $result; |
||
32 | } |
||
34 |