From 1caaad908bc2696d0e69b68dc2c7a2d649b0d039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sat, 3 Oct 2020 13:31:05 +0200 Subject: [PATCH] Use correct Attachment class for Storelocation Controller. This fixes issue #81. --- src/Controller/AdminPages/BaseAdminController.php | 10 ++++++---- src/Controller/AdminPages/LabelProfileController.php | 5 ++++- src/Controller/AdminPages/StorelocationController.php | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Controller/AdminPages/BaseAdminController.php b/src/Controller/AdminPages/BaseAdminController.php index b17b081c..268eb170 100644 --- a/src/Controller/AdminPages/BaseAdminController.php +++ b/src/Controller/AdminPages/BaseAdminController.php @@ -43,12 +43,14 @@ declare(strict_types=1); namespace App\Controller\AdminPages; use App\DataTables\LogDataTable; +use App\Entity\Attachments\Attachment; use App\Entity\Base\AbstractDBElement; use App\Entity\Base\AbstractNamedDBElement; use App\Entity\Base\AbstractPartsContainingDBElement; use App\Entity\Base\AbstractStructuralDBElement; use App\Entity\Base\PartsContainingRepositoryInterface; use App\Entity\LabelSystem\LabelProfile; +use App\Entity\Parameters\AbstractParameter; use App\Entity\UserSystem\User; use App\Exceptions\AttachmentDownloadException; use App\Form\AdminPages\ImportType; @@ -114,12 +116,12 @@ abstract class BaseAdminController extends AbstractController throw new InvalidArgumentException('You have to override the $entity_class, $form_class, $route_base and $twig_template value in your subclasss!'); } - if ('' === $this->attachment_class) { - throw new InvalidArgumentException('You have to override the $attachment_class value in your subclass!'); + if ('' === $this->attachment_class || !is_a($this->attachment_class, Attachment::class, true)) { + throw new InvalidArgumentException('You have to override the $attachment_class value with a valid Attachment class in your subclass!'); } - if ('' === $this->parameter_class) { - throw new InvalidArgumentException('You have to override the $parameter_class value in your subclass!'); + if ('' === $this->parameter_class || !is_a($this->parameter_class, AbstractParameter::class, true)) { + throw new InvalidArgumentException('You have to override the $parameter_class value with a valid Parameter class in your subclass!'); } $this->translator = $translator; diff --git a/src/Controller/AdminPages/LabelProfileController.php b/src/Controller/AdminPages/LabelProfileController.php index a1de996d..4242a47e 100644 --- a/src/Controller/AdminPages/LabelProfileController.php +++ b/src/Controller/AdminPages/LabelProfileController.php @@ -45,6 +45,7 @@ namespace App\Controller\AdminPages; use App\Entity\Attachments\AttachmentType; use App\Entity\Attachments\LabelAttachment; use App\Entity\LabelSystem\LabelProfile; +use App\Entity\Parameters\AbstractParameter; use App\Form\AdminPages\LabelProfileAdminForm; use App\Services\EntityExporter; use App\Services\EntityImporter; @@ -54,6 +55,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Security\Http\Authenticator\AbstractPreAuthenticatedAuthenticator; /** * @Route("/label_profile") @@ -65,7 +67,8 @@ class LabelProfileController extends BaseAdminController protected $form_class = LabelProfileAdminForm::class; protected $route_base = 'label_profile'; protected $attachment_class = LabelAttachment::class; - protected $parameter_class = 'not_used'; + //Just a placeholder + protected $parameter_class = AbstractParameter::class; /** * @Route("/{id}", name="label_profile_delete", methods={"DELETE"}) diff --git a/src/Controller/AdminPages/StorelocationController.php b/src/Controller/AdminPages/StorelocationController.php index ecdff3a5..7ddceae4 100644 --- a/src/Controller/AdminPages/StorelocationController.php +++ b/src/Controller/AdminPages/StorelocationController.php @@ -42,6 +42,7 @@ declare(strict_types=1); namespace App\Controller\AdminPages; +use App\Entity\Attachments\StorelocationAttachment; use App\Entity\Parameters\StorelocationParameter; use App\Entity\Parts\Storelocation; use App\Form\AdminPages\StorelocationAdminForm; @@ -63,7 +64,7 @@ class StorelocationController extends BaseAdminController protected $twig_template = 'AdminPages/StorelocationAdmin.html.twig'; protected $form_class = StorelocationAdminForm::class; protected $route_base = 'store_location'; - protected $attachment_class = StorelocationAdminForm::class; + protected $attachment_class = StorelocationAttachment::class; protected $parameter_class = StorelocationParameter::class; /**