diff --git a/src/Controller/AdminPages/BaseAdminController.php b/src/Controller/AdminPages/BaseAdminController.php index 28c9df60..0921d42a 100644 --- a/src/Controller/AdminPages/BaseAdminController.php +++ b/src/Controller/AdminPages/BaseAdminController.php @@ -39,7 +39,7 @@ use App\Repository\AbstractPartsContainingRepository; use App\Services\Attachments\AttachmentSubmitHandler; use App\Services\ImportExportSystem\EntityExporter; use App\Services\ImportExportSystem\EntityImporter; -use App\Services\LabelSystem\Barcodes\BarcodeExampleElementsGenerator; +use App\Services\LabelSystem\LabelExampleElementsGenerator; use App\Services\LabelSystem\LabelGenerator; use App\Services\LogSystem\EventCommentHelper; use App\Services\LogSystem\HistoryHelper; @@ -86,14 +86,14 @@ abstract class BaseAdminController extends AbstractController */ protected $eventDispatcher; protected LabelGenerator $labelGenerator; - protected BarcodeExampleElementsGenerator $barcodeExampleGenerator; + protected LabelExampleElementsGenerator $barcodeExampleGenerator; protected EntityManagerInterface $entityManager; public function __construct(TranslatorInterface $translator, UserPasswordHasherInterface $passwordEncoder, AttachmentSubmitHandler $attachmentSubmitHandler, EventCommentHelper $commentHelper, HistoryHelper $historyHelper, TimeTravel $timeTravel, - DataTableFactory $dataTableFactory, EventDispatcherInterface $eventDispatcher, BarcodeExampleElementsGenerator $barcodeExampleGenerator, + DataTableFactory $dataTableFactory, EventDispatcherInterface $eventDispatcher, LabelExampleElementsGenerator $barcodeExampleGenerator, LabelGenerator $labelGenerator, EntityManagerInterface $entityManager) { if ('' === $this->entity_class || '' === $this->form_class || '' === $this->twig_template || '' === $this->route_base) { diff --git a/src/Controller/AdminPages/CurrencyController.php b/src/Controller/AdminPages/CurrencyController.php index 133c3a50..bda992c5 100644 --- a/src/Controller/AdminPages/CurrencyController.php +++ b/src/Controller/AdminPages/CurrencyController.php @@ -31,7 +31,7 @@ use App\Services\Attachments\AttachmentSubmitHandler; use App\Services\ImportExportSystem\EntityExporter; use App\Services\ImportExportSystem\EntityImporter; use App\Services\Tools\ExchangeRateUpdater; -use App\Services\LabelSystem\Barcodes\BarcodeExampleElementsGenerator; +use App\Services\LabelSystem\LabelExampleElementsGenerator; use App\Services\LabelSystem\LabelGenerator; use App\Services\LogSystem\EventCommentHelper; use App\Services\LogSystem\HistoryHelper; @@ -76,7 +76,7 @@ class CurrencyController extends BaseAdminController TimeTravel $timeTravel, DataTableFactory $dataTableFactory, EventDispatcherInterface $eventDispatcher, - BarcodeExampleElementsGenerator $barcodeExampleGenerator, + LabelExampleElementsGenerator $barcodeExampleGenerator, LabelGenerator $labelGenerator, EntityManagerInterface $entityManager, ExchangeRateUpdater $exchangeRateUpdater diff --git a/src/Services/LabelSystem/Barcodes/BarcodeExampleElementsGenerator.php b/src/Services/LabelSystem/LabelExampleElementsGenerator.php similarity index 91% rename from src/Services/LabelSystem/Barcodes/BarcodeExampleElementsGenerator.php rename to src/Services/LabelSystem/LabelExampleElementsGenerator.php index 8a2d020d..0bc3761a 100644 --- a/src/Services/LabelSystem/Barcodes/BarcodeExampleElementsGenerator.php +++ b/src/Services/LabelSystem/LabelExampleElementsGenerator.php @@ -39,7 +39,7 @@ declare(strict_types=1); * along with this program. If not, see . */ -namespace App\Services\LabelSystem\Barcodes; +namespace App\Services\LabelSystem; use App\Entity\Base\AbstractStructuralDBElement; use App\Entity\Parts\Category; @@ -48,11 +48,12 @@ use App\Entity\Parts\Manufacturer; use App\Entity\Parts\Part; use App\Entity\Parts\PartLot; use App\Entity\Parts\Storelocation; +use App\Entity\UserSystem\User; use DateTime; use InvalidArgumentException; use ReflectionClass; -final class BarcodeExampleElementsGenerator +final class LabelExampleElementsGenerator { public function getElement(string $type): object { @@ -102,6 +103,7 @@ final class BarcodeExampleElementsGenerator $lot->setExpirationDate(new DateTime('+1 days')); $lot->setStorageLocation($this->getStructuralData(Storelocation::class)); $lot->setAmount(123); + $lot->setOwner($this->getUser()); return $lot; } @@ -112,6 +114,8 @@ final class BarcodeExampleElementsGenerator $storelocation->setName('Location 1'); $storelocation->setComment('Example comment'); $storelocation->updateTimestamps(); + $storelocation->setOwner($this->getUser()); + $parent = new Storelocation(); $parent->setName('Parent'); @@ -121,6 +125,16 @@ final class BarcodeExampleElementsGenerator return $storelocation; } + private function getUser(): User + { + $user = new User(); + $user->setName('user'); + $user->setFirstName('John'); + $user->setLastName('Doe'); + + return $user; + } + private function getStructuralData(string $class): AbstractStructuralDBElement { if (!is_a($class, AbstractStructuralDBElement::class, true)) {