/** * @param string $siteTitle The name of the new site, will be used for both the file mount's name and the directory created in fileadmin. * @return null|int Returns null if the file mount could not be created, or the uid of the last inserted "sys_filemounts" record. */ private function manageSysFileMounts($siteTitle) { $pathFirstPart = $this->getProcessSettings('path') ? $this->getProcessSettings('path') : self::$defaultPath; $pathFirstPart = substr($pathFirstPart, -1, 1) == '/' ? $pathFirstPart : $pathFirstPart . '/'; $folderPath = $pathFirstPart . GeneralUtility::strtolower($siteTitle); $folderPath = Core::formatAccentsInString($folderPath); $folderPath = preg_replace('/\\s+/', ' ', $folderPath); $folderPath = preg_replace('/\\s/', '_', $folderPath); $folderPath = '/' . $folderPath . '/'; // @todo: manage warning when overriding a folder? GeneralUtility::mkdir_deep(PATH_site . 'fileadmin' . $folderPath); /** @var FileMount $fileMount */ $fileMount = GeneralUtility::makeInstance(FileMount::class); $fileMount->setPath($folderPath); $fileMount->setTitle($siteTitle); $fileMount->setIsAbsolutePath(true); // @todo: seems it must be on pid=0, check? $fileMount->setPid(0); /** @var PersistenceManager $persistenceManager */ $persistenceManager = $this->objectManager->get(PersistenceManager::class); $persistenceManager->add($fileMount); $persistenceManager->persistAll(); return $fileMount->getUid(); }