|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/* |
| 6 | + * Copyright (C) 2025 Daniel Siepmann <coding@daniel-siepmann.de> |
| 7 | + * |
| 8 | + * This program is free software; you can redistribute it and/or |
| 9 | + * modify it under the terms of the GNU General Public License |
| 10 | + * as published by the Free Software Foundation; either version 2 |
| 11 | + * of the License, or (at your option) any later version. |
| 12 | + * |
| 13 | + * This program is distributed in the hope that it will be useful, |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + * GNU General Public License for more details. |
| 17 | + * |
| 18 | + * You should have received a copy of the GNU General Public License |
| 19 | + * along with this program; if not, write to the Free Software |
| 20 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 21 | + * 02110-1301, USA. |
| 22 | + */ |
| 23 | + |
| 24 | +namespace Codappix\Typo3PhpDatasets; |
| 25 | + |
| 26 | +use TYPO3\CMS\Core\Database\Connection as Typo3Connection; |
| 27 | + |
| 28 | +/** |
| 29 | + * @internal |
| 30 | + */ |
| 31 | +final readonly class Connection |
| 32 | +{ |
| 33 | + public function __construct( |
| 34 | + private Typo3Connection $typo3Connection, |
| 35 | + ) { |
| 36 | + } |
| 37 | + |
| 38 | + public function insert(string $tableName, array $record, array $types): void |
| 39 | + { |
| 40 | + $this->typo3Connection->insert($tableName, $record, $types); |
| 41 | + } |
| 42 | + |
| 43 | + public function getTable(string $tableName): Table |
| 44 | + { |
| 45 | + foreach ($this->typo3Connection->createSchemaManager()->listTables() as $table) { |
| 46 | + if ($table->getObjectName()->toString() === $tableName) { |
| 47 | + return new Table($table); |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + throw new \RuntimeException('Could not fetch table details for table: ' . $tableName, 1760939710); |
| 52 | + } |
| 53 | +} |
0 commit comments