Exemplo n.º 1
0
 /**
  * Toggle extension installation state action
  *
  * @param string $extension
  */
 protected function toggleExtensionInstallationStateAction($extension)
 {
     $installedExtensions = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getLoadedExtensionListArray();
     if (in_array($extension, $installedExtensions)) {
         // uninstall
         $this->installUtility->uninstall($extension);
     } else {
         // install
         $this->managementService->resolveDependenciesAndInstall($this->installUtility->enrichExtensionWithDetails($extension));
     }
     $this->redirect('index', 'List', NULL, array(self::TRIGGER_RefreshModuleMenu => TRUE));
 }
Exemplo n.º 2
0
 /**
  * Handles checks to find a compatible extension version from TER to fulfill given dependency
  *
  * @todo unit tests
  * @param string $extensionKey
  * @param Dependency $dependency
  * @throws Exception\UnresolvedDependencyException
  * @return void
  */
 protected function getExtensionFromTer($extensionKey, Dependency $dependency)
 {
     $isExtensionDownloadableFromTer = $this->isExtensionDownloadableFromTer($extensionKey);
     if (!$isExtensionDownloadableFromTer) {
         if (!$this->skipDependencyCheck) {
             if ($this->extensionRepository->countAll() > 0) {
                 throw new Exception\MissingExtensionDependencyException('The extension ' . $extensionKey . ' is not available from TER.', 1399161266);
             } else {
                 throw new Exception\MissingExtensionDependencyException('The extension ' . $extensionKey . ' could not be checked. Please update your Extension-List from TYPO3 Extension Repository (TER).', 1430580308);
             }
         }
         return;
     }
     $isDownloadableVersionCompatible = $this->isDownloadableVersionCompatible($dependency);
     if (!$isDownloadableVersionCompatible) {
         if (!$this->skipDependencyCheck) {
             throw new Exception\MissingVersionDependencyException('No compatible version found for extension ' . $extensionKey, 1399161284);
         }
         return;
     }
     $latestCompatibleExtensionByIntegerVersionDependency = $this->getLatestCompatibleExtensionByIntegerVersionDependency($dependency);
     if (!$latestCompatibleExtensionByIntegerVersionDependency instanceof Extension) {
         if (!$this->skipDependencyCheck) {
             throw new Exception\MissingExtensionDependencyException('Could not resolve dependency for "' . $dependency->getIdentifier() . '"', 1399161302);
         }
         return;
     }
     if ($this->isDependentExtensionLoaded($extensionKey)) {
         $this->managementService->markExtensionForUpdate($latestCompatibleExtensionByIntegerVersionDependency);
     } else {
         $this->managementService->markExtensionForDownload($latestCompatibleExtensionByIntegerVersionDependency);
     }
 }
