Clean code
This commit is contained in:
@@ -5,12 +5,12 @@ declare(strict_types=1);
|
||||
class MediaController extends BaseController
|
||||
{
|
||||
private const UPLOAD_MAX_BYTES = 10 * 1024 * 1024; // 10 Mo
|
||||
private const ACCEPTED_TYPES = ['image/jpeg', 'image/png', 'image/webp'];
|
||||
private const PER_PAGE = 24;
|
||||
|
||||
public function beforeRoute(): void
|
||||
{
|
||||
$this->requireAuth();
|
||||
$this->disableCache();
|
||||
}
|
||||
|
||||
public function index(): void
|
||||
@@ -18,12 +18,12 @@ class MediaController extends BaseController
|
||||
$page = max(1, (int) ($this->f3->get('GET.page') ?? 1));
|
||||
$result = (new Media($this->db))->paginateLibrary($page, self::PER_PAGE);
|
||||
|
||||
$this->renderSession('admin/media.html', [
|
||||
$this->render('admin/media.html', [
|
||||
'pageTitle' => 'Médiathèque',
|
||||
'items' => $result['items'],
|
||||
'pagination' => $result,
|
||||
'paginationAlias' => 'media_index',
|
||||
], true);
|
||||
]);
|
||||
}
|
||||
|
||||
public function upload(): void
|
||||
@@ -36,7 +36,8 @@ class MediaController extends BaseController
|
||||
|
||||
$received = Web::instance()->receive(
|
||||
fn(array $file): bool => (int) ($file['size'] ?? 0) > 0
|
||||
&& (int) ($file['size'] ?? 0) <= self::UPLOAD_MAX_BYTES,
|
||||
&& (int) ($file['size'] ?? 0) <= self::UPLOAD_MAX_BYTES
|
||||
&& in_array($file['type'] ?? '', self::ACCEPTED_TYPES, true),
|
||||
overwrite: false,
|
||||
slug: true
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user