‪TYPO3CMS  9.5
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 }
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\getUid
‪int getUid()
Definition: AbstractRecord.php:86
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\fetch
‪static fetch($tableName, $uid)
Definition: AbstractRecord.php:31
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\__construct
‪__construct(array $record)
Definition: AbstractRecord.php:70
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\getTitle
‪string getTitle()
Definition: AbstractRecord.php:94
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\getLanguageService
‪static TYPO3 CMS Core Localization LanguageService getLanguageService()
Definition: AbstractRecord.php:62
‪TYPO3\CMS\Workspaces\Domain\Record
Definition: AbstractRecord.php:2
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\getBackendUser
‪static TYPO3 CMS Core Authentication BackendUserAuthentication getBackendUser()
Definition: AbstractRecord.php:54
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\__toString
‪string __toString()
Definition: AbstractRecord.php:78
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord
Definition: AbstractRecord.php:26
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\getStagesService
‪StagesService getStagesService()
Definition: AbstractRecord.php:102
‪TYPO3\CMS\Workspaces\Service\StagesService
Definition: StagesService.php:31
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction
Definition: DeletedRestriction.php:26
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\$record
‪array $record
Definition: AbstractRecord.php:29