TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
RecordService.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Workspaces\Service;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
20 
25 {
29  protected $records = [];
30 
35  public function add($tableName, $id)
36  {
37  $databaseRecord = DatabaseRecord::create($tableName, $id);
38  if (!isset($this->records[$databaseRecord->getIdentifier()])) {
39  $this->records[$databaseRecord->getIdentifier()] = $databaseRecord;
40  }
41  }
42 
46  public function getIdsPerTable()
47  {
48  $idsPerTable = [];
49  foreach ($this->records as $databaseRecord) {
50  if (!isset($idsPerTable[$databaseRecord->getTable()])) {
51  $idsPerTable[$databaseRecord->getTable()] = [];
52  }
53  $idsPerTable[$databaseRecord->getTable()][] = $databaseRecord->getUid();
54  }
55  return $idsPerTable;
56  }
57 
61  public function getCreateUserIds()
62  {
63  $createUserIds = [];
64  foreach ($this->getIdsPerTable() as $tableName => $ids) {
65  if (empty($GLOBALS['TCA'][$tableName]['ctrl']['cruser_id'])) {
66  continue;
67  }
68  $createUserIdFieldName = $GLOBALS['TCA'][$tableName]['ctrl']['cruser_id'];
69 
70  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($tableName);
71  $queryBuilder->getRestrictions()->removeAll();
72 
73  $records = $queryBuilder
74  ->select($createUserIdFieldName)
75  ->from($tableName)
76  ->where(
77  $queryBuilder->expr()->in(
78  'uid',
79  $queryBuilder->createNamedParameter($ids, Connection::PARAM_INT_ARRAY)
80  )
81  )
82  ->groupBy($createUserIdFieldName)
83  ->execute()
84  ->fetchAll();
85 
86  $records = array_column($records, $createUserIdFieldName);
87 
88  if (!empty($records)) {
89  $createUserIds = array_merge($createUserIds, $records);
90  }
91  }
92  return array_unique($createUserIds);
93  }
94 }
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static makeInstance($className,...$constructorArguments)