2 namespace TYPO3\CMS\Core\Category\Collection;
49 public function __construct($tableName = null, $fieldName = null)
51 parent::__construct();
52 if (!empty($tableName)) {
54 }
elseif (empty($this->itemTableName)) {
55 throw new \RuntimeException(CategoryCollection::class .
' needs a valid itemTableName.', 1341826168);
57 if (!empty($fieldName)) {
70 public static function create(array $collectionRecord, $fillItems =
false)
74 CategoryCollection::class,
75 $collectionRecord[
'table_name'],
76 $collectionRecord[
'field_name']
78 $collection->fromArray($collectionRecord);
80 $collection->loadContents();
97 public static function load($id, $fillItems =
false, $tableName =
'', $fieldName =
'')
99 $collectionRecord = self::getDatabaseConnection()->exec_SELECTgetSingleRow(
101 static::$storageTableName,
104 $collectionRecord[
'table_name'] = $tableName;
105 $collectionRecord[
'field_name'] = $fieldName;
106 return self::create($collectionRecord, $fillItems);
118 $db = self::getDatabaseConnection();
120 $relatedRecords = array();
122 $where =
'AND ' . self::$storageTableName .
'.uid = ' . (int)$this->
getIdentifier();
124 $where .=
' AND sys_category_record_mm.tablenames = ' . $db->fullQuoteStr(
126 'sys_category_record_mm'
129 $where .=
' AND sys_category_record_mm.fieldname = ' . $db->fullQuoteStr(
131 'sys_category_record_mm'
133 $resource = $db->exec_SELECT_mm_query(
135 self::$storageTableName,
136 'sys_category_record_mm',
141 while ($record = $db->sql_fetch_assoc($resource)) {
142 $relatedRecords[] = $record;
144 $db->sql_free_result($resource);
146 return $relatedRecords;
163 foreach ($entries as $entry) {
190 public function add($data)
192 $this->storage->push($data);
203 foreach ($other as $value) {
215 public function remove($data)
218 foreach ($this->storage as $value) {
219 if ($value == $data) {
224 $this->storage->offsetUnset($offset);
235 $this->storage = new \SplDoublyLinkedList();
243 public function getItems()
245 $itemArray = array();
247 foreach ($this->storage as $item) {
248 $itemArray[] = $item;
260 $this->relationFieldName = $field;
280 return self::$storageTableName;
290 return self::$storageItemsField;