TYPO3 CMS  TYPO3_8-7
ModuleDataStorageService.php
Go to the documentation of this file.
1 <?php
3 
6 
7 /*
8  * This file is part of the TYPO3 CMS project.
9  *
10  * It is free software; you can redistribute it and/or modify it under
11  * the terms of the GNU General Public License, either version 2
12  * of the License, or any later version.
13  *
14  * For the full copyright and license information, please read the
15  * LICENSE.txt file that was distributed with this source code.
16  *
17  * The TYPO3 project - inspiring people to share!
18  */
19 
25 {
29  const KEY = 'tx_beuser';
30 
34  protected $objectManager;
35 
39  public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
40  {
41  $this->objectManager = $objectManager;
42  }
43 
49  public function loadModuleData()
50  {
51  $moduleData = $GLOBALS['BE_USER']->getModuleData(self::KEY) ?? '';
52  if ($moduleData !== '') {
53  $moduleData = @unserialize($moduleData, ['allowed_classes' => [ModuleData::class, Demand::class]]);
54  if ($moduleData instanceof ModuleData) {
55  return $moduleData;
56  }
57  }
58 
59  return $this->objectManager->get(ModuleData::class);
60  }
61 
67  public function persistModuleData(\TYPO3\CMS\Beuser\Domain\Model\ModuleData $moduleData)
68  {
69  $GLOBALS['BE_USER']->pushModuleData(self::KEY, serialize($moduleData));
70  }
71 }
persistModuleData(\TYPO3\CMS\Beuser\Domain\Model\ModuleData $moduleData)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)