‪TYPO3CMS  ‪main
TypeSelectRenderTypeSingleForeignTableGroupField.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 {
33  private string ‪$table = 'tx_styleguide_elements_select_single_21_foreign';
34 
38  protected ‪$matchArray = [
39  'fieldName' => 'select_single_21',
40  'fieldConfig' => [
41  'config' => [
42  'type' => 'select',
43  'renderType' => 'selectSingle',
44  'foreign_table' => 'tx_styleguide_elements_select_single_21_foreign',
45  'foreign_table_item_group' => 'item_group',
46  ],
47  ],
48  ];
49 
53  public function ‪generate(array $data): string
54  {
55  $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
56  $connection = $connectionPool->getConnectionForTable($this->table);
57  $groups = ['group3', 'group4', 'group5'];
58  foreach ($groups as $group) {
59  $childFieldValues = [
60  'pid' => $data['fieldValues']['pid'],
61  ];
62  $connection->insert(
63  $this->table,
64  $childFieldValues
65  );
66  ‪$uid = $connection->lastInsertId();
67  $childFieldValues['uid'] = ‪$uid;
68  $childFieldValues['item_group'] = $group;
69  $recordData = GeneralUtility::makeInstance(RecordData::class);
70  $childFieldValues = $recordData->generate($this->table, $childFieldValues);
71  $connection->update(
72  $this->table,
73  $childFieldValues,
74  ['uid' => ‪$uid]
75  );
76  }
77  return (string)$childFieldValues['uid'];
78  }
79 }
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\AbstractFieldGenerator
Definition: AbstractFieldGenerator.php:29
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\TypeSelectRenderTypeSingleForeignTableGroupField
Definition: TypeSelectRenderTypeSingleForeignTableGroupField.php:32
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\TypeSelectRenderTypeSingleForeignTableGroupField\generate
‪generate(array $data)
Definition: TypeSelectRenderTypeSingleForeignTableGroupField.php:52
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator
Definition: AbstractFieldGenerator.php:18
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\TypeSelectRenderTypeSingleForeignTableGroupField\$table
‪string $table
Definition: TypeSelectRenderTypeSingleForeignTableGroupField.php:33
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\TypeSelectRenderTypeSingleForeignTableGroupField\$matchArray
‪array $matchArray
Definition: TypeSelectRenderTypeSingleForeignTableGroupField.php:37
‪TYPO3\CMS\Webhooks\Message\$uid
‪identifier readonly int $uid
Definition: PageModificationMessage.php:35
‪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