‪TYPO3CMS  11.5
Session.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
21 
27 {
31  protected ‪$objectContainer;
32 
38  protected ‪$reconstitutedEntities;
39 
43  protected ‪$objectMap;
44 
48  protected ‪$identifierMap = [];
49 
53  public function ‪__construct(‪Container $container)
54  {
55  $this->objectContainer = $container;
56  $this->reconstitutedEntities = new ‪ObjectStorage();
57  $this->objectMap = new ‪ObjectStorage();
58  }
59 
68  public function ‪registerReconstitutedEntity($entity)
69  {
70  $this->reconstitutedEntities->attach($entity);
71  }
72 
78  public function ‪unregisterReconstitutedEntity($entity)
79  {
80  if ($this->reconstitutedEntities->contains($entity)) {
81  $this->reconstitutedEntities->detach($entity);
82  }
83  }
84 
90  public function ‪getReconstitutedEntities()
91  {
93  }
94 
95  // @todo implement the is dirty checking behaviour of the Flow persistence session here
96 
103  public function ‪hasObject($object)
104  {
105  return $this->objectMap->contains($object);
106  }
107 
115  public function ‪hasIdentifier($identifier, $className)
116  {
117  return isset($this->identifierMap[$this->‪getClassIdentifier($className)][$identifier]);
118  }
119 
127  public function ‪getObjectByIdentifier($identifier, $className)
128  {
129  return $this->identifierMap[$this->‪getClassIdentifier($className)][$identifier];
130  }
131 
140  public function ‪getIdentifierByObject($object)
141  {
142  if ($this->‪hasObject($object)) {
143  return $this->objectMap[$object];
144  }
145  return null;
146  }
147 
154  public function ‪registerObject($object, $identifier)
155  {
156  $this->objectMap[$object] = $identifier;
157  $this->identifierMap[$this->‪getClassIdentifier(get_class($object))][$identifier] = $object;
158  }
159 
165  public function ‪unregisterObject($object)
166  {
167  unset($this->identifierMap[$this->‪getClassIdentifier(get_class($object))][$this->objectMap[$object]]);
168  $this->objectMap->detach($object);
169  }
170 
175  public function ‪destroy()
176  {
177  $this->identifierMap = [];
178  $this->objectMap = new ObjectStorage();
179  $this->reconstitutedEntities = new ObjectStorage();
180  }
181 
189  protected function ‪getClassIdentifier($className): string
190  {
191  return strtolower($this->objectContainer->getImplementationClassName($className));
192  }
193 }
‪TYPO3\CMS\Extbase\Persistence\Generic\Session\getIdentifierByObject
‪string getIdentifierByObject($object)
Definition: Session.php:136
‪TYPO3\CMS\Extbase\Persistence\Generic\Session\getReconstitutedEntities
‪ObjectStorage getReconstitutedEntities()
Definition: Session.php:86
‪TYPO3\CMS\Extbase\Persistence\Generic\Session\__construct
‪__construct(Container $container)
Definition: Session.php:49
‪TYPO3\CMS\Extbase\Persistence\Generic\Session\$objectMap
‪ObjectStorage $objectMap
Definition: Session.php:40
‪TYPO3\CMS\Extbase\Object\Container\Container
Definition: Container.php:42
‪TYPO3\CMS\Extbase\Persistence\Generic\Session\unregisterReconstitutedEntity
‪unregisterReconstitutedEntity($entity)
Definition: Session.php:74
‪TYPO3\CMS\Extbase\Persistence\Generic\Session\$identifierMap
‪array $identifierMap
Definition: Session.php:44
‪TYPO3\CMS\Extbase\Persistence\Generic\Session\getClassIdentifier
‪string getClassIdentifier($className)
Definition: Session.php:185
‪TYPO3\CMS\Extbase\Persistence\Generic\Session\registerObject
‪registerObject($object, $identifier)
Definition: Session.php:150
‪TYPO3\CMS\Extbase\Persistence\ObjectStorage
Definition: ObjectStorage.php:32
‪TYPO3\CMS\Extbase\Persistence\Generic\Session\$reconstitutedEntities
‪ObjectStorage $reconstitutedEntities
Definition: Session.php:36
‪TYPO3\CMS\Extbase\Persistence\Generic\Session\getObjectByIdentifier
‪object getObjectByIdentifier($identifier, $className)
Definition: Session.php:123
‪TYPO3\CMS\Extbase\Persistence\Generic\Session\registerReconstitutedEntity
‪registerReconstitutedEntity($entity)
Definition: Session.php:64
‪TYPO3\CMS\Extbase\Persistence\Generic\Session\unregisterObject
‪unregisterObject($object)
Definition: Session.php:161
‪TYPO3\CMS\Extbase\Persistence\Generic\Session
Definition: Session.php:27
‪TYPO3\CMS\Extbase\Persistence\Generic\Session\destroy
‪destroy()
Definition: Session.php:171
‪TYPO3\CMS\Extbase\Persistence\Generic
Definition: Backend.php:16
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22
‪TYPO3\CMS\Extbase\Persistence\Generic\Session\$objectContainer
‪TYPO3 CMS Extbase Object Container Container $objectContainer
Definition: Session.php:30
‪TYPO3\CMS\Extbase\Persistence\Generic\Session\hasObject
‪bool hasObject($object)
Definition: Session.php:99
‪TYPO3\CMS\Extbase\Persistence\Generic\Session\hasIdentifier
‪bool hasIdentifier($identifier, $className)
Definition: Session.php:111