Fixed phpunit and phpstan issues
Some checks are pending
Build assets artifact / Build assets artifact (push) Waiting to run
Docker Image Build / docker (push) Waiting to run
Docker Image Build (FrankenPHP) / docker (push) Waiting to run
Static analysis / Static analysis (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, sqlite) (push) Waiting to run

This commit is contained in:
Jan Böhmer 2026-02-15 00:49:12 +01:00
parent 6b83c772cc
commit 233c5e8550
3 changed files with 17 additions and 9 deletions

View file

@ -70,12 +70,14 @@ use App\Twig\Sandbox\SandboxedLabelExtension;
use App\Twig\TwigCoreExtension; use App\Twig\TwigCoreExtension;
use InvalidArgumentException; use InvalidArgumentException;
use Twig\Environment; use Twig\Environment;
use Twig\Extension\AttributeExtension;
use Twig\Extension\SandboxExtension; use Twig\Extension\SandboxExtension;
use Twig\Extra\Html\HtmlExtension; use Twig\Extra\Html\HtmlExtension;
use Twig\Extra\Intl\IntlExtension; use Twig\Extra\Intl\IntlExtension;
use Twig\Extra\Markdown\MarkdownExtension; use Twig\Extra\Markdown\MarkdownExtension;
use Twig\Extra\String\StringExtension; use Twig\Extra\String\StringExtension;
use Twig\Loader\ArrayLoader; use Twig\Loader\ArrayLoader;
use Twig\RuntimeLoader\FactoryRuntimeLoader;
use Twig\Sandbox\SecurityPolicyInterface; use Twig\Sandbox\SecurityPolicyInterface;
/** /**
@ -186,13 +188,18 @@ final class SandboxedTwigFactory
$twig->addExtension(new StringExtension()); $twig->addExtension(new StringExtension());
$twig->addExtension(new HtmlExtension()); $twig->addExtension(new HtmlExtension());
//Add Part-DB specific extension
$twig->addExtension($this->formatExtension);
$twig->addExtension($this->barcodeExtension);
$twig->addExtension($this->entityExtension);
$twig->addExtension($this->twigCoreExtension);
$twig->addExtension($this->sandboxedLabelExtension); $twig->addExtension($this->sandboxedLabelExtension);
//Our other extensions are using attributes, we need a bit more work to load them
$dynamicExtensions = [$this->formatExtension, $this->barcodeExtension, $this->entityExtension, $this->twigCoreExtension];
$dynamicExtensionsMap = [];
foreach ($dynamicExtensions as $extension) {
$twig->addExtension(new AttributeExtension($extension::class));
$dynamicExtensionsMap[$extension::class] = static fn () => $extension;
}
$twig->addRuntimeLoader(new FactoryRuntimeLoader($dynamicExtensionsMap));
return $twig; return $twig;
} }

View file

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace App\Twig; namespace App\Twig;
use App\Entity\Base\AbstractDBElement; use App\Entity\Base\AbstractDBElement;
use App\Entity\LogSystem\AbstractLogEntry;
use App\Entity\UserSystem\User; use App\Entity\UserSystem\User;
use App\Repository\LogEntryRepository; use App\Repository\LogEntryRepository;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@ -42,7 +43,7 @@ final readonly class UserRepoExtension
#[AsTwigFunction('creating_user')] #[AsTwigFunction('creating_user')]
public function creatingUser(AbstractDBElement $element): ?User public function creatingUser(AbstractDBElement $element): ?User
{ {
return $this->entityManager->getRepository(LogEntryRepository::class)->getCreatingUser($element); return $this->entityManager->getRepository(AbstractLogEntry::class)->getCreatingUser($element);
} }
/** /**
@ -51,6 +52,6 @@ final readonly class UserRepoExtension
#[AsTwigFunction('last_editing_user')] #[AsTwigFunction('last_editing_user')]
public function lastEditingUser(AbstractDBElement $element): ?User public function lastEditingUser(AbstractDBElement $element): ?User
{ {
return $this->entityManager->getRepository(LogEntryRepository::class)->getLastEditingUser($element); return $this->entityManager->getRepository(AbstractLogEntry::class)->getLastEditingUser($element);
} }
} }

View file

@ -84,7 +84,7 @@
</span> </span>
</div> </div>
{% if entity is instanceof("App\\Entity\\Parts\\Storelocation") %} {% if entity is instanceof("App\\Entity\\Parts\\StorageLocation") %}
{{ dropdown.profile_dropdown('storelocation', entity.id, true, 'btn-secondary w-100 mt-2') }} {{ dropdown.profile_dropdown('storelocation', entity.id, true, 'btn-secondary w-100 mt-2') }}
{% endif %} {% endif %}
@ -136,4 +136,4 @@
{% if filterForm is defined %} {% if filterForm is defined %}
{% include "parts/lists/_filter.html.twig" %} {% include "parts/lists/_filter.html.twig" %}
{% endif %} {% endif %}
</div> </div>