| 1: | <?php |
| 2: | namespace TIC\DormBundle\Hydration; |
| 3: | |
| 4: | use Doctrine\ORM\Internal\Hydration\AbstractHydrator; |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | class KeyvalHydrator extends AbstractHydrator |
| 15: | { |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | protected function hydrateAllData(): array |
| 23: | { |
| 24: | $result = array(); |
| 25: | |
| 26: | |
| 27: | while ($data = $this->statement()->fetchNumeric()) { |
| 28: | if (! \is_array($data) || \count($data) < 2) continue; |
| 29: | |
| 30: | $key = $data[0]; |
| 31: | if ($key === null) $key = '[_NULL_]'; |
| 32: | elseif ($key === '') $key = '[_EMPTY_]'; |
| 33: | |
| 34: | $result[ $key ] = (\count($data) > 1) ? $data[1] : $data[0]; |
| 35: | } |
| 36: | |
| 37: | return $result; |
| 38: | } |
| 39: | |
| 40: | } |
| 41: | |