‪TYPO3CMS  ‪main
TypeSelectRenderTypeSingleForeignTable.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 
24 
32 {
36  protected ‪$matchArray = [
37  'fieldName' => 'select_single_12',
38  'fieldConfig' => [
39  'config' => [
40  'type' => 'select',
41  'renderType' => 'selectSingle',
42  'foreign_table' => 'tx_styleguide_elements_select_single_12_foreign',
43  ],
44  ],
45  ];
46 
53  public function ‪generate(array $data): string
54  {
55  $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
56  $connection = $connectionPool->getConnectionForTable('tx_styleguide_elements_select_single_12_foreign');
57  $childFieldValues = [];
58  $childRowsToCreate = 2;
59  for ($i = 0; $i < $childRowsToCreate; $i++) {
60  // Insert an empty row again to have the uid already. This is useful for
61  // possible further inline that may be attached to this child.
62  $childFieldValues = [
63  'pid' => $data['fieldValues']['pid'],
64  ];
65  $connection->insert(
66  'tx_styleguide_elements_select_single_12_foreign',
67  $childFieldValues
68  );
69  $childFieldValues['uid'] = $connection->lastInsertId();
70  $recordData = GeneralUtility::makeInstance(RecordData::class);
71  $childFieldValues = $recordData->generate('tx_styleguide_elements_select_single_12_foreign', $childFieldValues);
72  $connection->update(
73  'tx_styleguide_elements_select_single_12_foreign',
74  $childFieldValues,
75  [ 'uid' => $childFieldValues['uid'] ]
76  );
77  }
78  return (string)$childFieldValues['uid'];
79  }
80 }
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\TypeSelectRenderTypeSingleForeignTable\generate
‪string generate(array $data)
Definition: TypeSelectRenderTypeSingleForeignTable.php:52
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\AbstractFieldGenerator
Definition: AbstractFieldGenerator.php:29
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\TypeSelectRenderTypeSingleForeignTable\$matchArray
‪array $matchArray
Definition: TypeSelectRenderTypeSingleForeignTable.php:35
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\TypeSelectRenderTypeSingleForeignTable
Definition: TypeSelectRenderTypeSingleForeignTable.php:32
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator
Definition: AbstractFieldGenerator.php:18
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGeneratorInterface
Definition: FieldGeneratorInterface.php:26
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Styleguide\TcaDataGenerator\RecordData
Definition: RecordData.php:28