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