‪TYPO3CMS  10.4
TcaPreparation.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 
23 
30 {
31 
45  public function ‪prepare(array ‪$tca): array
46  {
48  return ‪$tca;
49  }
50 
57  protected function ‪prepareQuotingOfTableNamesAndColumnNames(array ‪$tca): array
58  {
59  $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
60 
61  $newTca = ‪$tca;
62  $configToPrepareQuoting = [
63  'foreign_table_where',
64  'MM_table_where',
65  'search' => 'andWhere'
66  ];
67  foreach (‪$tca as $table => $tableDefinition) {
68  if (!isset($tableDefinition['columns']) || !is_array($tableDefinition['columns'])) {
69  continue;
70  }
71 
72  foreach ($tableDefinition['columns'] as $columnName => $columnConfig) {
73  foreach ($configToPrepareQuoting as $level => $value) {
74  if (is_string($level)) {
75  $sqlQueryPartToPrepareQuotingIn = $columnConfig['config'][$level][$value] ?? '';
76  } else {
77  $sqlQueryPartToPrepareQuotingIn = $columnConfig['config'][$value] ?? '';
78  }
79  if (mb_strpos($sqlQueryPartToPrepareQuotingIn, '{#') !== false) {
81  $connectionPool->getConnectionForTable($table),
82  $sqlQueryPartToPrepareQuotingIn
83  );
84  if (is_string($level)) {
85  $newTca[$table]['columns'][$columnName]['config'][$level][$value] = $quoted;
86  } else {
87  $newTca[$table]['columns'][$columnName]['config'][$value] = $quoted;
88  }
89  }
90  }
91  }
92  }
93 
94  return $newTca;
95  }
96 }
‪TYPO3\CMS\Core\Database\Query\QueryHelper\quoteDatabaseIdentifiers
‪static string quoteDatabaseIdentifiers(Connection $connection, string $sql)
Definition: QueryHelper.php:219
‪TYPO3\CMS\Core\Preparations\TcaPreparation\prepareQuotingOfTableNamesAndColumnNames
‪array prepareQuotingOfTableNamesAndColumnNames(array $tca)
Definition: TcaPreparation.php:57
‪TYPO3\CMS\Core\Database\Query\QueryHelper
Definition: QueryHelper.php:32
‪TYPO3\CMS\Core\Preparations\TcaPreparation
Definition: TcaPreparation.php:30
‪TYPO3\CMS\Core\Preparations\TcaPreparation\prepare
‪array prepare(array $tca)
Definition: TcaPreparation.php:45
‪$tca
‪$tca
Definition: sys_file_metadata.php:5
‪TYPO3\CMS\Core\Preparations
Definition: TcaPreparation.php:18
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46