Added example content for owner placeholders in labels

This commit is contained in:
Jan Böhmer 2023-04-03 22:48:52 +02:00
parent 4aedce9668
commit f7293508ff
3 changed files with 21 additions and 7 deletions

View file

@ -39,7 +39,7 @@ use App\Repository\AbstractPartsContainingRepository;
use App\Services\Attachments\AttachmentSubmitHandler; use App\Services\Attachments\AttachmentSubmitHandler;
use App\Services\ImportExportSystem\EntityExporter; use App\Services\ImportExportSystem\EntityExporter;
use App\Services\ImportExportSystem\EntityImporter; use App\Services\ImportExportSystem\EntityImporter;
use App\Services\LabelSystem\Barcodes\BarcodeExampleElementsGenerator; use App\Services\LabelSystem\LabelExampleElementsGenerator;
use App\Services\LabelSystem\LabelGenerator; use App\Services\LabelSystem\LabelGenerator;
use App\Services\LogSystem\EventCommentHelper; use App\Services\LogSystem\EventCommentHelper;
use App\Services\LogSystem\HistoryHelper; use App\Services\LogSystem\HistoryHelper;
@ -86,14 +86,14 @@ abstract class BaseAdminController extends AbstractController
*/ */
protected $eventDispatcher; protected $eventDispatcher;
protected LabelGenerator $labelGenerator; protected LabelGenerator $labelGenerator;
protected BarcodeExampleElementsGenerator $barcodeExampleGenerator; protected LabelExampleElementsGenerator $barcodeExampleGenerator;
protected EntityManagerInterface $entityManager; protected EntityManagerInterface $entityManager;
public function __construct(TranslatorInterface $translator, UserPasswordHasherInterface $passwordEncoder, public function __construct(TranslatorInterface $translator, UserPasswordHasherInterface $passwordEncoder,
AttachmentSubmitHandler $attachmentSubmitHandler, AttachmentSubmitHandler $attachmentSubmitHandler,
EventCommentHelper $commentHelper, HistoryHelper $historyHelper, TimeTravel $timeTravel, EventCommentHelper $commentHelper, HistoryHelper $historyHelper, TimeTravel $timeTravel,
DataTableFactory $dataTableFactory, EventDispatcherInterface $eventDispatcher, BarcodeExampleElementsGenerator $barcodeExampleGenerator, DataTableFactory $dataTableFactory, EventDispatcherInterface $eventDispatcher, LabelExampleElementsGenerator $barcodeExampleGenerator,
LabelGenerator $labelGenerator, EntityManagerInterface $entityManager) LabelGenerator $labelGenerator, EntityManagerInterface $entityManager)
{ {
if ('' === $this->entity_class || '' === $this->form_class || '' === $this->twig_template || '' === $this->route_base) { if ('' === $this->entity_class || '' === $this->form_class || '' === $this->twig_template || '' === $this->route_base) {

View file

@ -31,7 +31,7 @@ use App\Services\Attachments\AttachmentSubmitHandler;
use App\Services\ImportExportSystem\EntityExporter; use App\Services\ImportExportSystem\EntityExporter;
use App\Services\ImportExportSystem\EntityImporter; use App\Services\ImportExportSystem\EntityImporter;
use App\Services\Tools\ExchangeRateUpdater; use App\Services\Tools\ExchangeRateUpdater;
use App\Services\LabelSystem\Barcodes\BarcodeExampleElementsGenerator; use App\Services\LabelSystem\LabelExampleElementsGenerator;
use App\Services\LabelSystem\LabelGenerator; use App\Services\LabelSystem\LabelGenerator;
use App\Services\LogSystem\EventCommentHelper; use App\Services\LogSystem\EventCommentHelper;
use App\Services\LogSystem\HistoryHelper; use App\Services\LogSystem\HistoryHelper;
@ -76,7 +76,7 @@ class CurrencyController extends BaseAdminController
TimeTravel $timeTravel, TimeTravel $timeTravel,
DataTableFactory $dataTableFactory, DataTableFactory $dataTableFactory,
EventDispatcherInterface $eventDispatcher, EventDispatcherInterface $eventDispatcher,
BarcodeExampleElementsGenerator $barcodeExampleGenerator, LabelExampleElementsGenerator $barcodeExampleGenerator,
LabelGenerator $labelGenerator, LabelGenerator $labelGenerator,
EntityManagerInterface $entityManager, EntityManagerInterface $entityManager,
ExchangeRateUpdater $exchangeRateUpdater ExchangeRateUpdater $exchangeRateUpdater

View file

@ -39,7 +39,7 @@ declare(strict_types=1);
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace App\Services\LabelSystem\Barcodes; namespace App\Services\LabelSystem;
use App\Entity\Base\AbstractStructuralDBElement; use App\Entity\Base\AbstractStructuralDBElement;
use App\Entity\Parts\Category; use App\Entity\Parts\Category;
@ -48,11 +48,12 @@ use App\Entity\Parts\Manufacturer;
use App\Entity\Parts\Part; use App\Entity\Parts\Part;
use App\Entity\Parts\PartLot; use App\Entity\Parts\PartLot;
use App\Entity\Parts\Storelocation; use App\Entity\Parts\Storelocation;
use App\Entity\UserSystem\User;
use DateTime; use DateTime;
use InvalidArgumentException; use InvalidArgumentException;
use ReflectionClass; use ReflectionClass;
final class BarcodeExampleElementsGenerator final class LabelExampleElementsGenerator
{ {
public function getElement(string $type): object public function getElement(string $type): object
{ {
@ -102,6 +103,7 @@ final class BarcodeExampleElementsGenerator
$lot->setExpirationDate(new DateTime('+1 days')); $lot->setExpirationDate(new DateTime('+1 days'));
$lot->setStorageLocation($this->getStructuralData(Storelocation::class)); $lot->setStorageLocation($this->getStructuralData(Storelocation::class));
$lot->setAmount(123); $lot->setAmount(123);
$lot->setOwner($this->getUser());
return $lot; return $lot;
} }
@ -112,6 +114,8 @@ final class BarcodeExampleElementsGenerator
$storelocation->setName('Location 1'); $storelocation->setName('Location 1');
$storelocation->setComment('Example comment'); $storelocation->setComment('Example comment');
$storelocation->updateTimestamps(); $storelocation->updateTimestamps();
$storelocation->setOwner($this->getUser());
$parent = new Storelocation(); $parent = new Storelocation();
$parent->setName('Parent'); $parent->setName('Parent');
@ -121,6 +125,16 @@ final class BarcodeExampleElementsGenerator
return $storelocation; 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 private function getStructuralData(string $class): AbstractStructuralDBElement
{ {
if (!is_a($class, AbstractStructuralDBElement::class, true)) { if (!is_a($class, AbstractStructuralDBElement::class, true)) {