TYPO3 CMS  TYPO3_7-6
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  */
18 
22 abstract class AbstractRecord
23 {
27  protected $record;
28 
29  protected static function fetch($tableName, $uid)
30  {
31  $record = static::getDatabaseConnection()->exec_SELECTgetSingleRow('*', $tableName, 'deleted=0 AND uid=' . (int)$uid);
32  if (empty($record)) {
33  throw new \RuntimeException('Record "' . $tableName . ': ' . $uid . '" not found');
34  }
35  return $record;
36  }
37 
41  protected static function getDatabaseConnection()
42  {
43  return $GLOBALS['TYPO3_DB'];
44  }
45 
49  protected static function getBackendUser()
50  {
51  return $GLOBALS['BE_USER'];
52  }
53 
57  protected static function getLanguageService()
58  {
59  return $GLOBALS['LANG'];
60  }
61 
65  public function __construct(array $record)
66  {
67  $this->record = $record;
68  }
69 
73  public function __toString()
74  {
75  return (string)$this->getUid();
76  }
77 
81  public function getUid()
82  {
83  return (int)$this->record['uid'];
84  }
85 
89  public function getTitle()
90  {
91  return (string)$this->record['title'];
92  }
93 
97  protected function getStagesService()
98  {
99  return GeneralUtility::makeInstance(StagesService::class);
100  }
101 }
$uid
Definition: server.php:38
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']