‪TYPO3CMS  ‪main
RecordService.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 
29 {
33  protected array ‪$records = [];
34 
35  public function ‪add(string $tableName, int $id): void
36  {
37  $databaseRecord = ‪DatabaseRecord::create($tableName, $id);
38  if (!isset($this->records[$databaseRecord->getIdentifier()])) {
39  $this->records[$databaseRecord->getIdentifier()] = $databaseRecord;
40  }
41  }
42 
43  public function ‪getIdsPerTable(): array
44  {
45  $idsPerTable = [];
46  foreach ($this->records as $databaseRecord) {
47  if (!isset($idsPerTable[$databaseRecord->getTable()])) {
48  $idsPerTable[$databaseRecord->getTable()] = [];
49  }
50  $idsPerTable[$databaseRecord->getTable()][] = $databaseRecord->getUid();
51  }
52  return $idsPerTable;
53  }
54 
55  public function ‪getCreateUserIds(): array
56  {
57  $createUserIds = [];
58  $recordHistory = GeneralUtility::makeInstance(RecordHistory::class);
59 
60  foreach ($this->‪getIdsPerTable() as $tableName => $ids) {
61  $historyRecords = $recordHistory->getCreationInformationForMultipleRecords($tableName, $ids);
62  foreach ($historyRecords as $historyRecord) {
63  if ($historyRecord['actiontype'] === 'BE') {
64  $createUserIds[] = (int)$historyRecord['userid'];
65  }
66  }
67  }
68  return array_unique($createUserIds);
69  }
70 }
‪TYPO3\CMS\Workspaces\Service\RecordService\$records
‪array $records
Definition: RecordService.php:33
‪TYPO3\CMS\Workspaces\Service
‪TYPO3\CMS\Workspaces\Service\RecordService\getIdsPerTable
‪getIdsPerTable()
Definition: RecordService.php:43
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord
Definition: DatabaseRecord.php:29
‪TYPO3\CMS\Workspaces\Service\RecordService\add
‪add(string $tableName, int $id)
Definition: RecordService.php:35
‪TYPO3\CMS\Workspaces\Service\RecordService\getCreateUserIds
‪getCreateUserIds()
Definition: RecordService.php:55
‪TYPO3\CMS\Backend\History\RecordHistory
Definition: RecordHistory.php:32
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22
‪TYPO3\CMS\Workspaces\Domain\Model\DatabaseRecord\create
‪static create(string $table, int $uid)
Definition: DatabaseRecord.php:40
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Workspaces\Service\RecordService
Definition: RecordService.php:29