TYPO3 CMS  TYPO3_8-7
AbstractRecord.php
Go to the documentation of this file.
1 <?php
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  */
16 
21 
25 abstract class AbstractRecord
26 {
30  protected $record;
31 
32  protected static function fetch($tableName, $uid)
33  {
34  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($tableName);
35  $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
36  $record = $queryBuilder->select('*')
37  ->from($tableName)
38  ->where(
39  $queryBuilder->expr()->eq(
40  'uid',
41  $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
42  )
43  )
44  ->execute()
45  ->fetch();
46  if (empty($record)) {
47  throw new \RuntimeException('Record "' . $tableName . ': ' . $uid . '" not found', 1476122008);
48  }
49  return $record;
50  }
51 
55  protected static function getBackendUser()
56  {
57  return $GLOBALS['BE_USER'];
58  }
59 
63  protected static function getLanguageService()
64  {
65  return $GLOBALS['LANG'];
66  }
67 
71  public function __construct(array $record)
72  {
73  $this->record = $record;
74  }
75 
79  public function __toString()
80  {
81  return (string)$this->getUid();
82  }
83 
87  public function getUid()
88  {
89  return (int)$this->record['uid'];
90  }
91 
95  public function getTitle()
96  {
97  return (string)$this->record['title'];
98  }
99 
103  protected function getStagesService()
104  {
105  return GeneralUtility::makeInstance(StagesService::class);
106  }
107 }
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']