fix: adopt folder structure in uploads/photos
This commit is contained in:
@@ -22,6 +22,7 @@ class AppExtension extends AbstractExtension
|
|||||||
new TwigFilter('bpn_country_label', [AppRuntime::class, 'bpnCountryLabel']),
|
new TwigFilter('bpn_country_label', [AppRuntime::class, 'bpnCountryLabel']),
|
||||||
new TwigFilter('bpn_pickup_label', [AppRuntime::class, 'bpnPickupLabel']),
|
new TwigFilter('bpn_pickup_label', [AppRuntime::class, 'bpnPickupLabel']),
|
||||||
new TwigFilter('upload_status_badge', [AppRuntime::class, 'renderUploadStatusBadge'], ['is_safe' => ['html']]),
|
new TwigFilter('upload_status_badge', [AppRuntime::class, 'renderUploadStatusBadge'], ['is_safe' => ['html']]),
|
||||||
|
new TwigFilter('upload_filename_full', [AppRuntime::class, 'getFilenameWithFolder']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-3
@@ -7,6 +7,7 @@ use App\BusProNet\DataProvider\PickupDataProvider;
|
|||||||
use App\Entity\Teamer;
|
use App\Entity\Teamer;
|
||||||
use App\Entity\Upload;
|
use App\Entity\Upload;
|
||||||
use App\Service\Teamer\PickupResolver;
|
use App\Service\Teamer\PickupResolver;
|
||||||
|
use App\Service\Upload\UploadHandler;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
@@ -23,7 +24,8 @@ class AppRuntime implements RuntimeExtensionInterface
|
|||||||
private readonly CountryDataProvider $countries,
|
private readonly CountryDataProvider $countries,
|
||||||
private readonly PickupDataProvider $pickups,
|
private readonly PickupDataProvider $pickups,
|
||||||
private readonly PickupResolver $pickupResolver,
|
private readonly PickupResolver $pickupResolver,
|
||||||
private readonly string $environment
|
private readonly UploadHandler $uploadHandler,
|
||||||
|
private readonly string $environment,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +193,7 @@ class AppRuntime implements RuntimeExtensionInterface
|
|||||||
return rawurlencode($masterRequest->getRequestUri());
|
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) {
|
if ('test' !== $this->environment) {
|
||||||
return '';
|
return '';
|
||||||
@@ -204,7 +206,7 @@ class AppRuntime implements RuntimeExtensionInterface
|
|||||||
return sprintf(' data-qa-%s="%s"', strtolower($label), $value);
|
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();
|
$oldLocale = Carbon::getLocale();
|
||||||
$locale = $this->requestStack->getMainRequest()->getLocale();
|
$locale = $this->requestStack->getMainRequest()->getLocale();
|
||||||
@@ -216,4 +218,11 @@ class AppRuntime implements RuntimeExtensionInterface
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFilenameWithFolder(Upload $upload): string
|
||||||
|
{
|
||||||
|
$folder = substr($upload->getFilename(), 0, 1);
|
||||||
|
|
||||||
|
return sprintf('%s/%s', $folder, $upload->getFilename());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<div class="flex flex-col items-center space-y-2">
|
<div class="flex flex-col items-center space-y-2">
|
||||||
{% if teamer.photo %}
|
{% if teamer.photo %}
|
||||||
<img src="{{ asset(teamer.photo.filename | imagine_filter('profile')) }}"
|
<img src="{{ asset(teamer.photo | upload_filename_full | imagine_filter('profile')) }}"
|
||||||
class="w-12 h-auto rounded-full"
|
class="w-12 h-auto rounded-full"
|
||||||
alt="{{ teamer.firstName }}">
|
alt="{{ teamer.firstName }}">
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
Reference in New Issue
Block a user