[TASK] Remove blank line between docblock and the documented element
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Classes / Domain / Record / AbstractRecord.php
1 <?php
2 namespace TYPO3\CMS\Workspaces\Domain\Record;
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 use TYPO3\CMS\Core\Utility\GeneralUtility;
17 use TYPO3\CMS\Workspaces\Service\StagesService;
18
19 /**
20 * Combined record class
21 */
22 abstract class AbstractRecord
23 {
24 /**
25 * @var array
26 */
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
38 /**
39 * @return \TYPO3\CMS\Core\Database\DatabaseConnection
40 */
41 protected static function getDatabaseConnection()
42 {
43 return $GLOBALS['TYPO3_DB'];
44 }
45
46 /**
47 * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
48 */
49 protected static function getBackendUser()
50 {
51 return $GLOBALS['BE_USER'];
52 }
53
54 /**
55 * @return \TYPO3\CMS\Lang\LanguageService
56 */
57 protected static function getLanguageService()
58 {
59 return $GLOBALS['LANG'];
60 }
61
62 /**
63 * @param array $record
64 */
65 public function __construct(array $record)
66 {
67 $this->record = $record;
68 }
69
70 /**
71 * @return string
72 */
73 public function __toString()
74 {
75 return (string)$this->getUid();
76 }
77
78 /**
79 * @return int
80 */
81 public function getUid()
82 {
83 return (int)$this->record['uid'];
84 }
85
86 /**
87 * @return string
88 */
89 public function getTitle()
90 {
91 return (string)$this->record['title'];
92 }
93
94 /**
95 * @return StagesService
96 */
97 protected function getStagesService()
98 {
99 return GeneralUtility::makeInstance(StagesService::class);
100 }
101 }