‪TYPO3CMS  10.4
AbstractRecord.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
22 
26 abstract class ‪AbstractRecord
27 {
31  protected ‪$record;
32 
33  protected static function ‪fetch($tableName, $uid)
34  {
35  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($tableName);
36  $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
37  ‪$record = $queryBuilder->select('*')
38  ->from($tableName)
39  ->where(
40  $queryBuilder->expr()->eq(
41  'uid',
42  $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
43  )
44  )
45  ->execute()
46  ->fetch();
47  if (empty(‪$record)) {
48  throw new \RuntimeException('Record "' . $tableName . ': ' . $uid . '" not found', 1476122008);
49  }
50  return ‪$record;
51  }
52 
56  protected static function ‪getBackendUser()
57  {
58  return ‪$GLOBALS['BE_USER'];
59  }
60 
64  protected static function ‪getLanguageService()
65  {
66  return ‪$GLOBALS['LANG'];
67  }
68 
72  public function ‪__construct(array ‪$record)
73  {
74  $this->record = ‪$record;
75  }
76 
80  public function ‪__toString()
81  {
82  return (string)$this->‪getUid();
83  }
84 
88  public function ‪getUid()
89  {
90  return (int)$this->record['uid'];
91  }
92 
96  public function ‪getTitle()
97  {
98  return (string)$this->record['title'];
99  }
100 
104  protected function ‪getStagesService()
105  {
106  return GeneralUtility::makeInstance(StagesService::class);
107  }
108 }
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\getUid
‪int getUid()
Definition: AbstractRecord.php:87
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\fetch
‪static fetch($tableName, $uid)
Definition: AbstractRecord.php:32
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\__construct
‪__construct(array $record)
Definition: AbstractRecord.php:71
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\getTitle
‪string getTitle()
Definition: AbstractRecord.php:95
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\getLanguageService
‪static TYPO3 CMS Core Localization LanguageService getLanguageService()
Definition: AbstractRecord.php:63
‪TYPO3\CMS\Workspaces\Domain\Record
Definition: AbstractRecord.php:16
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\getBackendUser
‪static TYPO3 CMS Core Authentication BackendUserAuthentication getBackendUser()
Definition: AbstractRecord.php:55
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\__toString
‪string __toString()
Definition: AbstractRecord.php:79
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord
Definition: AbstractRecord.php:27
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\getStagesService
‪StagesService getStagesService()
Definition: AbstractRecord.php:103
‪TYPO3\CMS\Workspaces\Service\StagesService
Definition: StagesService.php:33
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction
Definition: DeletedRestriction.php:28
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\$record
‪array $record
Definition: AbstractRecord.php:30