‪TYPO3CMS  9.5
TcaPreparation.php
Go to the documentation of this file.
1 <?php
2 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 
21 
28 {
29 
43  public function ‪prepare(array ‪$tca): array
44  {
46  return ‪$tca;
47  }
48 
55  protected function ‪prepareQuotingOfTableNamesAndColumnNames(array ‪$tca): array
56  {
57  $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
58 
59  $newTca = ‪$tca;
60  $configToPrepareQuoting = [
61  'foreign_table_where',
62  'MM_table_where',
63  'search' => 'andWhere'
64  ];
65  foreach (‪$tca as $table => $tableDefinition) {
66  if (!isset($tableDefinition['columns']) || !is_array($tableDefinition['columns'])) {
67  continue;
68  }
69 
70  foreach ($tableDefinition['columns'] as $columnName => $columnConfig) {
71  foreach ($configToPrepareQuoting as $level => $value) {
72  if (is_string($level)) {
73  $sqlQueryPartToPrepareQuotingIn = $columnConfig['config'][$level][$value] ?? '';
74  } else {
75  $sqlQueryPartToPrepareQuotingIn = $columnConfig['config'][$value] ?? '';
76  }
77  if (mb_strpos($sqlQueryPartToPrepareQuotingIn, '{#') !== false) {
79  $connectionPool->getConnectionForTable($table),
80  $sqlQueryPartToPrepareQuotingIn
81  );
82  if (is_string($level)) {
83  $newTca[$table]['columns'][$columnName]['config'][$level][$value] = $quoted;
84  } else {
85  $newTca[$table]['columns'][$columnName]['config'][$value] = $quoted;
86  }
87  }
88  }
89  }
90  }
91 
92  return $newTca;
93  }
94 }
‪TYPO3\CMS\Core\Database\Query\QueryHelper\quoteDatabaseIdentifiers
‪static string quoteDatabaseIdentifiers(Connection $connection, string $sql)
Definition: QueryHelper.php:217
‪TYPO3\CMS\Core\Preparations\TcaPreparation\prepareQuotingOfTableNamesAndColumnNames
‪array prepareQuotingOfTableNamesAndColumnNames(array $tca)
Definition: TcaPreparation.php:55
‪TYPO3\CMS\Core\Database\Query\QueryHelper
Definition: QueryHelper.php:30
‪TYPO3\CMS\Core\Preparations\TcaPreparation
Definition: TcaPreparation.php:28
‪TYPO3\CMS\Core\Preparations\TcaPreparation\prepare
‪array prepare(array $tca)
Definition: TcaPreparation.php:43
‪$tca
‪$tca
Definition: sys_file_metadata.php:4
‪TYPO3\CMS\Core\Preparations
Definition: TcaPreparation.php:3
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45