diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php index af7a2e1..04035d9 100644 --- a/src/Twig/AppExtension.php +++ b/src/Twig/AppExtension.php @@ -22,6 +22,7 @@ class AppExtension extends AbstractExtension new TwigFilter('bpn_country_label', [AppRuntime::class, 'bpnCountryLabel']), new TwigFilter('bpn_pickup_label', [AppRuntime::class, 'bpnPickupLabel']), new TwigFilter('upload_status_badge', [AppRuntime::class, 'renderUploadStatusBadge'], ['is_safe' => ['html']]), + new TwigFilter('upload_filename_full', [AppRuntime::class, 'getFilenameWithFolder']), ]; } diff --git a/src/Twig/AppRuntime.php b/src/Twig/AppRuntime.php index 5b82edc..54afefd 100644 --- a/src/Twig/AppRuntime.php +++ b/src/Twig/AppRuntime.php @@ -7,6 +7,7 @@ use App\BusProNet\DataProvider\PickupDataProvider; use App\Entity\Teamer; use App\Entity\Upload; use App\Service\Teamer\PickupResolver; +use App\Service\Upload\UploadHandler; use Carbon\Carbon; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Contracts\Translation\TranslatorInterface; @@ -23,7 +24,8 @@ class AppRuntime implements RuntimeExtensionInterface private readonly CountryDataProvider $countries, private readonly PickupDataProvider $pickups, private readonly PickupResolver $pickupResolver, - private readonly string $environment + private readonly UploadHandler $uploadHandler, + private readonly string $environment, ) { } @@ -110,7 +112,7 @@ class AppRuntime implements RuntimeExtensionInterface $size = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; $factor = floor((strlen($bytes) - 1) / 3); - return sprintf("%.{$precision}f", $bytes / (1024 ** $factor)) . @$size[$factor]; + return sprintf("%.{$precision}f", $bytes / (1024 ** $factor)).@$size[$factor]; } public function formatMoney(int $amount): string @@ -145,7 +147,7 @@ class AppRuntime implements RuntimeExtensionInterface { $label = $this->translator->trans('label.document.status.'.$status); $class = 'upload-status-badge '; - $class .= match($status) { + $class .= match ($status) { Upload::STATUS_NEW => 'upload-status-badge--new', Upload::STATUS_REJECTED => 'upload-status-badge--error', Upload::STATUS_PAID => 'upload-status-badge--paid', @@ -191,7 +193,7 @@ class AppRuntime implements RuntimeExtensionInterface return rawurlencode($masterRequest->getRequestUri()); } - public function renderQaAttribute(string $label, string $value = null): string + public function renderQaAttribute(string $label, ?string $value = null): string { if ('test' !== $this->environment) { return ''; @@ -204,7 +206,7 @@ class AppRuntime implements RuntimeExtensionInterface return sprintf(' data-qa-%s="%s"', strtolower($label), $value); } - public function dateDiffForHumans(\DateTimeInterface $dateTime, \DateTimeInterface $other = null): string + public function dateDiffForHumans(\DateTimeInterface $dateTime, ?\DateTimeInterface $other = null): string { $oldLocale = Carbon::getLocale(); $locale = $this->requestStack->getMainRequest()->getLocale(); @@ -216,4 +218,11 @@ class AppRuntime implements RuntimeExtensionInterface return $result; } + + public function getFilenameWithFolder(Upload $upload): string + { + $folder = substr($upload->getFilename(), 0, 1); + + return sprintf('%s/%s', $folder, $upload->getFilename()); + } } diff --git a/templates/administrative/teamer/index.html.twig b/templates/administrative/teamer/index.html.twig index b98850b..46e125a 100644 --- a/templates/administrative/teamer/index.html.twig +++ b/templates/administrative/teamer/index.html.twig @@ -58,7 +58,7 @@