‪TYPO3CMS  ‪main
DriverResult.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Doctrine\DBAL\Driver\Middleware\AbstractResultMiddleware;
21 
31 class ‪DriverResult extends AbstractResultMiddleware
32 {
36  public function ‪fetchNumeric(): array|false
37  {
38  return $this->‪mapResourceToString(parent::fetchNumeric());
39  }
40 
44  public function ‪fetchAssociative(): array|false
45  {
46  return $this->‪mapResourceToString(parent::fetchAssociative());
47  }
48 
52  public function ‪fetchOne(): mixed
53  {
54  return $this->‪mapResourceToString(parent::fetchOne());
55  }
56 
60  public function ‪fetchAllNumeric(): array
61  {
62  $data = $this->‪mapResourceToString(parent::fetchAllNumeric());
63  assert(is_array($data));
64  return array_map($this->‪mapResourceToString(...), $data);
65  }
66 
70  public function ‪fetchAllAssociative(): array
71  {
72  $data = $this->‪mapResourceToString(parent::fetchAllAssociative());
73  assert(is_array($data));
74  return array_map($this->‪mapResourceToString(...), $data);
75  }
76 
80  public function ‪fetchFirstColumn(): array
81  {
82  $data = $this->‪mapResourceToString(parent::fetchFirstColumn());
83  assert(is_array($data));
84  return array_map($this->‪mapResourceToString(...), $data);
85  }
86 
93  protected function ‪mapResourceToString(‪$record)
94  {
95  if (is_array(‪$record)) {
96  foreach (‪$record as $k => $value) {
97  if (is_resource($value)) {
98  ‪$record[$k] = stream_get_contents($value);
99  }
100  }
101  }
102  return ‪$record;
103  }
104 }
‪TYPO3\CMS\Core\Database\Driver\DriverResult\fetchAssociative
‪fetchAssociative()
Definition: DriverResult.php:44
‪TYPO3\CMS\Core\Database\Driver\DriverResult\fetchAllAssociative
‪fetchAllAssociative()
Definition: DriverResult.php:70
‪TYPO3\CMS\Core\Database\Driver\DriverResult\fetchAllNumeric
‪fetchAllNumeric()
Definition: DriverResult.php:60
‪TYPO3\CMS\Core\Database\Driver\DriverResult\mapResourceToString
‪mixed mapResourceToString($record)
Definition: DriverResult.php:93
‪TYPO3\CMS\Core\Database\Driver
Definition: CustomPdoResultDriverDecorator.php:18
‪TYPO3\CMS\Core\Database\Driver\DriverResult\fetchFirstColumn
‪fetchFirstColumn()
Definition: DriverResult.php:80
‪TYPO3\CMS\Webhooks\Message\$record
‪identifier readonly int readonly array $record
Definition: PageModificationMessage.php:36
‪TYPO3\CMS\Core\Database\Driver\DriverResult\fetchOne
‪fetchOne()
Definition: DriverResult.php:52
‪TYPO3\CMS\Core\Database\Driver\DriverResult\fetchNumeric
‪fetchNumeric()
Definition: DriverResult.php:36
‪TYPO3\CMS\Core\Database\Driver\DriverResult
Definition: DriverResult.php:32