1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-10-05 19:31:02 +00:00

Remove voter & add tests

This commit is contained in:
Jeremy Benoist 2025-10-02 11:54:12 +02:00
parent 7e7674a4a6
commit 5629330cb6
No known key found for this signature in database
GPG key ID: 7168D5DD29F38552
29 changed files with 269 additions and 154 deletions

View file

@ -22,15 +22,15 @@ abstract class WallabagController extends AbstractController
*/
public function indexAction(Request $request, TranslatorInterface $translator)
{
$wallabag = $this->getImportService();
if (!$this->isGranted('USE_IMPORTER', $wallabag)) {
throw $this->createAccessDeniedException('You can not access this importer.');
$import = $this->getImportService();
if (!$import->isEnabled()) {
throw $this->createNotFoundException('Import is disabled');
}
$form = $this->createForm(UploadImportType::class);
$form->handleRequest($request);
$wallabag->setUser($this->getUser());
$import->setUser($this->getUser());
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('file')->getData();
@ -38,7 +38,7 @@ abstract class WallabagController extends AbstractController
$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)) {
$res = $wallabag
$res = $import
->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name)
->setMarkAsRead($markAsRead)
->import();
@ -46,7 +46,7 @@ abstract class WallabagController extends AbstractController
$message = 'flashes.import.notice.failed';
if (true === $res) {
$summary = $wallabag->getSummary();
$summary = $import->getSummary();
$message = $translator->trans('flashes.import.notice.summary', [
'%imported%' => $summary['imported'],
'%skipped%' => $summary['skipped'],
@ -71,7 +71,7 @@ abstract class WallabagController extends AbstractController
return $this->render($this->getImportTemplate(), [
'form' => $form->createView(),
'import' => $wallabag,
'import' => $import,
]);
}