‪TYPO3CMS  11.5
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 
23 
27 abstract class ‪AbstractRecord
28 {
32  protected ‪$record;
33 
34  protected static function ‪fetch($tableName, $uid)
35  {
36  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($tableName);
37  $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
38  ‪$record = $queryBuilder->select('*')
39  ->from($tableName)
40  ->where(
41  $queryBuilder->expr()->eq(
42  'uid',
43  $queryBuilder->createNamedParameter($uid, ‪Connection::PARAM_INT)
44  )
45  )
46  ->executeQuery()
47  ->fetchAssociative();
48  if (empty(‪$record)) {
49  throw new \RuntimeException('Record "' . $tableName . ': ' . $uid . '" not found', 1476122008);
50  }
51  return ‪$record;
52  }
53 
57  protected static function ‪getBackendUser()
58  {
59  return ‪$GLOBALS['BE_USER'];
60  }
61 
65  protected static function ‪getLanguageService()
66  {
67  return ‪$GLOBALS['LANG'];
68  }
69 
73  public function ‪__construct(array ‪$record)
74  {
75  $this->record = ‪$record;
76  }
77 
81  public function ‪__toString()
82  {
83  return (string)$this->‪getUid();
84  }
85 
89  public function ‪getUid()
90  {
91  return (int)$this->record['uid'];
92  }
93 
97  public function ‪getTitle()
98  {
99  return (string)$this->record['title'];
100  }
101 
105  protected function ‪getStagesService()
106  {
107  return GeneralUtility::makeInstance(StagesService::class);
108  }
109 }
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\getUid
‪int getUid()
Definition: AbstractRecord.php:88
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\fetch
‪static fetch($tableName, $uid)
Definition: AbstractRecord.php:33
‪TYPO3\CMS\Core\Database\Connection\PARAM_INT
‪const PARAM_INT
Definition: Connection.php:49
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\__construct
‪__construct(array $record)
Definition: AbstractRecord.php:72
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\getTitle
‪string getTitle()
Definition: AbstractRecord.php:96
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\getLanguageService
‪static TYPO3 CMS Core Localization LanguageService getLanguageService()
Definition: AbstractRecord.php:64
‪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:56
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\__toString
‪string __toString()
Definition: AbstractRecord.php:80
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord
Definition: AbstractRecord.php:28
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\getStagesService
‪StagesService getStagesService()
Definition: AbstractRecord.php:104
‪TYPO3\CMS\Workspaces\Service\StagesService
Definition: StagesService.php:32
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:38
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪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:50
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\$record
‪array $record
Definition: AbstractRecord.php:31