[CLEANUP] Code cleanup in ext:core/Collection
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Collection / PersistableCollectionInterface.php
1 <?php
2 namespace TYPO3\CMS\Core\Collection;
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
17 /**
18 * Interface for collection class being persistable
19 *
20 * Collections are containers-classes handling the storage
21 * of data values (f.e. strings, records, relations) in a
22 * common and generic way, while the class manages the storage
23 * in an appropriate way itself
24 *
25 * @author Steffen Ritter <typo3steffen-ritter.net>
26 */
27 interface PersistableCollectionInterface {
28
29 /**
30 * Get the identifier of the collection
31 *
32 * For database stored collections, this will be a integer,
33 * session stored, registry stored or other collections might
34 * use a string as well
35 *
36 * @return int|string
37 */
38 public function getIdentifier();
39
40 /**
41 * Sets the identifier of the collection
42 *
43 * @param int|string $id
44 * @return void
45 */
46 public function setIdentifier($id);
47
48 /**
49 * Loads the collections with the given id from persistence
50 *
51 * For memory reasons, per default only f.e. title, database-table,
52 * identifier (what ever static data is defined) is loaded.
53 * Entries can be load on first access.
54 *
55 * @param int|string $id
56 * @param bool $fillItems Populates the entries directly on load, might be bad for memory on large collections
57 * @return \TYPO3\CMS\Core\Collection\CollectionInterface
58 */
59 static public function load($id, $fillItems = FALSE);
60
61 /**
62 * Persists current collection state to underlying storage
63 *
64 * @return void
65 */
66 public function persist();
67
68 /**
69 * Populates the content-entries of the storage
70 *
71 * Queries the underlying storage for entries of the collection
72 * and adds them to the collection data.
73 *
74 * If the content entries of the storage had not been loaded on creation
75 * ($fillItems = false) this function is to be used for loading the contents
76 * afterwards.
77 *
78 * @return void
79 */
80 public function loadContents();
81
82 }