1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-12 03:34:04 +02:00

[ticket/14285] Add comments

PHPBB3-14285
This commit is contained in:
Rubén Calvo
2018-07-17 12:48:27 +02:00
committed by rubencm
parent 6f69803a53
commit d105d22286
3 changed files with 90 additions and 4 deletions

View File

@@ -20,6 +20,9 @@ use phpbb\storage\storage;
use phpbb\storage\streamed_response;
use Symfony\Component\HttpFoundation\Request as symfony_request;
/**
* Generic controller for storage
*/
class controller
{
/** @var service */
@@ -37,6 +40,14 @@ class controller
/** @var symfony_request */
protected $symfony_request;
/**
* Constructor
*
* @param service $cache
* @param driver_interfacd $db
* @param storage $storage
* @param symfony_request $symfony_request
*/
public function __construct(service $cache, driver_interface $db, storage $storage, symfony_request $symfony_request)
{
$this->cache = $cache;
@@ -46,6 +57,15 @@ class controller
$this->response = new streamed_response();
}
/**
* Handler
*
* @param string $file File path
*
* @throws \phpbb\exception\http_exception when can't access $file
*
* @return \Symfony\Component\HttpFoundation\StreamedResponse a Symfony response object
*/
public function handle($file)
{
if (!$this->is_allowed($file))
@@ -68,16 +88,35 @@ class controller
return $this->response;
}
/**
* If the user is allowed to download the file
*
* @param string $file File path
*
* @return bool
*/
protected function is_allowed($file)
{
return true;
}
/**
* Check if file exists
*
* @param string $file File path
*
* @return bool
*/
protected function file_exists($file)
{
return $this->storage->exists($file);
}
/**
* Prepare response
*
* @param string $file File path
*/
protected function prepare($file)
{
$this->response->setPublic();
@@ -132,9 +171,7 @@ class controller
/**
* Garbage Collection
*
* @param bool $exit Whether to die or not.
*
* @return null
* @param bool $exit Whether to die or not
*/
protected function file_gc()
{