TYPO3  7.6
RecordService.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Workspaces\Service;
3 
18 
23 {
27  protected $records = array();
28 
33  public function add($tableName, $id)
34  {
35  $databaseRecord = DatabaseRecord::create($tableName, $id);
36  if (!isset($this->records[$databaseRecord->getIdentifier()])) {
37  $this->records[$databaseRecord->getIdentifier()] = $databaseRecord;
38  }
39  }
40 
44  public function getIdsPerTable()
45  {
46  $idsPerTable = array();
47  foreach ($this->records as $databaseRecord) {
48  if (!isset($idsPerTable[$databaseRecord->getTable()])) {
49  $idsPerTable[$databaseRecord->getTable()] = array();
50  }
51  $idsPerTable[$databaseRecord->getTable()][] = $databaseRecord->getUid();
52  }
53  return $idsPerTable;
54  }
55 
59  public function getCreateUserIds()
60  {
61  $createUserIds = array();
62  foreach ($this->getIdsPerTable() as $tableName => $ids) {
63  if (empty($GLOBALS['TCA'][$tableName]['ctrl']['cruser_id'])) {
64  continue;
65  }
66  $createUserIdFieldName = $GLOBALS['TCA'][$tableName]['ctrl']['cruser_id'];
67  $records = $this->getDatabaseConnection()->exec_SELECTgetRows(
68  $createUserIdFieldName, $tableName,
69  'uid IN (' . implode(',', $ids) . ')',
70  $createUserIdFieldName,
71  '', '',
72  $createUserIdFieldName
73  );
74  if (!empty($records)) {
75  $createUserIds = array_merge($createUserIds, array_keys($records));
76  }
77  }
78  return array_unique($createUserIds);
79  }
80 
84  protected function getDatabaseConnection()
85  {
86  return $GLOBALS['TYPO3_DB'];
87  }
88 }