TYPO3 CMS  TYPO3_6-2
AbstractRepository.php
Go to the documentation of this file.
1 <?php
3 
23 
27  protected $table = '';
28 
32  protected $factory;
33 
37  protected $typeField = '';
38 
42  protected $type = '';
43 
47  public function __construct() {
48  $this->factory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ResourceFactory');
49  }
50 
58  public function add($object) {
59 
60  }
61 
69  public function remove($object) {
70 
71  }
72 
81  public function replace($existingObject, $newObject) {
82 
83  }
84 
91  public function update($modifiedObject) {
92 
93  }
94 
101  public function getAddedObjects() {
102 
103  }
104 
111  public function getRemovedObjects() {
112 
113  }
114 
121  public function findAll() {
122  $itemList = array();
123  $whereClause = '1=1';
124  if ($this->type != '') {
125  $whereClause .= ' AND ' . $this->typeField . ' = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->type, $this->table) . ' ';
126  }
127  $whereClause .= $this->getWhereClauseForEnabledFields();
128  $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->table, $whereClause);
129  while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
130  $itemList[] = $this->createDomainObject($row);
131  }
132  $GLOBALS['TYPO3_DB']->sql_free_result($res);
133  return $itemList;
134  }
135 
143  abstract protected function createDomainObject(array $databaseRow);
144 
151  public function countAll() {
152 
153  }
154 
162  public function removeAll() {
163 
164  }
165 
176  public function findByUid($uid) {
177  if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($uid)) {
178  throw new \InvalidArgumentException('uid has to be integer.', 1316779798);
179  }
180  $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', $this->table, 'uid=' . (int)$uid . $this->getWhereClauseForEnabledFields());
181  if (empty($row) || !is_array($row)) {
182  throw new \RuntimeException('Could not find row with uid "' . $uid . '" in table ' . $this->table, 1314354065);
183  }
184  return $this->createDomainObject($row);
185  }
186 
193  protected function getWhereClauseForEnabledFields() {
194  if ($this->getEnvironmentMode() === 'FE' && $GLOBALS['TSFE']->sys_page) {
195  // frontend context
196  $whereClause = $GLOBALS['TSFE']->sys_page->enableFields($this->table);
197  $whereClause .= $GLOBALS['TSFE']->sys_page->deleteClause($this->table);
198  } else {
199  // backend context
201  $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($this->table);
202  }
203  return $whereClause;
204  }
205 
220  public function setDefaultOrderings(array $defaultOrderings) {
221  throw new \BadMethodCallException('Repository does not support the setDefaultOrderings() method.', 1313185906);
222  }
223 
233  public function setDefaultQuerySettings(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $defaultQuerySettings) {
234  throw new \BadMethodCallException('Repository does not support the setDefaultQuerySettings() method.', 1313185907);
235  }
236 
244  public function createQuery() {
245  throw new \BadMethodCallException('Repository does not support the createQuery() method.', 1313185908);
246  }
247 
255  public function findByIdentifier($identifier) {
256  return $this->findByUid($identifier);
257  }
258 
268  public function __call($method, $arguments) {
269  throw new \BadMethodCallException('Repository method "' . $method . '" is not implemented.', 1378918410);
270  }
271 
278  public function getEntityClassName() {
279  return $this->objectType;
280  }
281 
288  protected function getEnvironmentMode() {
289  return TYPO3_MODE;
290  }
291 
295  protected function getDatabaseConnection() {
296  return $GLOBALS['TYPO3_DB'];
297  }
298 
299 }
$uid
Definition: server.php:36
const TYPO3_MODE
Definition: init.php:40
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
setDefaultQuerySettings(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $defaultQuerySettings)
static deleteClause($table, $tableAlias='')