download() public method

public download ( $pluginOrThemeName )
Example #1
0
 /**
  * @return false|string   false on failed download, or a path to the downloaded zip file
  * @throws PluginInstallerException
  */
 private function downloadPluginFromMarketplace()
 {
     try {
         return $this->marketplaceClient->download($this->pluginName);
     } catch (\Exception $e) {
         try {
             $downloadUrl = $this->marketplaceClient->getDownloadUrl($this->pluginName);
             $errorMessage = sprintf('Failed to download plugin from %s: %s', $downloadUrl, $e->getMessage());
         } catch (\Exception $ex) {
             $errorMessage = sprintf('Failed to download plugin: %s', $e->getMessage());
         }
         throw new PluginInstallerException($errorMessage);
     }
 }
Example #2
0
 public function download()
 {
     Piwik::checkUserHasSuperUserAccess();
     $this->dieIfPluginsAdminIsDisabled();
     $pluginName = new PluginName();
     $pluginName = $pluginName->getPluginName();
     Nonce::checkNonce($pluginName);
     $filename = $pluginName . '.zip';
     try {
         $pathToPlugin = $this->marketplaceApi->download($pluginName);
         ProxyHttp::serverStaticFile($pathToPlugin, 'application/zip', $expire = 0, $start = false, $end = false, $filename);
     } catch (Exception $e) {
         Common::sendResponseCode(500);
         Log::warning('Could not download file . ' . $e->getMessage());
     }
     if (!empty($pathToPlugin)) {
         Filesystem::deleteFileIfExists($pathToPlugin);
     }
 }