[CONTROLLER][Attachment] Assert that the supplied is positive and add documentation
This commit is contained in:
parent
88dd9e542f
commit
518995d155
|
@ -39,12 +39,20 @@ use Symfony\Component\Mime\MimeTypes;
|
||||||
|
|
||||||
class Attachment extends Controller
|
class Attachment extends Controller
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Generic function that handles getting a representation for an attachment
|
||||||
|
*/
|
||||||
private function attachment(int $id, callable $handle)
|
private function attachment(int $id, callable $handle)
|
||||||
{
|
{
|
||||||
if (Event::handle('AttachmentFileInfo', [$id, &$res]) != Event::stop) {
|
if ($id <= 0) {
|
||||||
// If no one else claims this attachment, use the default representation
|
throw new ClientException(_m('No such attachment'), 404);
|
||||||
$res = GSFile::getAttachmentFileInfo($id);
|
} else {
|
||||||
|
if (Event::handle('AttachmentFileInfo', [$id, &$res]) != Event::stop) {
|
||||||
|
// If no one else claims this attachment, use the default representation
|
||||||
|
$res = GSFile::getAttachmentFileInfo($id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($res)) {
|
if (!empty($res)) {
|
||||||
return $handle($res);
|
return $handle($res);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user