Use correct Attachment class for Storelocation Controller.

This fixes issue #81.
This commit is contained in:
Jan Böhmer 2020-10-03 13:31:05 +02:00
parent 09cb74d8bd
commit 1caaad908b
3 changed files with 12 additions and 6 deletions

View file

@ -43,12 +43,14 @@ declare(strict_types=1);
namespace App\Controller\AdminPages; namespace App\Controller\AdminPages;
use App\DataTables\LogDataTable; use App\DataTables\LogDataTable;
use App\Entity\Attachments\Attachment;
use App\Entity\Base\AbstractDBElement; use App\Entity\Base\AbstractDBElement;
use App\Entity\Base\AbstractNamedDBElement; use App\Entity\Base\AbstractNamedDBElement;
use App\Entity\Base\AbstractPartsContainingDBElement; use App\Entity\Base\AbstractPartsContainingDBElement;
use App\Entity\Base\AbstractStructuralDBElement; use App\Entity\Base\AbstractStructuralDBElement;
use App\Entity\Base\PartsContainingRepositoryInterface; use App\Entity\Base\PartsContainingRepositoryInterface;
use App\Entity\LabelSystem\LabelProfile; use App\Entity\LabelSystem\LabelProfile;
use App\Entity\Parameters\AbstractParameter;
use App\Entity\UserSystem\User; use App\Entity\UserSystem\User;
use App\Exceptions\AttachmentDownloadException; use App\Exceptions\AttachmentDownloadException;
use App\Form\AdminPages\ImportType; 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!'); 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) { if ('' === $this->attachment_class || !is_a($this->attachment_class, Attachment::class, true)) {
throw new InvalidArgumentException('You have to override the $attachment_class value in your subclass!'); throw new InvalidArgumentException('You have to override the $attachment_class value with a valid Attachment class in your subclass!');
} }
if ('' === $this->parameter_class) { if ('' === $this->parameter_class || !is_a($this->parameter_class, AbstractParameter::class, true)) {
throw new InvalidArgumentException('You have to override the $parameter_class value in your subclass!'); throw new InvalidArgumentException('You have to override the $parameter_class value with a valid Parameter class in your subclass!');
} }
$this->translator = $translator; $this->translator = $translator;

View file

@ -45,6 +45,7 @@ namespace App\Controller\AdminPages;
use App\Entity\Attachments\AttachmentType; use App\Entity\Attachments\AttachmentType;
use App\Entity\Attachments\LabelAttachment; use App\Entity\Attachments\LabelAttachment;
use App\Entity\LabelSystem\LabelProfile; use App\Entity\LabelSystem\LabelProfile;
use App\Entity\Parameters\AbstractParameter;
use App\Form\AdminPages\LabelProfileAdminForm; use App\Form\AdminPages\LabelProfileAdminForm;
use App\Services\EntityExporter; use App\Services\EntityExporter;
use App\Services\EntityImporter; use App\Services\EntityImporter;
@ -54,6 +55,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authenticator\AbstractPreAuthenticatedAuthenticator;
/** /**
* @Route("/label_profile") * @Route("/label_profile")
@ -65,7 +67,8 @@ class LabelProfileController extends BaseAdminController
protected $form_class = LabelProfileAdminForm::class; protected $form_class = LabelProfileAdminForm::class;
protected $route_base = 'label_profile'; protected $route_base = 'label_profile';
protected $attachment_class = LabelAttachment::class; 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"}) * @Route("/{id}", name="label_profile_delete", methods={"DELETE"})

View file

@ -42,6 +42,7 @@ declare(strict_types=1);
namespace App\Controller\AdminPages; namespace App\Controller\AdminPages;
use App\Entity\Attachments\StorelocationAttachment;
use App\Entity\Parameters\StorelocationParameter; use App\Entity\Parameters\StorelocationParameter;
use App\Entity\Parts\Storelocation; use App\Entity\Parts\Storelocation;
use App\Form\AdminPages\StorelocationAdminForm; use App\Form\AdminPages\StorelocationAdminForm;
@ -63,7 +64,7 @@ class StorelocationController extends BaseAdminController
protected $twig_template = 'AdminPages/StorelocationAdmin.html.twig'; protected $twig_template = 'AdminPages/StorelocationAdmin.html.twig';
protected $form_class = StorelocationAdminForm::class; protected $form_class = StorelocationAdminForm::class;
protected $route_base = 'store_location'; protected $route_base = 'store_location';
protected $attachment_class = StorelocationAdminForm::class; protected $attachment_class = StorelocationAttachment::class;
protected $parameter_class = StorelocationParameter::class; protected $parameter_class = StorelocationParameter::class;
/** /**