Add Extbase 1.0.1 to TYPO3core. Do NOT make changes inside! See misc/core_svn_rules...
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Session.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 /**
26 * The persistence session - acts as a Unit of Work for Extbase persistence framework.
27 *
28 * @package Extbase
29 * @subpackage Persistence
30 * @version $ID:$
31 */
32 class Tx_Extbase_Persistence_Session implements t3lib_singleton {
33
34 /**
35 * Objects which were reconstituted. The relevant objects are registered by
36 * the Tx_Extbase_Persistence_Mapper_DataMapper.
37 *
38 * @var Tx_Extbase_Persistence_ObjectStorage
39 */
40 protected $reconstitutedObjects;
41
42 /**
43 * Constructs a new Session
44 *
45 */
46 public function __construct() {
47 $this->reconstitutedObjects = new Tx_Extbase_Persistence_ObjectStorage();
48 }
49
50 /**
51 * Registers a reconstituted object
52 *
53 * @param object $object
54 * @return void
55 */
56 public function registerReconstitutedObject(Tx_Extbase_DomainObject_DomainObjectInterface $object) {
57 $this->reconstitutedObjects->attach($object);
58 }
59
60 /**
61 * Unregisters a reconstituted object
62 *
63 * @param Tx_Extbase_DomainObject_DomainObjectInterface $object
64 * @return void
65 */
66 public function unregisterReconstitutedObject(Tx_Extbase_DomainObject_DomainObjectInterface $object) {
67 $this->reconstitutedObjects->detach($object);
68 }
69
70 /**
71 * Returns all objects which have been registered as reconstituted objects
72 *
73 * @param string $objectClassName The class name of objects to be returned
74 * @return array All reconstituted objects
75 */
76 public function getReconstitutedObjects() {
77 return $this->reconstitutedObjects;
78 }
79
80 }
81 ?>