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']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-5
@@ -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,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +112,7 @@ class AppRuntime implements RuntimeExtensionInterface
|
|||||||
$size = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
$size = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||||
$factor = floor((strlen($bytes) - 1) / 3);
|
$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
|
public function formatMoney(int $amount): string
|
||||||
@@ -145,7 +147,7 @@ class AppRuntime implements RuntimeExtensionInterface
|
|||||||
{
|
{
|
||||||
$label = $this->translator->trans('label.document.status.'.$status);
|
$label = $this->translator->trans('label.document.status.'.$status);
|
||||||
$class = 'upload-status-badge ';
|
$class = 'upload-status-badge ';
|
||||||
$class .= match($status) {
|
$class .= match ($status) {
|
||||||
Upload::STATUS_NEW => 'upload-status-badge--new',
|
Upload::STATUS_NEW => 'upload-status-badge--new',
|
||||||
Upload::STATUS_REJECTED => 'upload-status-badge--error',
|
Upload::STATUS_REJECTED => 'upload-status-badge--error',
|
||||||
Upload::STATUS_PAID => 'upload-status-badge--paid',
|
Upload::STATUS_PAID => 'upload-status-badge--paid',
|
||||||
@@ -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