/** * Toggle extension installation state action * * @param string $extensionKey */ protected function toggleExtensionInstallationStateAction($extensionKey) { $installedExtensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray(); try { if (in_array($extensionKey, $installedExtensions)) { // uninstall $this->installUtility->uninstall($extensionKey); } else { // install $extension = $this->extensionModelUtility->mapExtensionArrayToModel($this->installUtility->enrichExtensionWithDetails($extensionKey)); if ($this->managementService->installExtension($extension) === FALSE) { $this->redirect('unresolvedDependencies', 'List', NULL, array('extensionKey' => $extensionKey)); } } } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) { $this->addFlashMessage(htmlspecialchars($e->getMessage()), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } catch (\TYPO3\Flow\Package\Exception\PackageStatesFileNotWritableException $e) { $this->addFlashMessage(htmlspecialchars($e->getMessage()), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } $this->redirect('index', 'List', NULL, array(self::TRIGGER_RefreshModuleMenu => TRUE)); }
/** * Install an action from TER * Downloads the extension, resolves dependencies and installs it * * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension * @param string $downloadPath * @return array */ protected function installFromTer(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension, $downloadPath = 'Local') { $result = FALSE; $errorMessages = array(); try { $this->downloadUtility->setDownloadPath($downloadPath); if (($result = $this->managementService->installExtension($extension)) === FALSE) { $errorMessages = $this->managementService->getDependencyErrors(); } } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) { $errorMessages = array($extension->getExtensionKey() => array(array('code' => $e->getCode(), 'message' => $e->getMessage()))); } return array($result, $errorMessages); }
/** * Install an extension from TER * Downloads the extension, resolves dependencies and installs it * * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension * @param string $downloadPath * @return array */ protected function installFromTer(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension, $downloadPath = 'Local') { $result = false; $errorMessages = array(); try { $this->downloadUtility->setDownloadPath($downloadPath); $this->managementService->setAutomaticInstallationEnabled($this->configurationUtility->getCurrentConfiguration('extensionmanager')['automaticInstallation']['value']); if (($result = $this->managementService->installExtension($extension)) === false) { $errorMessages = $this->managementService->getDependencyErrors(); } } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) { $errorMessages = array($extension->getExtensionKey() => array(array('code' => $e->getCode(), 'message' => $e->getMessage()))); } return array($result, $errorMessages); }
/** * @param string $extensionKey * @return bool */ public function activateExtension($extensionKey) { $this->managementService->reloadPackageInformation($extensionKey); $extension = $this->managementService->getExtension($extensionKey); return is_array($this->managementService->installExtension($extension)); }