/** * Prepares an extension for import from TER * Uninstalls the extension if it is already loaded (case: update) * and reloads the caches. * * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension * @return void */ protected function prepareExtensionForImport(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension) { if (\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded($extension->getExtensionKey())) { \TYPO3\CMS\Core\Extension\ExtensionManager::unloadExtension($extension->getExtensionKey()); $this->installUtility->reloadCaches(); } }
/** * Extracts a given zip file and installs the extension * As there is no information about the extension key in the zip * we have to use the file name to get that information * filename format is expected to be extensionkey_version.zip * * @param string $file path to uploaded file * @param string $fileName filename (basename) of uploaded file * @return array */ protected function getExtensionFromZipFile($file, $fileName) { $fileNameParts = \TYPO3\CMS\Core\Utility\GeneralUtility::revExplode('_', $fileName, 2); $this->fileHandlingUtility->unzipExtensionFromFile($file, $fileNameParts[0]); $this->installUtility->install($fileNameParts[0]); return array('extKey' => $fileNameParts[0]); }
/** * Install dependent extensions * * @param array $installQueue * @return array */ protected function installDependencies(array $installQueue) { $resolvedDependencies = array(); foreach ($installQueue as $extensionToInstall) { $this->installUtility->install($extensionToInstall); $resolvedDependencies['installed'][$extensionToInstall] = $extensionToInstall; } return $resolvedDependencies; }
/** * Extracts a given zip file and installs the extension * As there is no information about the extension key in the zip * we have to use the file name to get that information * filename format is expected to be extensionkey_version.zip * * @param string $file Path to uploaded file * @param string $fileName Filename (basename) of uploaded file * @param boolean $overwrite Overwrite existing extension if TRUE * @return array */ protected function getExtensionFromZipFile($file, $fileName, $overwrite = FALSE) { // Remove version and ending from filename to determine extension key $extensionKey = preg_replace('/_(\\d+)(\\.|\\-)(\\d+)(\\.|\\-)(\\d+)/i', '', strtolower($fileName)); $extensionKey = substr($extensionKey, 0, strrpos($extensionKey, '.')); if (!$overwrite && $this->installUtility->isAvailable($extensionKey)) { throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Extension is already available and overwriting is disabled.', 1342864311); } $this->fileHandlingUtility->unzipExtensionFromFile($file, $extensionKey); $this->installUtility->install($extensionKey); return array('extKey' => $extensionKey); }
/** * Install dependent extensions * * @param array $installQueue * @return array */ protected function installDependencies(array $installQueue) { $resolvedDependencies = array(); foreach ($installQueue as $extensionKey => $extensionDetails) { $this->installUtility->install($extensionDetails); if (!is_array($resolvedDependencies['installed'])) { $resolvedDependencies['installed'] = array(); } $resolvedDependencies['installed'][$extensionKey] = $extensionDetails; } return $resolvedDependencies; }
/** * Download data of an extension as sql statements * * @param string $extension * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException */ protected function downloadExtensionDataAction($extension) { $error = NULL; $sqlData = $this->installUtility->getExtensionSqlDataDump($extension); $dump = $sqlData['extTables'] . $sqlData['staticSql']; $fileName = $extension . '_sqlDump.sql'; $filePath = PATH_site . 'typo3temp/' . $fileName; $error = \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir($filePath, $dump); if (is_string($error)) { throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException($error, 1343048718); } $this->fileHandlingUtility->sendSqlDumpFileToBrowserAndDelete($filePath, $fileName); }
/** * Extracts a given zip file and installs the extension * As there is no information about the extension key in the zip * we have to use the file name to get that information * filename format is expected to be extensionkey_version.zip * * @param string $file Path to uploaded file * @param string $fileName Filename (basename) of uploaded file * @param boolean $overwrite Overwrite existing extension if TRUE * @return array * @throws ExtensionManagerException */ protected function getExtensionFromZipFile($file, $fileName, $overwrite = FALSE) { // Remove version and extension from filename to determine the extension key $extensionKey = $this->getExtensionKeyFromFileName($fileName); $isExtensionAvailable = $this->installUtility->isAvailable($extensionKey); if (!$overwrite && $isExtensionAvailable) { throw new ExtensionManagerException('Extension is already available and overwriting is disabled.', 1342864311); } if ($isExtensionAvailable) { $this->copyExtensionFolderToTempFolder($extensionKey); } $this->removeFromOriginalPath = TRUE; $this->fileHandlingUtility->unzipExtensionFromFile($file, $extensionKey); return array('extKey' => $extensionKey); }
/** * Install dependent extensions * * @param array $installQueue * @return array */ protected function installDependencies(array $installQueue) { if (!empty($installQueue)) { $this->emitWillInstallExtensionsSignal($installQueue); } $resolvedDependencies = array(); foreach ($installQueue as $extensionKey => $_) { $this->installUtility->install($extensionKey); $this->emitHasInstalledExtensionSignal($extensionKey); if (!is_array($resolvedDependencies['installed'])) { $resolvedDependencies['installed'] = array(); } $resolvedDependencies['installed'][$extensionKey] = $extensionKey; } return $resolvedDependencies; }
/** * Adds the information from the emconf array to the extension information * * @param array $extensions * @return array */ public function enrichExtensionsWithEmConfAndTerInformation(array $extensions) { foreach ($extensions as $extensionKey => $properties) { $emconf = $this->emConfUtility->includeEmConf($properties); if ($emconf) { $extensions[$extensionKey] = array_merge($emconf, $properties); $terObject = $this->extensionRepository->findOneByExtensionKeyAndVersion($extensionKey, $extensions[$extensionKey]['version']); if ($terObject instanceof \TYPO3\CMS\Extensionmanager\Domain\Model\Extension) { $extensions[$extensionKey]['terObject'] = $terObject; $extensions[$extensionKey]['updateAvailable'] = $this->installUtility->isUpdateAvailable($terObject); } } else { unset($extensions[$extensionKey]); } } return $extensions; }
/** * Adds the information from the emconf array and TER to the extension information * * @param array $extensions * @return array */ public function enrichExtensionsWithEmConfAndTerInformation(array $extensions) { $extensions = $this->enrichExtensionsWithEmConfInformation($extensions); foreach ($extensions as $extensionKey => $properties) { $terObject = $this->getExtensionTerData($extensionKey, $extensions[$extensionKey]['version']); if ($terObject !== null) { $extensions[$extensionKey]['terObject'] = $terObject; $extensions[$extensionKey]['updateAvailable'] = false; $extensions[$extensionKey]['updateToVersion'] = null; $extensionToUpdate = $this->installUtility->getUpdateableVersion($terObject); if ($extensionToUpdate !== false) { $extensions[$extensionKey]['updateAvailable'] = true; $extensions[$extensionKey]['updateToVersion'] = $extensionToUpdate; } } } return $extensions; }
/** * Adds the information from the emconf array to the extension information * * @param array $extensions * @return array */ public function enrichExtensionsWithEmConfAndTerInformation(array $extensions) { foreach ($extensions as $extensionKey => $properties) { $emconf = $this->emConfUtility->includeEmConf($properties); if ($emconf) { $extensions[$extensionKey] = array_merge($emconf, $properties); $terObject = $this->getExtensionTerData($extensionKey, $extensions[$extensionKey]['version']); if ($terObject !== NULL) { $extensions[$extensionKey]['terObject'] = $terObject; $extensions[$extensionKey]['updateAvailable'] = FALSE; $extensions[$extensionKey]['updateToVersion'] = NULL; $extensionToUpdate = $this->installUtility->getUpdateableVersion($terObject); if ($extensionToUpdate !== FALSE) { $extensions[$extensionKey]['updateAvailable'] = TRUE; $extensions[$extensionKey]['updateToVersion'] = $extensionToUpdate; } } } else { unset($extensions[$extensionKey]); } } return $extensions; }
/** * @param string $extensionKey */ protected function reloadPackageInformation($extensionKey) { $this->installUtility->reloadPackageInformation($extensionKey); }
/** * Get version of an available or installed extension * * @param string $extension * @return string */ public function getExtensionVersion($extension) { $extensionData = $this->installUtility->enrichExtensionWithDetails($extension); $version = $extensionData['version']; return $version; }
/** * @test */ public function uninstallCallsUnloadExtension() { $this->installMock->expects($this->once())->method('unloadExtension'); $this->installMock->uninstall($this->extensionKey); }
/** * Get extension path for an available or installed extension * * @param string $extension * @return string */ public function getAbsoluteExtensionPath($extension) { $extension = $this->installUtility->enrichExtensionWithDetails($extension); $absolutePath = $this->returnAbsolutePath($extension['siteRelPath']); return $absolutePath; }
/** * Check if an extension is loaded. * * @param string $extensionKey The extension key * * @throws \InvalidArgumentException * @return void */ protected function checkExtensionLoaded($extensionKey) { if (!$this->installUtility->isLoaded($extensionKey)) { throw new InvalidArgumentException(sprintf('Extension "%s" is not installed!', $extensionKey)); } }