/** * Install the extension * * @param Extension $extension * @return bool|array Returns FALSE if dependencies cannot be resolved, otherwise array with installation information */ public function installExtension(Extension $extension) { $this->downloadExtension($extension); if (!$this->checkDependencies($extension)) { return false; } $updatedDependencies = array(); $installedDependencies = array(); $queue = $this->downloadQueue->getExtensionQueue(); $copyQueue = $this->downloadQueue->getExtensionCopyStorage(); if (!empty($copyQueue)) { $this->copyDependencies($copyQueue); } $downloadedDependencies = array(); if (array_key_exists('download', $queue)) { $downloadedDependencies = $this->downloadDependencies($queue['download']); } if ($this->automaticInstallationEnabled) { if (array_key_exists('update', $queue)) { $this->downloadDependencies($queue['update']); $updatedDependencies = $this->uninstallDependenciesToBeUpdated($queue['update']); } // add extension at the end of the download queue $this->downloadQueue->addExtensionToInstallQueue($extension); $installQueue = $this->downloadQueue->getExtensionInstallStorage(); if (!empty($installQueue)) { $installedDependencies = $this->installDependencies($installQueue); } } return array_merge($downloadedDependencies, $updatedDependencies, $installedDependencies); }
/** * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension|array $extension * @return array */ public function resolveDependenciesAndInstall($extension) { if (!is_array($extension) && !$extension instanceof \TYPO3\CMS\Extensionmanager\Domain\Model\Extension) { throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Extension must be array or object.', 1350891642); } $this->dependencyUtility->buildExtensionDependenciesTree($extension); if ($extension instanceof \TYPO3\CMS\Extensionmanager\Domain\Model\Extension) { // We have a TER Extension, which should be downloaded first. $this->downloadQueue->addExtensionToQueue($extension); $extensionKey = $extension->getExtensionKey(); } else { $extensionKey = $extension['key']; } $queue = $this->downloadQueue->getExtensionQueue(); $downloadedDependencies = array(); $updatedDependencies = array(); $installedDependencies = array(); if (array_key_exists('download', $queue)) { $downloadedDependencies = $this->downloadDependencies($queue['download']); } if (array_key_exists('update', $queue)) { $this->downloadDependencies($queue['update']); $updatedDependencies = $this->uninstallDependenciesToBeUpdated($queue['update']); } // add extension at the end of the download queue $this->downloadQueue->addExtensionToInstallQueue($extensionKey); $installQueue = $this->downloadQueue->getExtensionInstallStorage(); if (count($installQueue) > 0) { $installedDependencies = $this->installDependencies($installQueue); } return array_merge($downloadedDependencies, $updatedDependencies, $installedDependencies); }
/** * Install the extension * * @param Extension $extension * @return bool|array Returns FALSE if dependencies cannot be resolved, otherwise array with installation information */ public function installExtension(Extension $extension) { $this->downloadExtension($extension); if (!$this->checkDependencies($extension)) { return false; } $downloadedDependencies = []; $updatedDependencies = []; $installQueue = []; // First resolve all dependencies and the sub-dependencies until all queues are empty as new extensions might be // added each time // Extensions have to be installed in reverse order. Extensions which were added at last are dependencies of // earlier ones and need to be available before while (!$this->downloadQueue->isCopyQueueEmpty() || !$this->downloadQueue->isQueueEmpty('download') || !$this->downloadQueue->isQueueEmpty('update')) { // First copy all available extension // This might change other queues again $copyQueue = $this->downloadQueue->resetExtensionCopyStorage(); if (!empty($copyQueue)) { $this->copyDependencies($copyQueue); } $installQueue = array_merge($this->downloadQueue->resetExtensionInstallStorage(), $installQueue); // Get download and update information $queue = $this->downloadQueue->resetExtensionQueue(); if (!empty($queue['download'])) { $downloadedDependencies = array_merge($downloadedDependencies, $this->downloadDependencies($queue['download'])); } $installQueue = array_merge($this->downloadQueue->resetExtensionInstallStorage(), $installQueue); if ($this->automaticInstallationEnabled) { if (!empty($queue['update'])) { $this->downloadDependencies($queue['update']); $updatedDependencies = array_merge($updatedDependencies, $this->uninstallDependenciesToBeUpdated($queue['update'])); } $installQueue = array_merge($this->downloadQueue->resetExtensionInstallStorage(), $installQueue); } } // If there were any dependency errors we have to abort here if ($this->dependencyUtility->hasDependencyErrors()) { return false; } // Attach extension to install queue $this->downloadQueue->addExtensionToInstallQueue($extension); $installQueue += $this->downloadQueue->resetExtensionInstallStorage(); $installedDependencies = $this->installDependencies($installQueue); return array_merge($downloadedDependencies, $updatedDependencies, $installedDependencies); }
/** * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension * @return array */ public function resolveDependenciesAndInstall(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension) { $this->dependencyUtility->buildExtensionDependenciesTree($extension); $this->downloadQueue->addExtensionToQueue($extension); $queue = $this->downloadQueue->getExtensionQueue(); $downloadedDependencies = array(); $updatedDependencies = array(); $installedDependencies = array(); if (array_key_exists('download', $queue)) { $downloadedDependencies = $this->downloadDependencies($queue['download']); } if (array_key_exists('update', $queue)) { $this->downloadDependencies($queue['update']); $updatedDependencies = $this->uninstallDependenciesToBeUpdated($queue['update']); } // add extension at the end of the download queue $this->downloadQueue->addExtensionToInstallQueue($extension->getExtensionKey()); $installQueue = $this->downloadQueue->getExtensionInstallStorage(); if (count($installQueue) > 0) { $installedDependencies = $this->installDependencies($installQueue); } return array_merge($downloadedDependencies, $updatedDependencies, $installedDependencies); }