public installOrUpdatePluginFromMarketplace ( $pluginName ) |
public function installOrUpdatePluginFromMarketplace($pluginName)
{
$this->checkMarketplaceIsEnabled();
$this->pluginName = $pluginName;
try {
$this->makeSureFoldersAreWritable();
$this->makeSurePluginNameIsValid();
$tmpPluginZip = $this->downloadPluginFromMarketplace();
$tmpPluginFolder = dirname($tmpPluginZip) . '/' . basename($tmpPluginZip, '.zip') . '/';
$this->extractPluginFiles($tmpPluginZip, $tmpPluginFolder);
$this->makeSurePluginJsonExists($tmpPluginFolder);
$metadata = $this->getPluginMetadataIfValid($tmpPluginFolder);
$this->makeSureThereAreNoMissingRequirements($metadata);
$this->copyPluginToDestination($tmpPluginFolder);
Filesystem::deleteAllCacheOnUpdate($this->pluginName);
$pluginManager = PluginManager::getInstance();
if ($pluginManager->isPluginLoaded($this->pluginName)) {
$plugin = PluginManager::getInstance()->getLoadedPlugin($this->pluginName);
if (!empty($plugin)) {
$plugin->reloadPluginInformation();
}
}
} catch (\Exception $e) {
if (!empty($tmpPluginZip)) {
Filesystem::deleteFileIfExists($tmpPluginZip);
}
if (!empty($tmpPluginFolder)) {
$this->removeFolderIfExists($tmpPluginFolder);
}
throw $e;
}
$this->removeFileIfExists($tmpPluginZip);
$this->removeFolderIfExists($tmpPluginFolder);
}
private function createUpdateOrInstallView($template, $nonceName) { static::dieIfMarketplaceIsDisabled(); $pluginName = $this->initPluginModification($nonceName); $this->dieIfPluginsAdminIsDisabled(); $view = $this->configureView('@CorePluginsAdmin/' . $template); $view->plugin = array('name' => $pluginName); try { $pluginInstaller = new PluginInstaller($pluginName); $pluginInstaller->installOrUpdatePluginFromMarketplace(); } catch (\Exception $e) { $notification = new Notification($e->getMessage()); $notification->context = Notification::CONTEXT_ERROR; Notification\Manager::notify('CorePluginsAdmin_InstallPlugin', $notification); $this->redirectAfterModification(true); return; } $marketplace = new Marketplace(); $view->plugin = $marketplace->getPluginInfo($pluginName); return $view; }