settingsManager= $settingManager; $this->fileManagerMainService = $fileManagerMainService; } /** * @return SystemBox|null */ public function getSystemBox(): ?SystemBox { $boxGuid = $this->settingsManager->get(self::SETTING_BOX); if(empty($boxGuid) || $boxGuid === ''){ //create folder return $this->createSystemBox(); } $folder = $this->fileManagerMainService->getSystemBoxFromGuid($boxGuid); if(!$folder instanceof FolderItemInterface) return $this->createSystemBox(); return $folder; } /** * @return SystemBox|null */ private function createSystemBox(): ?SystemBox { $folder = new SystemBox(); $folder ->setBase(true) ->setDescription('System box') ->setName('sysbox') ->setSystemBox(true) ; $r = $this->fileManagerMainService->quickUpdateFolder($folder); if(!$r) return null; $this->settingsManager->update(self::SETTING_BOX,$folder->getGuid()); return $folder; } }