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