TYPO3 CMS  TYPO3_6-2
Session.php
Go to the documentation of this file.
1 <?php
3 
17 
22 
29 
37  protected $reconstitutedEntitiesData = array();
38 
42  protected $objectMap;
43 
47  protected $identifierMap = array();
48 
53  protected $reflectionService;
54 
58  public function __construct() {
59  $this->reconstitutedEntities = new ObjectStorage();
60  $this->objectMap = new ObjectStorage();
61  }
62 
73  public function registerReconstitutedEntity($entity, array $entityData = array()) {
74  $this->reconstitutedEntities->attach($entity);
75  $this->reconstitutedEntitiesData[$entityData['identifier']] = $entityData;
76  }
77 
85  public function replaceReconstitutedEntity($oldEntity, $newEntity) {
86  $this->reconstitutedEntities->detach($oldEntity);
87  $this->reconstitutedEntities->attach($newEntity);
88  }
89 
96  public function unregisterReconstitutedEntity($entity) {
97  if ($this->reconstitutedEntities->contains($entity)) {
98  $this->reconstitutedEntities->detach($entity);
99  unset($this->reconstitutedEntitiesData[$this->getIdentifierByObject($entity)]);
100  }
101  }
102 
108  public function getReconstitutedEntities() {
110  }
111 
118  public function isReconstitutedEntity($entity) {
119  return $this->reconstitutedEntities->contains($entity);
120  }
121 
122  // TODO implement the is dirty checking behaviour of the Flow persistence session here
123 
131  public function hasObject($object) {
132  return $this->objectMap->contains($object);
133  }
134 
142  public function hasIdentifier($identifier, $className) {
143  return isset($this->identifierMap[strtolower($className)][$identifier]);
144  }
145 
154  public function getObjectByIdentifier($identifier, $className) {
155  return $this->identifierMap[strtolower($className)][$identifier];
156  }
157 
167  public function getIdentifierByObject($object) {
168  if ($this->hasObject($object)) {
169  return $this->objectMap[$object];
170  }
171  return NULL;
172  }
173 
181  public function registerObject($object, $identifier) {
182  $this->objectMap[$object] = $identifier;
183  $this->identifierMap[strtolower(get_class($object))][$identifier] = $object;
184  }
185 
192  public function unregisterObject($object) {
193  unset($this->identifierMap[strtolower(get_class($object))][$this->objectMap[$object]]);
194  $this->objectMap->detach($object);
195  }
196 
203  public function destroy() {
204  $this->identifierMap = array();
205  $this->objectMap = new ObjectStorage();
206  $this->reconstitutedEntities = new ObjectStorage();
207  $this->reconstitutedEntitiesData = array();
208  }
209 
210 }
registerReconstitutedEntity($entity, array $entityData=array())
Definition: Session.php:73
replaceReconstitutedEntity($oldEntity, $newEntity)
Definition: Session.php:85
getObjectByIdentifier($identifier, $className)
Definition: Session.php:154
hasIdentifier($identifier, $className)
Definition: Session.php:142