forked from wallabag/wallabag
Make controllers get parameters from constructor
This commit is contained in:
@ -13,6 +13,12 @@ use Wallabag\Import\ImportInterface;
|
||||
|
||||
abstract class BrowserController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
protected readonly array $allowMimetypes,
|
||||
protected readonly string $resourceDir,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Response
|
||||
*/
|
||||
@ -31,9 +37,9 @@ abstract class BrowserController extends AbstractController
|
||||
$markAsRead = $form->get('mark_as_read')->getData();
|
||||
$name = $this->getUser()->getId() . '.json';
|
||||
|
||||
if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) {
|
||||
if (null !== $file && \in_array($file->getClientMimeType(), $this->allowMimetypes, true) && $file->move($this->resourceDir, $name)) {
|
||||
$res = $wallabag
|
||||
->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name)
|
||||
->setFilepath($this->resourceDir . '/' . $name)
|
||||
->setMarkAsRead($markAsRead)
|
||||
->import();
|
||||
|
||||
@ -52,7 +58,7 @@ abstract class BrowserController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
unlink($this->getParameter('wallabag.resource_dir') . '/' . $name);
|
||||
unlink($this->resourceDir . '/' . $name);
|
||||
}
|
||||
|
||||
$this->addFlash('notice', $message);
|
||||
|
||||
Reference in New Issue
Block a user