class attachment extends controller

Controller for /download/attachment/{id} routes

Properties

protected service $cache from  controller
protected driver_interface $db from  controller
protected storage $storage from  controller
protected Request $symfony_request from  controller
protected auth $auth
protected config $config
protected content_visibility $content_visibility
protected dispatcher_interface $dispatcher
protected language $language
protected request $request
protected user $user

Methods

__construct(auth $auth, service $cache, config $config, content_visibility $content_visibility, driver_interface $db, dispatcher_interface $dispatcher, language $language, request $request, storage $storage, Request $symfony_request, user $user)

Constructor

Response
handle(string $file)

Handler

bool
is_allowed(string $file)

If the user is allowed to download the file

bool
file_exists(string $file)

Check if file exists

void
prepare(StreamedResponse $response, string $file)

Prepare response

void
file_gc()

Garbage Collection

void
phpbb_download_handle_forum_auth(int $topic_id)

Handles authentication when downloading attachments from a post or topic

void
phpbb_download_handle_pm_auth(int $msg_id)

Handles authentication when downloading attachments from PMs

bool
phpbb_download_check_pm_auth(int $msg_id)

Checks whether a user can download from a particular PM

void
phpbb_increment_downloads(int $id)

Increments the download count of all provided attachments

Details

at line 75
__construct(auth $auth, service $cache, config $config, content_visibility $content_visibility, driver_interface $db, dispatcher_interface $dispatcher, language $language, request $request, storage $storage, Request $symfony_request, user $user)

Constructor

Parameters

auth $auth
service $cache
config $config
content_visibility $content_visibility
driver_interface $db
dispatcher_interface $dispatcher
language $language
request $request
storage $storage
Request $symfony_request
user $user

at line 91
Response handle(string $file)

Handler

Parameters

string $file

File path

Return Value

Response

a Symfony response object

Exceptions

http_exception

when can't access $file

exception

when there is an error reading the file

in controller at line 99
protected bool is_allowed(string $file)

If the user is allowed to download the file

Parameters

string $file

File path

Return Value

bool

in controller at line 111
protected bool file_exists(string $file)

Check if file exists

Parameters

string $file

File path

Return Value

bool

at line 300
protected void prepare(StreamedResponse $response, string $file)

Prepare response

Parameters

StreamedResponse $response
string $file

File path

Return Value

void

Exceptions

exception

when there is an error reading the file

in controller at line 183
protected void file_gc()

Garbage Collection

Return Value

void

at line 290
protected filenameFallback($filename)

at line 316
protected void phpbb_download_handle_forum_auth(int $topic_id)

Handles authentication when downloading attachments from a post or topic

Parameters

int $topic_id

The id of the topic that we are downloading from

Return Value

void

Exceptions

http_exception

If attachment is not found If user don't have permission to download the attachment

at line 359
protected void phpbb_download_handle_pm_auth(int $msg_id)

Handles authentication when downloading attachments from PMs

Parameters

int $msg_id

The id of the PM that we are downloading from

Return Value

void

Exceptions

http_exception

If attachment is not found

at line 393
protected bool phpbb_download_check_pm_auth(int $msg_id)

Checks whether a user can download from a particular PM

Parameters

int $msg_id

The id of the PM that we are downloading from

Return Value

bool

Whether the user is allowed to download from that PM or not

at line 419
protected void phpbb_increment_downloads(int $id)

Increments the download count of all provided attachments

Parameters

int $id

The attach_id of the attachment

Return Value

void

at line 431
protected bool download_allowed()

Return Value

bool