Exemplo n.º 3
0
 /**
  * Update an extension. Makes no sanity check but directly searches highest
  * available version from TER and updates. Update check is done by the list
  * already. This method should only be called if we are sure that there is
  * an update.
  *
  * @return void
  */
 protected function updateExtensionAction()
 {
     $extensionKey = $this->request->getArgument('extension');
     /** @var $highestTerVersionExtension \TYPO3\CMS\Extensionmanager\Domain\Model\Extension */
     $highestTerVersionExtension = $this->extensionRepository->findHighestAvailableVersion($extensionKey);
     $this->prepareExtensionForImport($highestTerVersionExtension);
     $result = $this->managementService->resolveDependenciesAndInstall($highestTerVersionExtension);
     $this->view->assign('result', $result)->assign('extension', $highestTerVersionExtension);
 }
 /**
  * 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);
 }
Exemplo n.º 5
0
 /**
  * Fetch an extension from TER.
  *
  * @param string $extensionKey     The extension key
  * @param string $location         Where to import the extension. System = typo3/sysext, Global = typo3/ext, Local = typo3conf/ext
  * @param bool   $overwrite        Overwrite the extension if it already exists
  * @param int    $mirror           The mirror to fetch the extension from
  *
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @return array
  */
 public function fetchExtension($extensionKey, $version = '', $location = 'Local', $overwrite = FALSE, $mirror = -1)
 {
     if (!is_numeric($mirror)) {
         throw new InvalidArgumentException('Option --mirror must be a number. Run the command extensionapi:listmirrors to get the list of all available repositories');
     }
     if ($version === '') {
         $extension = $this->extensionRepository->findHighestAvailableVersion($extensionKey);
         if ($extension === NULL) {
             throw new InvalidArgumentException(sprintf('Extension "%s" was not found on TER', $extensionKey));
         }
     } else {
         $extension = $this->extensionRepository->findOneByExtensionKeyAndVersion($extensionKey, $version);
         if ($extension === NULL) {
             throw new InvalidArgumentException(sprintf('Version %s of extension "%s" does not exist', $version, $extensionKey));
         }
     }
     if (!$overwrite) {
         $comingExtPath = $this->fileHandlingUtility->getExtensionDir($extensionKey, $location);
         if (@is_dir($comingExtPath)) {
             throw new InvalidArgumentException(sprintf('Extension "%s" already exists at "%s"!', $extensionKey, $comingExtPath));
         }
     }
     $mirrors = $this->repositoryHelper->getMirrors();
     if ($mirrors === NULL) {
         throw new RuntimeException('No mirrors found!');
     }
     if ($mirror === -1) {
         $mirrors->setSelect();
     } elseif ($mirror > 0 && $mirror <= count($mirrors->getMirrors())) {
         $mirrors->setSelect($mirror);
     } else {
         throw new InvalidArgumentException(sprintf('Mirror "%s" does not exist', $mirror));
     }
     /**
      * @var \TYPO3\CMS\Extensionmanager\Utility\DownloadUtility $downloadUtility
      */
     $downloadUtility = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\DownloadUtility');
     $downloadUtility->setDownloadPath($location);
     $this->extensionManagementService->downloadMainExtension($extension);
     $return = array();
     $extensionDir = $this->fileHandlingUtility->getExtensionDir($extensionKey, $location);
     if (is_dir($extensionDir)) {
         $return['main']['extKey'] = $extension->getExtensionKey();
         $return['main']['version'] = $extension->getVersion();
     } else {
         throw new RuntimeException(sprintf('Extension "%s" version %s could not installed!', $extensionKey, $extension->getVersion()));
     }
     return $return;
 }
Exemplo n.º 6
0
 /**
  * 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);
 }
 /**
  * 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 bool $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->managementService->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);
 }
Exemplo n.º 8
0
 /**
  * Handles checks to find a compatible extension version from TER
  * to fulfill given dependency
  *
  * @todo unit tests
  * @param string $extensionKey
  * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Dependency $dependency
  * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
  * @return void
  */
 protected function getExtensionFromTer($extensionKey, \TYPO3\CMS\Extensionmanager\Domain\Model\Dependency $dependency)
 {
     $isExtensionDownloadableFromTer = $this->isExtensionDownloadableFromTer($extensionKey);
     if ($isExtensionDownloadableFromTer === TRUE) {
         $isDownloadableVersionCompatible = $this->isDownloadableVersionCompatible($dependency);
         if ($isDownloadableVersionCompatible === TRUE) {
             $latestCompatibleExtensionByIntegerVersionDependency = $this->getLatestCompatibleExtensionByIntegerVersionDependency($dependency);
             if ($latestCompatibleExtensionByIntegerVersionDependency instanceof \TYPO3\CMS\Extensionmanager\Domain\Model\Extension) {
                 if ($this->isDependentExtensionLoaded($extensionKey)) {
                     $this->managementService->markExtensionForUpdate($latestCompatibleExtensionByIntegerVersionDependency);
                 } else {
                     $this->managementService->markExtensionForDownload($latestCompatibleExtensionByIntegerVersionDependency);
                 }
             } else {
                 throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Could not resolve dependency for "' . $dependency->getIdentifier() . '"');
             }
         } else {
             throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('No compatible version found for extension ' . $extensionKey);
         }
     } else {
         throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('The extension ' . $extensionKey . ' is not available from TER.');
     }
 }
Exemplo n.º 9
0
 /**
  * Install an extension and omit dependency checking
  *
  * @param string $extensionKey
  * @return void
  */
 public function installExtensionWithoutSystemDependencyCheckAction($extensionKey)
 {
     $this->managementService->setSkipSystemDependencyCheck(TRUE);
     $this->forward('toggleExtensionInstallationState', NULL, NULL, array('extensionKey' => $extensionKey));
 }
Exemplo n.º 10
0
 /**
  * Install an extension and omit dependency checking
  *
  * @param string $extensionKey
  * @return void
  */
 public function installExtensionWithoutSystemDependencyCheckAction($extensionKey)
 {
     $this->managementService->setSkipDependencyCheck(true);
     $this->forward('toggleExtensionInstallationState', null, null, ['extensionKey' => $extensionKey]);
 }