. */ declare(strict_types=1); namespace App\Twig; use App\Entity\Base\AbstractDBElement; use App\Entity\UserSystem\User; use App\Repository\LogEntryRepository; use Doctrine\ORM\EntityManagerInterface; use Twig\Attribute\AsTwigFunction; final readonly class UserRepoExtension { public function __construct(private EntityManagerInterface $entityManager) { } /** * Returns the user which has edited the given entity the last time. */ #[AsTwigFunction('creating_user')] public function creatingUser(AbstractDBElement $element): ?User { return $this->entityManager->getRepository(LogEntryRepository::class)->getCreatingUser($element); } /** * Returns the user which has edited the given entity the last time. */ #[AsTwigFunction('last_editing_user')] public function lastEditingUser(AbstractDBElement $element): ?User { return $this->entityManager->getRepository(LogEntryRepository::class)->getLastEditingUser($element); } }