‪TYPO3CMS  ‪main
TypeInlineFalSelectSingle12Foreign.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 
25 
33 {
41  protected static ‪$first = true;
42 
46  protected ‪$matchArray = [
47  'fieldName' => 'fal_1',
48  'fieldConfig' => [
49  'label' => 'fal_1 selicon_field',
50  'config' => [
51  'type' => 'file',
52  'maxitems' => 1,
53  ],
54  ],
55  ];
56 
63  public function ‪generate(array $data): string
64  {
65  $recordFinder = GeneralUtility::makeInstance(RecordFinder::class);
66  $demoImages = $recordFinder->findDemoFileObjects();
67  $recordData = [];
68  if (self::$first) {
69  $demoImage = $demoImages['bus_lane.jpg'];
70  self::$first = false;
71  } else {
72  $demoImage = $demoImages['telephone_box.jpg'];
73  }
74  $newId = ‪StringUtility::getUniqueId('NEW');
75  $recordData['sys_file_reference'][$newId] = [
76  'table_local' => 'sys_file',
77  'uid_local' => $demoImage->getUid(),
78  'uid_foreign' => $data['fieldValues']['uid'],
79  'tablenames' => $data['tableName'],
80  'fieldname' => $data['fieldName'],
81  'pid' => $data['fieldValues']['pid'],
82  ];
83  // Populate page tree via recordDataHandler
84  $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
85  $dataHandler->enableLogging = false;
86  $dataHandler->start($recordData, []);
87  $dataHandler->process_datamap();
88  return (string)1;
89  }
90 }
‪TYPO3\CMS\Core\DataHandling\DataHandler
Definition: DataHandler.php:94
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\AbstractFieldGenerator
Definition: AbstractFieldGenerator.php:29
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\TypeInlineFalSelectSingle12Foreign\generate
‪string generate(array $data)
Definition: TypeInlineFalSelectSingle12Foreign.php:61
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\TypeInlineFalSelectSingle12Foreign\$first
‪static bool $first
Definition: TypeInlineFalSelectSingle12Foreign.php:40
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\TypeInlineFalSelectSingle12Foreign
Definition: TypeInlineFalSelectSingle12Foreign.php:33
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator
Definition: AbstractFieldGenerator.php:18
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGeneratorInterface
Definition: FieldGeneratorInterface.php:26
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator\TypeInlineFalSelectSingle12Foreign\$matchArray
‪array $matchArray
Definition: TypeInlineFalSelectSingle12Foreign.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:24
‪TYPO3\CMS\Styleguide\TcaDataGenerator\RecordFinder
Definition: RecordFinder.php:38
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static getUniqueId(string $prefix='')
Definition: StringUtility.php:57