TYPO3 CMS  TYPO3_6-2
RecordCollectionRepository.php
Go to the documentation of this file.
1 <?php
3 
22 
23  const TYPE_Static = 'static';
29  protected $table = 'sys_collection';
30 
34  protected $typeField = 'type';
35 
39  protected $tableField = 'table_name';
40 
47  public function findByUid($uid) {
48  $result = NULL;
49  $data = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('*', $this->table, 'uid=' . (int)$uid . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($this->table));
50  if (is_array($data)) {
51  $result = $this->createDomainObject($data);
52  }
53  return $result;
54  }
55 
61  public function findAll() {
62  return $this->queryMultipleRecords();
63  }
64 
71  public function findByTableName($tableName) {
72  $conditions = array(
73  $this->tableField . '=' . $this->getDatabaseConnection()->fullQuoteStr($tableName, $this->table)
74  );
75  return $this->queryMultipleRecords($conditions);
76  }
77 
84  public function findByType($type) {
85  $conditions = array(
86  $this->typeField . '=' . $this->getDatabaseConnection()->fullQuoteStr($type, $this->table)
87  );
88  return $this->queryMultipleRecords($conditions);
89  }
90 
98  public function findByTypeAndTableName($type, $tableName) {
99  $conditions = array(
100  $this->typeField . '=' . $this->getDatabaseConnection()->fullQuoteStr($type, $this->table),
101  $this->tableField . '=' . $this->getDatabaseConnection()->fullQuoteStr($tableName, $this->table)
102  );
103  return $this->queryMultipleRecords($conditions);
104  }
105 
112  public function deleteByUid($uid) {
113  $this->getDatabaseConnection()->exec_UPDATEquery($this->table, 'uid=' . (int)$uid, array('deleted' => 1, 'tstamp' => $GLOBALS['EXEC_TIME']));
114  }
115 
122  protected function queryMultipleRecords(array $conditions = array()) {
123  $result = NULL;
124  if (count($conditions) > 0) {
125  $conditionsWhereClause = implode(' AND ', $conditions);
126  } else {
127  $conditionsWhereClause = '1=1';
128  }
129  $data = $this->getDatabaseConnection()->exec_SELECTgetRows('*', $this->table, $conditionsWhereClause . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($this->table));
130  if ($data !== NULL) {
131  $result = $this->createMultipleDomainObjects($data);
132  }
133  return $result;
134  }
135 
142  protected function createDomainObject(array $record) {
143  switch ($record['type']) {
144  case self::TYPE_Static:
146  break;
147  default:
148  throw new \RuntimeException('Unknown record collection type "' . $record['type'], 1328646798);
149  }
150  return $collection;
151  }
152 
159  protected function createMultipleDomainObjects(array $data) {
160  $collections = array();
161  foreach ($data as $collection) {
162  $collections[] = $this->createDomainObject($collection);
163  }
164  return $collections;
165  }
166 
172  protected function getDatabaseConnection() {
173  return $GLOBALS['TYPO3_DB'];
174  }
175 
176 }
$uid
Definition: server.php:36
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static create(array $collectionRecord, $fillItems=FALSE)