[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/phpbb/install/controller/ -> archive_download.php (source)

   1  <?php
   2  /**
   3   *
   4   * This file is part of the phpBB Forum Software package.
   5   *
   6   * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7   * @license GNU General Public License, version 2 (GPL-2.0)
   8   *
   9   * For full copyright and license information, please see
  10   * the docs/CREDITS.txt file.
  11   *
  12   */
  13  
  14  namespace phpbb\install\controller;
  15  
  16  use phpbb\exception\http_exception;
  17  use phpbb\install\helper\config;
  18  use Symfony\Component\HttpFoundation\BinaryFileResponse;
  19  use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  20  
  21  class archive_download
  22  {
  23      /**
  24       * @var config
  25       */
  26      protected $installer_config;
  27  
  28      /**
  29       * Constructor
  30       *
  31       * @param config $config
  32       */
  33  	public function __construct(config $config)
  34      {
  35          $this->installer_config = $config;
  36          $this->installer_config->load_config();
  37      }
  38  
  39      /**
  40       * Sends response with the merge conflict archive
  41       *
  42       * Merge conflicts always have to be resolved manually,
  43       * so we use a different archive for that.
  44       *
  45       * @return BinaryFileResponse
  46       */
  47  	public function conflict_archive()
  48      {
  49          $filename = $this->installer_config->get('update_file_conflict_archive', '');
  50  
  51          if (empty($filename))
  52          {
  53              throw new http_exception(404, 'URL_NOT_FOUND');
  54          }
  55  
  56          return $this->send_response($filename);
  57      }
  58  
  59      /**
  60       * Sends response with the updated files' archive
  61       *
  62       * @return BinaryFileResponse
  63       */
  64  	public function update_archive()
  65      {
  66          $filename = $this->installer_config->get('update_file_archive', '');
  67  
  68          if (empty($filename))
  69          {
  70              throw new http_exception(404, 'URL_NOT_FOUND');
  71          }
  72  
  73          return $this->send_response($filename);
  74      }
  75  
  76      /**
  77       * Generates a download response
  78       *
  79       * @param string    $filename    Path to the file to download
  80       *
  81       * @return BinaryFileResponse    Response object
  82       */
  83  	private function send_response($filename)
  84      {
  85          $response = new BinaryFileResponse($filename);
  86          $response->setContentDisposition(
  87              ResponseHeaderBag::DISPOSITION_ATTACHMENT,
  88              basename($filename)
  89          );
  90  
  91          return $response;
  92      }
  93  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1