[CLEANUP] Adjust code to coding guidelines
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Generic / Session.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Persistence\Generic;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2010-2012 Extbase Team (http://forge.typo3.org/projects/typo3v4-mvc)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * The persistence session - acts as a Unit of Work for Extbase persistence framework.
31 */
32 class Session implements \TYPO3\CMS\Core\SingletonInterface {
33
34 /**
35 * Objects which were reconstituted. The relevant objects are registered by
36 * the \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper.
37 *
38 * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage
39 */
40 protected $reconstitutedObjects;
41
42 /**
43 * Constructs a new Session
44 */
45 public function __construct() {
46 $this->reconstitutedObjects = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
47 }
48
49 /**
50 * Registers a reconstituted object
51 *
52 * @param object|\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object $object
53 * @return void
54 */
55 public function registerReconstitutedObject(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object) {
56 $this->reconstitutedObjects->attach($object);
57 }
58
59 /**
60 * Unregisters a reconstituted object
61 *
62 * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object
63 * @return void
64 */
65 public function unregisterReconstitutedObject(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object) {
66 $this->reconstitutedObjects->detach($object);
67 }
68
69 /**
70 * Returns all objects which have been registered as reconstituted objects
71 *
72 * @return array All reconstituted objects
73 */
74 public function getReconstitutedObjects() {
75 return $this->reconstitutedObjects;
76 }
77 }
78
79 ?>