mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-10 10:24:31 +02:00
Use imports instead of FQNs
This commit is contained in:
parent
f63b6d7207
commit
5629215ce4
179 changed files with 792 additions and 597 deletions
|
@ -148,7 +148,7 @@ class AttachmentSubmitHandler
|
|||
throw new InvalidArgumentException('The given attachment class is not known! The passed class was: '.$attachment::class);
|
||||
}
|
||||
//Ensure the attachment has an assigned element
|
||||
if (!$attachment->getElement() instanceof \App\Entity\Attachments\AttachmentContainingDBElement) {
|
||||
if (!$attachment->getElement() instanceof AttachmentContainingDBElement) {
|
||||
throw new InvalidArgumentException('The given attachment is not assigned to an element! An element is needed to generate a path!');
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ class AttachmentSubmitHandler
|
|||
$options = $resolver->resolve($options);
|
||||
|
||||
//When a file is given then upload it, otherwise check if we need to download the URL
|
||||
if ($file instanceof \Symfony\Component\HttpFoundation\File\UploadedFile) {
|
||||
if ($file instanceof UploadedFile) {
|
||||
$this->upload($attachment, $file, $options);
|
||||
} elseif ($options['download_url'] && $attachment->isExternal()) {
|
||||
$this->downloadURL($attachment, $options);
|
||||
|
@ -192,7 +192,7 @@ class AttachmentSubmitHandler
|
|||
//this is only possible if the attachment is new (not yet persisted to DB)
|
||||
if ($options['become_preview_if_empty'] && null === $attachment->getID() && $attachment->isPicture()) {
|
||||
$element = $attachment->getElement();
|
||||
if ($element instanceof AttachmentContainingDBElement && !$element->getMasterPictureAttachment() instanceof \App\Entity\Attachments\Attachment) {
|
||||
if ($element instanceof AttachmentContainingDBElement && !$element->getMasterPictureAttachment() instanceof Attachment) {
|
||||
$element->setMasterPictureAttachment($attachment);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services\Attachments;
|
||||
|
||||
use Imagine\Exception\RuntimeException;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use InvalidArgumentException;
|
||||
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
|
||||
|
@ -140,7 +141,7 @@ class AttachmentURLGenerator
|
|||
$tmp = $this->thumbnailManager->getBrowserPath($asset_path, $filter_name, [], null, UrlGeneratorInterface::NETWORK_PATH);
|
||||
//So we remove the schema manually
|
||||
return preg_replace('/^https?:/', '', $tmp);
|
||||
} catch (\Imagine\Exception\RuntimeException $e) {
|
||||
} catch (RuntimeException $e) {
|
||||
//If the filter fails, we can not serve the thumbnail and fall back to the original image and log a warning
|
||||
$this->logger->warning('Could not open thumbnail for attachment with ID ' . $attachment->getID() . ': ' . $e->getMessage());
|
||||
return $this->assets->getUrl($asset_path);
|
||||
|
|
|
@ -22,6 +22,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services\Attachments;
|
||||
|
||||
use App\Entity\Parts\Footprint;
|
||||
use App\Entity\ProjectSystem\Project;
|
||||
use App\Entity\Parts\Category;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Entity\Parts\Manufacturer;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Parts\Part;
|
||||
|
||||
|
@ -52,21 +58,21 @@ class PartPreviewGenerator
|
|||
$list[] = $attachment;
|
||||
}
|
||||
|
||||
if ($part->getFootprint() instanceof \App\Entity\Parts\Footprint) {
|
||||
if ($part->getFootprint() instanceof Footprint) {
|
||||
$attachment = $part->getFootprint()->getMasterPictureAttachment();
|
||||
if ($this->isAttachmentValidPicture($attachment)) {
|
||||
$list[] = $attachment;
|
||||
}
|
||||
}
|
||||
|
||||
if ($part->getBuiltProject() instanceof \App\Entity\ProjectSystem\Project) {
|
||||
if ($part->getBuiltProject() instanceof Project) {
|
||||
$attachment = $part->getBuiltProject()->getMasterPictureAttachment();
|
||||
if ($this->isAttachmentValidPicture($attachment)) {
|
||||
$list[] = $attachment;
|
||||
}
|
||||
}
|
||||
|
||||
if ($part->getCategory() instanceof \App\Entity\Parts\Category) {
|
||||
if ($part->getCategory() instanceof Category) {
|
||||
$attachment = $part->getCategory()->getMasterPictureAttachment();
|
||||
if ($this->isAttachmentValidPicture($attachment)) {
|
||||
$list[] = $attachment;
|
||||
|
@ -74,7 +80,7 @@ class PartPreviewGenerator
|
|||
}
|
||||
|
||||
foreach ($part->getPartLots() as $lot) {
|
||||
if ($lot->getStorageLocation() instanceof \App\Entity\Parts\Storelocation) {
|
||||
if ($lot->getStorageLocation() instanceof Storelocation) {
|
||||
$attachment = $lot->getStorageLocation()->getMasterPictureAttachment();
|
||||
if ($this->isAttachmentValidPicture($attachment)) {
|
||||
$list[] = $attachment;
|
||||
|
@ -82,14 +88,14 @@ class PartPreviewGenerator
|
|||
}
|
||||
}
|
||||
|
||||
if ($part->getPartUnit() instanceof \App\Entity\Parts\MeasurementUnit) {
|
||||
if ($part->getPartUnit() instanceof MeasurementUnit) {
|
||||
$attachment = $part->getPartUnit()->getMasterPictureAttachment();
|
||||
if ($this->isAttachmentValidPicture($attachment)) {
|
||||
$list[] = $attachment;
|
||||
}
|
||||
}
|
||||
|
||||
if ($part->getManufacturer() instanceof \App\Entity\Parts\Manufacturer) {
|
||||
if ($part->getManufacturer() instanceof Manufacturer) {
|
||||
$attachment = $part->getManufacturer()->getMasterPictureAttachment();
|
||||
if ($this->isAttachmentValidPicture($attachment)) {
|
||||
$list[] = $attachment;
|
||||
|
@ -114,7 +120,7 @@ class PartPreviewGenerator
|
|||
}
|
||||
|
||||
//Otherwise check if the part has a footprint with a valid master attachment
|
||||
if ($part->getFootprint() instanceof \App\Entity\Parts\Footprint) {
|
||||
if ($part->getFootprint() instanceof Footprint) {
|
||||
$attachment = $part->getFootprint()->getMasterPictureAttachment();
|
||||
if ($this->isAttachmentValidPicture($attachment)) {
|
||||
return $attachment;
|
||||
|
@ -122,7 +128,7 @@ class PartPreviewGenerator
|
|||
}
|
||||
|
||||
//With lowest priority use the master attachment of the project this part represents (when existing)
|
||||
if ($part->getBuiltProject() instanceof \App\Entity\ProjectSystem\Project) {
|
||||
if ($part->getBuiltProject() instanceof Project) {
|
||||
$attachment = $part->getBuiltProject()->getMasterPictureAttachment();
|
||||
if ($this->isAttachmentValidPicture($attachment)) {
|
||||
return $attachment;
|
||||
|
@ -142,7 +148,7 @@ class PartPreviewGenerator
|
|||
*/
|
||||
protected function isAttachmentValidPicture(?Attachment $attachment): bool
|
||||
{
|
||||
return $attachment instanceof \App\Entity\Attachments\Attachment
|
||||
return $attachment instanceof Attachment
|
||||
&& $attachment->isPicture()
|
||||
&& $this->attachmentHelper->isFileExisting($attachment);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Entity\Attachments\AttachmentContainingDBElement;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Base\AbstractDBElement;
|
||||
|
@ -162,17 +163,17 @@ class ElementTypeNameGenerator
|
|||
|
||||
//Add a hint to the associated element if possible
|
||||
if ($include_associated) {
|
||||
if ($entity instanceof Attachment && $entity->getElement() instanceof \App\Entity\Attachments\AttachmentContainingDBElement) {
|
||||
if ($entity instanceof Attachment && $entity->getElement() instanceof AttachmentContainingDBElement) {
|
||||
$on = $entity->getElement();
|
||||
} elseif ($entity instanceof AbstractParameter && $entity->getElement() instanceof \App\Entity\Base\AbstractDBElement) {
|
||||
} elseif ($entity instanceof AbstractParameter && $entity->getElement() instanceof AbstractDBElement) {
|
||||
$on = $entity->getElement();
|
||||
} elseif ($entity instanceof PartLot && $entity->getPart() instanceof \App\Entity\Parts\Part) {
|
||||
} elseif ($entity instanceof PartLot && $entity->getPart() instanceof Part) {
|
||||
$on = $entity->getPart();
|
||||
} elseif ($entity instanceof Orderdetail && $entity->getPart() instanceof \App\Entity\Parts\Part) {
|
||||
} elseif ($entity instanceof Orderdetail && $entity->getPart() instanceof Part) {
|
||||
$on = $entity->getPart();
|
||||
} elseif ($entity instanceof Pricedetail && $entity->getOrderdetail() instanceof \App\Entity\PriceInformations\Orderdetail && $entity->getOrderdetail()->getPart() instanceof \App\Entity\Parts\Part) {
|
||||
} elseif ($entity instanceof Pricedetail && $entity->getOrderdetail() instanceof Orderdetail && $entity->getOrderdetail()->getPart() instanceof Part) {
|
||||
$on = $entity->getOrderdetail()->getPart();
|
||||
} elseif ($entity instanceof ProjectBOMEntry && $entity->getProject() instanceof \App\Entity\ProjectSystem\Project) {
|
||||
} elseif ($entity instanceof ProjectBOMEntry && $entity->getProject() instanceof Project) {
|
||||
$on = $entity->getProject();
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class MoneyFormatter
|
|||
public function format(string|float $value, ?Currency $currency = null, int $decimals = 5, bool $show_all_digits = false): string
|
||||
{
|
||||
$iso_code = $this->base_currency;
|
||||
if ($currency instanceof \App\Entity\PriceInformations\Currency && !empty($currency->getIsoCode())) {
|
||||
if ($currency instanceof Currency && !empty($currency->getIsoCode())) {
|
||||
$iso_code = $currency->getIsoCode();
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class EntityExporter
|
|||
* @param array $options The options to use for exporting
|
||||
* @return string The serialized data
|
||||
*/
|
||||
public function exportEntities(\App\Entity\Base\AbstractNamedDBElement|array $entities, array $options): string
|
||||
public function exportEntities(AbstractNamedDBElement|array $entities, array $options): string
|
||||
{
|
||||
if (!is_array($entities)) {
|
||||
$entities = [$entities];
|
||||
|
@ -108,7 +108,7 @@ class EntityExporter
|
|||
*
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function exportEntityFromRequest(\App\Entity\Base\AbstractNamedDBElement|array $entities, Request $request): Response
|
||||
public function exportEntityFromRequest(AbstractNamedDBElement|array $entities, Request $request): Response
|
||||
{
|
||||
$options = [
|
||||
'format' => $request->get('format') ?? 'json',
|
||||
|
|
|
@ -61,7 +61,7 @@ class EntityImporter
|
|||
if (!is_a($class_name, AbstractNamedDBElement::class, true)) {
|
||||
throw new InvalidArgumentException('$class_name must be a StructuralDBElement type!');
|
||||
}
|
||||
if ($parent instanceof \App\Entity\Base\AbstractStructuralDBElement && !$parent instanceof $class_name) {
|
||||
if ($parent instanceof AbstractStructuralDBElement && !$parent instanceof $class_name) {
|
||||
throw new InvalidArgumentException('$parent must have the same type as specified in $class_name!');
|
||||
}
|
||||
|
||||
|
@ -85,11 +85,7 @@ class EntityImporter
|
|||
}
|
||||
while ($identSize < end($indentations)) {
|
||||
//If the line is intendet less than the last line, we have to go up in the tree
|
||||
if ($current_parent instanceof AbstractStructuralDBElement) {
|
||||
$current_parent = $current_parent->getParent();
|
||||
} else {
|
||||
$current_parent = null;
|
||||
}
|
||||
$current_parent = $current_parent instanceof AbstractStructuralDBElement ? $current_parent->getParent() : null;
|
||||
array_pop($indentations);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace App\Services\ImportExportSystem\PartKeeprImporter;
|
||||
|
||||
use Doctrine\ORM\Id\AssignedGenerator;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\AttachmentContainingDBElement;
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
|
@ -210,7 +211,7 @@ trait PKImportHelperTrait
|
|||
|
||||
$metadata = $this->em->getClassMetadata($element::class);
|
||||
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE);
|
||||
$metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
$metadata->setIdentifierValues($element, ['id' => $id]);
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ class PKPartImporter
|
|||
throw new \RuntimeException(sprintf('Could not find part with ID %s', $partmanufacturer['part_id']));
|
||||
}
|
||||
$manufacturer = $this->em->find(Manufacturer::class, (int) $partmanufacturer['manufacturer_id']);
|
||||
if (!$manufacturer instanceof \App\Entity\Parts\Manufacturer) {
|
||||
if (!$manufacturer instanceof Manufacturer) {
|
||||
throw new \RuntimeException(sprintf('Could not find manufacturer with ID %s', $partmanufacturer['manufacturer_id']));
|
||||
}
|
||||
$part->setManufacturer($manufacturer);
|
||||
|
@ -187,7 +187,7 @@ class PKPartImporter
|
|||
}
|
||||
|
||||
$part = $this->em->find(Part::class, (int) $partparameter['part_id']);
|
||||
if (!$part instanceof \App\Entity\Parts\Part) {
|
||||
if (!$part instanceof Part) {
|
||||
throw new \RuntimeException(sprintf('Could not find part with ID %s', $partparameter['part_id']));
|
||||
}
|
||||
|
||||
|
@ -235,12 +235,12 @@ class PKPartImporter
|
|||
foreach ($data['partdistributor'] as $partdistributor) {
|
||||
//Retrieve the part
|
||||
$part = $this->em->find(Part::class, (int) $partdistributor['part_id']);
|
||||
if (!$part instanceof \App\Entity\Parts\Part) {
|
||||
if (!$part instanceof Part) {
|
||||
throw new \RuntimeException(sprintf('Could not find part with ID %s', $partdistributor['part_id']));
|
||||
}
|
||||
//Retrieve the distributor
|
||||
$supplier = $this->em->find(Supplier::class, (int) $partdistributor['distributor_id']);
|
||||
if (!$supplier instanceof \App\Entity\Parts\Supplier) {
|
||||
if (!$supplier instanceof Supplier) {
|
||||
throw new \RuntimeException(sprintf('Could not find supplier with ID %s', $partdistributor['distributor_id']));
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ final class BarcodeRedirector
|
|||
case 'lot':
|
||||
//Try to determine the part to the given lot
|
||||
$lot = $this->em->find(PartLot::class, $id);
|
||||
if (!$lot instanceof \App\Entity\Parts\PartLot) {
|
||||
if (!$lot instanceof PartLot) {
|
||||
throw new EntityNotFoundException();
|
||||
}
|
||||
|
||||
|
|
|
@ -41,18 +41,18 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services\LabelSystem;
|
||||
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use App\Entity\Contracts\NamedElementInterface;
|
||||
use App\Entity\LabelSystem\LabelOptions;
|
||||
use App\Exceptions\TwigModeException;
|
||||
use App\Services\ElementTypeNameGenerator;
|
||||
use InvalidArgumentException;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Twig\Environment;
|
||||
use Twig\Error\Error;
|
||||
|
||||
final class LabelHTMLGenerator
|
||||
{
|
||||
public function __construct(private readonly ElementTypeNameGenerator $elementTypeNameGenerator, private readonly LabelTextReplacer $replacer, private readonly Environment $twig, private readonly BarcodeGenerator $barcodeGenerator, private readonly SandboxedTwigProvider $sandboxedTwigProvider, private readonly \Symfony\Bundle\SecurityBundle\Security $security, private readonly string $partdb_title)
|
||||
public function __construct(private readonly ElementTypeNameGenerator $elementTypeNameGenerator, private readonly LabelTextReplacer $replacer, private readonly Environment $twig, private readonly BarcodeGenerator $barcodeGenerator, private readonly SandboxedTwigProvider $sandboxedTwigProvider, private readonly Security $security, private readonly string $partdb_title)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -41,19 +41,19 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services\LabelSystem\PlaceholderProviders;
|
||||
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use App\Entity\UserSystem\User;
|
||||
use DateTime;
|
||||
use IntlDateFormatter;
|
||||
use Locale;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
* Provides Placeholders for infos about global infos like Installation name or datetimes.
|
||||
*/
|
||||
final class GlobalProviders implements PlaceholderProviderInterface
|
||||
{
|
||||
public function __construct(private readonly string $partdb_title, private readonly \Symfony\Bundle\SecurityBundle\Security $security, private readonly UrlGeneratorInterface $url_generator)
|
||||
public function __construct(private readonly string $partdb_title, private readonly Security $security, private readonly UrlGeneratorInterface $url_generator)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services\LabelSystem\PlaceholderProviders;
|
||||
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Entity\Parts\PartLot;
|
||||
use App\Services\Formatters\AmountFormatter;
|
||||
use App\Services\LabelSystem\LabelTextReplacer;
|
||||
|
@ -90,19 +92,19 @@ final class PartLotProvider implements PlaceholderProviderInterface
|
|||
}
|
||||
|
||||
if ('[[LOCATION]]' === $placeholder) {
|
||||
return $label_target->getStorageLocation() instanceof \App\Entity\Parts\Storelocation ? $label_target->getStorageLocation()->getName() : '';
|
||||
return $label_target->getStorageLocation() instanceof Storelocation ? $label_target->getStorageLocation()->getName() : '';
|
||||
}
|
||||
|
||||
if ('[[LOCATION_FULL]]' === $placeholder) {
|
||||
return $label_target->getStorageLocation() instanceof \App\Entity\Parts\Storelocation ? $label_target->getStorageLocation()->getFullPath() : '';
|
||||
return $label_target->getStorageLocation() instanceof Storelocation ? $label_target->getStorageLocation()->getFullPath() : '';
|
||||
}
|
||||
|
||||
if ('[[OWNER]]' === $placeholder) {
|
||||
return $label_target->getOwner() instanceof \App\Entity\UserSystem\User ? $label_target->getOwner()->getFullName() : '';
|
||||
return $label_target->getOwner() instanceof User ? $label_target->getOwner()->getFullName() : '';
|
||||
}
|
||||
|
||||
if ('[[OWNER_USERNAME]]' === $placeholder) {
|
||||
return $label_target->getOwner() instanceof \App\Entity\UserSystem\User ? $label_target->getOwner()->getUsername() : '';
|
||||
return $label_target->getOwner() instanceof User ? $label_target->getOwner()->getUsername() : '';
|
||||
}
|
||||
|
||||
return $this->labelTextReplacer->handlePlaceholder($placeholder, $label_target->getPart());
|
||||
|
|
|
@ -41,6 +41,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services\LabelSystem\PlaceholderProviders;
|
||||
|
||||
use App\Entity\Parts\Category;
|
||||
use App\Entity\Parts\Manufacturer;
|
||||
use App\Entity\Parts\Footprint;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Services\Formatters\SIFormatter;
|
||||
use Parsedown;
|
||||
|
@ -59,27 +62,27 @@ final class PartProvider implements PlaceholderProviderInterface
|
|||
}
|
||||
|
||||
if ('[[CATEGORY]]' === $placeholder) {
|
||||
return $part->getCategory() instanceof \App\Entity\Parts\Category ? $part->getCategory()->getName() : '';
|
||||
return $part->getCategory() instanceof Category ? $part->getCategory()->getName() : '';
|
||||
}
|
||||
|
||||
if ('[[CATEGORY_FULL]]' === $placeholder) {
|
||||
return $part->getCategory() instanceof \App\Entity\Parts\Category ? $part->getCategory()->getFullPath() : '';
|
||||
return $part->getCategory() instanceof Category ? $part->getCategory()->getFullPath() : '';
|
||||
}
|
||||
|
||||
if ('[[MANUFACTURER]]' === $placeholder) {
|
||||
return $part->getManufacturer() instanceof \App\Entity\Parts\Manufacturer ? $part->getManufacturer()->getName() : '';
|
||||
return $part->getManufacturer() instanceof Manufacturer ? $part->getManufacturer()->getName() : '';
|
||||
}
|
||||
|
||||
if ('[[MANUFACTURER_FULL]]' === $placeholder) {
|
||||
return $part->getManufacturer() instanceof \App\Entity\Parts\Manufacturer ? $part->getManufacturer()->getFullPath() : '';
|
||||
return $part->getManufacturer() instanceof Manufacturer ? $part->getManufacturer()->getFullPath() : '';
|
||||
}
|
||||
|
||||
if ('[[FOOTPRINT]]' === $placeholder) {
|
||||
return $part->getFootprint() instanceof \App\Entity\Parts\Footprint ? $part->getFootprint()->getName() : '';
|
||||
return $part->getFootprint() instanceof Footprint ? $part->getFootprint()->getName() : '';
|
||||
}
|
||||
|
||||
if ('[[FOOTPRINT_FULL]]' === $placeholder) {
|
||||
return $part->getFootprint() instanceof \App\Entity\Parts\Footprint ? $part->getFootprint()->getFullPath() : '';
|
||||
return $part->getFootprint() instanceof Footprint ? $part->getFootprint()->getFullPath() : '';
|
||||
}
|
||||
|
||||
if ('[[MASS]]' === $placeholder) {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace App\Services\LabelSystem\PlaceholderProviders;
|
||||
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
|
||||
class StorelocationProvider implements PlaceholderProviderInterface
|
||||
|
@ -28,11 +29,11 @@ class StorelocationProvider implements PlaceholderProviderInterface
|
|||
{
|
||||
if ($label_target instanceof Storelocation) {
|
||||
if ('[[OWNER]]' === $placeholder) {
|
||||
return $label_target->getOwner() instanceof \App\Entity\UserSystem\User ? $label_target->getOwner()->getFullName() : '';
|
||||
return $label_target->getOwner() instanceof User ? $label_target->getOwner()->getFullName() : '';
|
||||
}
|
||||
|
||||
if ('[[OWNER_USERNAME]]' === $placeholder) {
|
||||
return $label_target->getOwner() instanceof \App\Entity\UserSystem\User ? $label_target->getOwner()->getUsername() : '';
|
||||
return $label_target->getOwner() instanceof User ? $label_target->getOwner()->getUsername() : '';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,10 +58,10 @@ final class StructuralDBElementProvider implements PlaceholderProviderInterface
|
|||
return $label_target->getFullPath();
|
||||
}
|
||||
if ('[[PARENT]]' === $placeholder) {
|
||||
return $label_target->getParent() instanceof \App\Entity\Base\AbstractStructuralDBElement ? $label_target->getParent()->getName() : '';
|
||||
return $label_target->getParent() instanceof AbstractStructuralDBElement ? $label_target->getParent()->getName() : '';
|
||||
}
|
||||
if ('[[PARENT_FULL_PATH]]' === $placeholder) {
|
||||
return $label_target->getParent() instanceof \App\Entity\Base\AbstractStructuralDBElement ? $label_target->getParent()->getFullPath() : '';
|
||||
return $label_target->getParent() instanceof AbstractStructuralDBElement ? $label_target->getParent()->getFullPath() : '';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,15 +22,16 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services\LogSystem;
|
||||
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use App\Entity\LogSystem\AbstractLogEntry;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Services\Misc\ConsoleInfoHelper;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class EventLogger
|
||||
{
|
||||
public function __construct(protected int $minimum_log_level, protected array $blacklist, protected array $whitelist, protected EntityManagerInterface $em, protected \Symfony\Bundle\SecurityBundle\Security $security, protected ConsoleInfoHelper $console_info_helper)
|
||||
public function __construct(protected int $minimum_log_level, protected array $blacklist, protected array $whitelist, protected EntityManagerInterface $em, protected Security $security, protected ConsoleInfoHelper $console_info_helper)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -44,14 +45,14 @@ class EventLogger
|
|||
{
|
||||
$user = $this->security->getUser();
|
||||
//If the user is not specified explicitly, set it to the current user
|
||||
if ((!$user instanceof \Symfony\Component\Security\Core\User\UserInterface || $user instanceof User) && !$logEntry->getUser() instanceof \App\Entity\UserSystem\User) {
|
||||
if (!$user instanceof \App\Entity\UserSystem\User) {
|
||||
if ((!$user instanceof UserInterface || $user instanceof User) && !$logEntry->getUser() instanceof User) {
|
||||
if (!$user instanceof User) {
|
||||
$repo = $this->em->getRepository(User::class);
|
||||
$user = $repo->getAnonymousUser();
|
||||
}
|
||||
|
||||
//If no anonymous user is available skip the log (needed for data fixtures)
|
||||
if (!$user instanceof \App\Entity\UserSystem\User) {
|
||||
if (!$user instanceof User) {
|
||||
return false;
|
||||
}
|
||||
$logEntry->setUser($user);
|
||||
|
|
|
@ -70,7 +70,7 @@ class LogTargetHelper
|
|||
$target = $this->entryRepository->getTargetElement($context);
|
||||
|
||||
//If the target is null and the context has a target, that means that the target was deleted. Show it that way.
|
||||
if (!$target instanceof \App\Entity\Base\AbstractDBElement) {
|
||||
if (!$target instanceof AbstractDBElement) {
|
||||
if ($context->hasTarget()) {
|
||||
return $this->elementTypeNameGenerator->formatElementDeletedHTML($context->getTargetClass(),
|
||||
$context->getTargetId());
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace App\Services\Misc;
|
||||
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
|
||||
use Doctrine\DBAL\Platforms\SqlitePlatform;
|
||||
|
@ -56,7 +57,7 @@ class DBInfoHelper
|
|||
|
||||
/**
|
||||
* Returns the database version of the used database.
|
||||
* @throws \Doctrine\DBAL\Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getDatabaseVersion(): ?string
|
||||
{
|
||||
|
@ -74,14 +75,14 @@ class DBInfoHelper
|
|||
/**
|
||||
* Returns the database size in bytes.
|
||||
* @return int|null The database size in bytes or null if unknown
|
||||
* @throws \Doctrine\DBAL\Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getDatabaseSize(): ?int
|
||||
{
|
||||
if ($this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform) {
|
||||
try {
|
||||
return $this->connection->fetchOne('SELECT SUM(data_length + index_length) FROM information_schema.TABLES WHERE table_schema = DATABASE()');
|
||||
} catch (\Doctrine\DBAL\Exception) {
|
||||
} catch (Exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +90,7 @@ class DBInfoHelper
|
|||
if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
|
||||
try {
|
||||
return $this->connection->fetchOne('SELECT page_count * page_size as size FROM pragma_page_count(), pragma_page_size();');
|
||||
} catch (\Doctrine\DBAL\Exception) {
|
||||
} catch (Exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +114,7 @@ class DBInfoHelper
|
|||
if ($this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform) {
|
||||
try {
|
||||
return $this->connection->fetchOne('SELECT USER()');
|
||||
} catch (\Doctrine\DBAL\Exception) {
|
||||
} catch (Exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ class ParameterExtractor
|
|||
$split = $this->splitString($input);
|
||||
foreach ($split as $param_string) {
|
||||
$tmp = $this->stringToParam($param_string, $class);
|
||||
if ($tmp instanceof \App\Entity\Parameters\AbstractParameter) {
|
||||
if ($tmp instanceof AbstractParameter) {
|
||||
$parameters[] = $tmp;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Services\Parts;
|
||||
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Entity\LogSystem\PartStockChangedLogEntry;
|
||||
use App\Entity\Parts\PartLot;
|
||||
use App\Services\LogSystem\EventCommentHelper;
|
||||
|
@ -24,7 +25,7 @@ final class PartLotWithdrawAddHelper
|
|||
}
|
||||
|
||||
//So far all other restrictions are defined at the storelocation level
|
||||
if(!$partLot->getStorageLocation() instanceof \App\Entity\Parts\Storelocation) {
|
||||
if(!$partLot->getStorageLocation() instanceof Storelocation) {
|
||||
return true;
|
||||
}
|
||||
//We can not add parts if the storage location of the lot is marked as full
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace App\Services\Parts;
|
||||
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use App\Entity\Parts\Category;
|
||||
use App\Entity\Parts\Footprint;
|
||||
use App\Entity\Parts\Manufacturer;
|
||||
|
@ -33,11 +34,10 @@ use InvalidArgumentException;
|
|||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
final class PartsTableActionHandler
|
||||
{
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly \Symfony\Bundle\SecurityBundle\Security $security, private readonly UrlGeneratorInterface $urlGenerator)
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly Security $security, private readonly UrlGeneratorInterface $urlGenerator)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -150,13 +150,13 @@ class PricedetailHelper
|
|||
$pricedetail = $orderdetail->findPriceForQty($amount);
|
||||
|
||||
//When we don't have information about this amount, ignore it
|
||||
if (!$pricedetail instanceof \App\Entity\PriceInformations\Pricedetail) {
|
||||
if (!$pricedetail instanceof Pricedetail) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$converted = $this->convertMoneyToCurrency($pricedetail->getPricePerUnit(), $pricedetail->getCurrency(), $currency);
|
||||
//Ignore price information that can not be converted to base currency.
|
||||
if ($converted instanceof \Brick\Math\BigDecimal) {
|
||||
if ($converted instanceof BigDecimal) {
|
||||
$avg = $avg->plus($converted);
|
||||
++$count;
|
||||
}
|
||||
|
@ -189,9 +189,9 @@ class PricedetailHelper
|
|||
|
||||
$val_base = $value;
|
||||
//Convert value to base currency
|
||||
if ($originCurrency instanceof \App\Entity\PriceInformations\Currency) {
|
||||
if ($originCurrency instanceof Currency) {
|
||||
//Without an exchange rate we can not calculate the exchange rate
|
||||
if (!$originCurrency->getExchangeRate() instanceof \Brick\Math\BigDecimal || $originCurrency->getExchangeRate()->isZero()) {
|
||||
if (!$originCurrency->getExchangeRate() instanceof BigDecimal || $originCurrency->getExchangeRate()->isZero()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -200,9 +200,9 @@ class PricedetailHelper
|
|||
|
||||
$val_target = $val_base;
|
||||
//Convert value in base currency to target currency
|
||||
if ($targetCurrency instanceof \App\Entity\PriceInformations\Currency) {
|
||||
if ($targetCurrency instanceof Currency) {
|
||||
//Without an exchange rate we can not calculate the exchange rate
|
||||
if (!$targetCurrency->getExchangeRate() instanceof \Brick\Math\BigDecimal) {
|
||||
if (!$targetCurrency->getExchangeRate() instanceof BigDecimal) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace App\Services\ProjectSystem;
|
||||
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\ProjectSystem\Project;
|
||||
use App\Entity\ProjectSystem\ProjectBOMEntry;
|
||||
use App\Helpers\Projects\ProjectBuildRequest;
|
||||
|
@ -39,7 +40,7 @@ class ProjectBuildHelper
|
|||
{
|
||||
$part = $projectBOMEntry->getPart();
|
||||
|
||||
if (!$part instanceof \App\Entity\Parts\Part) {
|
||||
if (!$part instanceof Part) {
|
||||
throw new \InvalidArgumentException('This function cannot determine the maximum buildable count for a BOM entry without a part!');
|
||||
}
|
||||
|
||||
|
@ -108,7 +109,7 @@ class ProjectBuildHelper
|
|||
$part = $bomEntry->getPart();
|
||||
|
||||
//Skip BOM entries without a part (as we can not determine that)
|
||||
if (!$part instanceof \App\Entity\Parts\Part) {
|
||||
if (!$part instanceof Part) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class NodesListBuilder
|
|||
*/
|
||||
public function typeToNodesList(string $class_name, ?AbstractStructuralDBElement $parent = null): array
|
||||
{
|
||||
$parent_id = $parent instanceof \App\Entity\Base\AbstractStructuralDBElement ? $parent->getID() : '0';
|
||||
$parent_id = $parent instanceof AbstractStructuralDBElement ? $parent->getID() : '0';
|
||||
// Backslashes are not allowed in cache keys
|
||||
$secure_class_name = str_replace('\\', '_', $class_name);
|
||||
$key = 'list_'.$this->keyGenerator->generateKey().'_'.$secure_class_name.$parent_id;
|
||||
|
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services\Trees;
|
||||
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\ProjectSystem\Project;
|
||||
use App\Entity\LabelSystem\LabelProfile;
|
||||
|
@ -38,7 +39,6 @@ use App\Entity\UserSystem\User;
|
|||
use App\Helpers\Trees\TreeViewNode;
|
||||
use App\Services\UserSystem\UserCacheKeyGenerator;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Cache\ItemInterface;
|
||||
use Symfony\Contracts\Cache\TagAwareCacheInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
@ -49,7 +49,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
*/
|
||||
class ToolsTreeBuilder
|
||||
{
|
||||
public function __construct(protected TranslatorInterface $translator, protected UrlGeneratorInterface $urlGenerator, protected TagAwareCacheInterface $cache, protected UserCacheKeyGenerator $keyGenerator, protected \Symfony\Bundle\SecurityBundle\Security $security)
|
||||
public function __construct(protected TranslatorInterface $translator, protected UrlGeneratorInterface $urlGenerator, protected TagAwareCacheInterface $cache, protected UserCacheKeyGenerator $keyGenerator, protected Security $security)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ class TreeViewGenerator
|
|||
$href = $this->urlGenerator->createURL(new $class());
|
||||
$new_node = new TreeViewNode($this->translator->trans('entity.tree.new'), $href);
|
||||
//When the id of the selected element is null, then we have a new element, and we need to select "new" node
|
||||
if (!$selectedElement instanceof \App\Entity\Base\AbstractDBElement || null === $selectedElement->getID()) {
|
||||
if (!$selectedElement instanceof AbstractDBElement || null === $selectedElement->getID()) {
|
||||
$new_node->setSelected(true);
|
||||
}
|
||||
$head[] = $new_node;
|
||||
|
@ -98,7 +98,7 @@ class TreeViewGenerator
|
|||
$recursiveIterator = new RecursiveIteratorIterator($treeIterator, RecursiveIteratorIterator::SELF_FIRST);
|
||||
foreach ($recursiveIterator as $item) {
|
||||
/** @var TreeViewNode $item */
|
||||
if ($selectedElement instanceof \App\Entity\Base\AbstractDBElement && $item->getId() === $selectedElement->getID()) {
|
||||
if ($selectedElement instanceof AbstractDBElement && $item->getId() === $selectedElement->getID()) {
|
||||
$item->setSelected(true);
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ class TreeViewGenerator
|
|||
if (!is_a($class, AbstractNamedDBElement::class, true)) {
|
||||
throw new InvalidArgumentException('$class must be a class string that implements StructuralDBElement or NamedDBElement!');
|
||||
}
|
||||
if ($parent instanceof \App\Entity\Base\AbstractStructuralDBElement && !$parent instanceof $class) {
|
||||
if ($parent instanceof AbstractStructuralDBElement && !$parent instanceof $class) {
|
||||
throw new InvalidArgumentException('$parent must be of the type $class!');
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ class TreeViewGenerator
|
|||
$repo = $this->em->getRepository($class);
|
||||
|
||||
//If we just want a part of a tree, don't cache it
|
||||
if ($parent instanceof \App\Entity\Base\AbstractStructuralDBElement) {
|
||||
if ($parent instanceof AbstractStructuralDBElement) {
|
||||
return $repo->getGenericNodeTree($parent);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class PasswordResetManager
|
|||
//Try to find a user by the given string
|
||||
$user = $repo->findByEmailOrName($name_or_email);
|
||||
//Do nothing if no user was found
|
||||
if (!$user instanceof \App\Entity\UserSystem\User) {
|
||||
if (!$user instanceof User) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ class PasswordResetManager
|
|||
$user = $repo->findOneBy(['name' => $username]);
|
||||
|
||||
//If no user matching the name, show an error message
|
||||
if (!$user instanceof \App\Entity\UserSystem\User) {
|
||||
if (!$user instanceof User) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services\UserSystem;
|
||||
|
||||
use App\Entity\Base\AbstractStructuralDBElement;
|
||||
use App\Configuration\PermissionsConfiguration;
|
||||
use App\Entity\UserSystem\Group;
|
||||
use App\Entity\UserSystem\User;
|
||||
|
@ -110,7 +111,7 @@ class PermissionManager
|
|||
|
||||
/** @var Group $parent */
|
||||
$parent = $user->getGroup();
|
||||
while ($parent instanceof \App\Entity\Base\AbstractStructuralDBElement) { //The top group, has parent == null
|
||||
while ($parent instanceof AbstractStructuralDBElement) { //The top group, has parent == null
|
||||
//Check if our current element gives an info about disallow/allow
|
||||
$allowed = $this->dontInherit($parent, $permission, $operation);
|
||||
if (null !== $allowed) {
|
||||
|
|
|
@ -102,7 +102,7 @@ class PermissionSchemaUpdater
|
|||
public function userUpgradeSchemaRecursively(User $user, int $target_version = PermissionData::CURRENT_SCHEMA_VERSION): bool
|
||||
{
|
||||
$updated = $this->upgradeSchema($user, $target_version);
|
||||
if ($user->getGroup() instanceof \App\Entity\UserSystem\Group) {
|
||||
if ($user->getGroup() instanceof Group) {
|
||||
$updated = $this->groupUpgradeSchemaRecursively($user->getGroup(), $target_version) || $updated;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace App\Services\UserSystem;
|
||||
|
||||
use Imagine\Exception\RuntimeException;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Attachments\UserAttachment;
|
||||
|
@ -44,7 +45,7 @@ class UserAvatarHelper
|
|||
public function getAvatarURL(User $user): string
|
||||
{
|
||||
//Check if the user has a master attachment defined (meaning he has explicitly defined a profile picture)
|
||||
if ($user->getMasterPictureAttachment() instanceof \App\Entity\Attachments\Attachment) {
|
||||
if ($user->getMasterPictureAttachment() instanceof Attachment) {
|
||||
return $this->attachmentURLGenerator->getThumbnailURL($user->getMasterPictureAttachment(), 'thumbnail_md');
|
||||
}
|
||||
|
||||
|
@ -60,7 +61,7 @@ class UserAvatarHelper
|
|||
public function getAvatarSmURL(User $user): string
|
||||
{
|
||||
//Check if the user has a master attachment defined (meaning he has explicitly defined a profile picture)
|
||||
if ($user->getMasterPictureAttachment() instanceof \App\Entity\Attachments\Attachment) {
|
||||
if ($user->getMasterPictureAttachment() instanceof Attachment) {
|
||||
return $this->attachmentURLGenerator->getThumbnailURL($user->getMasterPictureAttachment(), 'thumbnail_xs');
|
||||
}
|
||||
|
||||
|
@ -72,7 +73,7 @@ class UserAvatarHelper
|
|||
try {
|
||||
//Otherwise we can serve the relative path via Asset component
|
||||
return $this->filterService->getUrlOfFilteredImage('/img/default_avatar.png', 'thumbnail_xs');
|
||||
} catch (\Imagine\Exception\RuntimeException) {
|
||||
} catch (RuntimeException) {
|
||||
//If the filter fails, we can not serve the thumbnail and fall back to the original image and log an warning
|
||||
return $this->packages->getUrl('/img/default_avatar.png');
|
||||
}
|
||||
|
@ -81,7 +82,7 @@ class UserAvatarHelper
|
|||
public function getAvatarMdURL(User $user): string
|
||||
{
|
||||
//Check if the user has a master attachment defined (meaning he has explicitly defined a profile picture)
|
||||
if ($user->getMasterPictureAttachment() instanceof \App\Entity\Attachments\Attachment) {
|
||||
if ($user->getMasterPictureAttachment() instanceof Attachment) {
|
||||
return $this->attachmentURLGenerator->getThumbnailURL($user->getMasterPictureAttachment(), 'thumbnail_sm');
|
||||
}
|
||||
|
||||
|
@ -93,7 +94,7 @@ class UserAvatarHelper
|
|||
try {
|
||||
//Otherwise we can serve the relative path via Asset component
|
||||
return $this->filterService->getUrlOfFilteredImage('/img/default_avatar.png', 'thumbnail_xs');
|
||||
} catch (\Imagine\Exception\RuntimeException) {
|
||||
} catch (RuntimeException) {
|
||||
//If the filter fails, we can not serve the thumbnail and fall back to the original image and log an warning
|
||||
return $this->packages->getUrl('/img/default_avatar.png');
|
||||
}
|
||||
|
@ -131,7 +132,7 @@ class UserAvatarHelper
|
|||
{
|
||||
//Determine which attachment to user
|
||||
//If the user already has a master attachment, we use this one
|
||||
if ($user->getMasterPictureAttachment() instanceof \App\Entity\Attachments\Attachment) {
|
||||
if ($user->getMasterPictureAttachment() instanceof Attachment) {
|
||||
$attachment = $user->getMasterPictureAttachment();
|
||||
} else { //Otherwise we have to create one
|
||||
$attachment = new UserAttachment();
|
||||
|
|
|
@ -22,17 +22,18 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services\UserSystem;
|
||||
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use App\Entity\UserSystem\User;
|
||||
use Locale;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
* Purpose of this service is to generate a key unique for a user, to use in Cache keys and tags.
|
||||
*/
|
||||
class UserCacheKeyGenerator
|
||||
{
|
||||
public function __construct(protected \Symfony\Bundle\SecurityBundle\Security $security, protected RequestStack $requestStack)
|
||||
public function __construct(protected Security $security, protected RequestStack $requestStack)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -46,10 +47,10 @@ class UserCacheKeyGenerator
|
|||
{
|
||||
$request = $this->requestStack->getCurrentRequest();
|
||||
//Retrieve the locale from the request, if possible, otherwise use the default locale
|
||||
$locale = $request instanceof \Symfony\Component\HttpFoundation\Request ? $request->getLocale() : Locale::getDefault();
|
||||
$locale = $request instanceof Request ? $request->getLocale() : Locale::getDefault();
|
||||
|
||||
//If no user was specified, use the currently used one.
|
||||
if (!$user instanceof \App\Entity\UserSystem\User) {
|
||||
if (!$user instanceof User) {
|
||||
$user = $this->security->getUser();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue