WIP: Implement application process

This commit is contained in:
Björn Fromme
2023-10-09 14:42:37 +02:00
parent 8e3499581a
commit abced8c924
26 changed files with 802 additions and 138 deletions
+30 -20
View File
@@ -3,9 +3,7 @@
namespace App\Twig;
use App\BusProNet\DataProvider\CountryDataProvider;
use App\BusProNet\DataProvider\HotelDataProvider;
use App\BusProNet\DataProvider\PickupDataProvider;
use App\BusProNet\Model\Country;
use App\Entity\Teamer;
use Carbon\Carbon;
use Symfony\Component\HttpFoundation\RequestStack;
@@ -16,12 +14,11 @@ use Twig\Extra\Intl\IntlExtension;
class AppRuntime implements RuntimeExtensionInterface
{
public function __construct(
private readonly RequestStack $requestStack,
private readonly IntlExtension $intlExtension,
private readonly RequestStack $requestStack,
private readonly IntlExtension $intlExtension,
private readonly CountryDataProvider $countries,
private readonly PickupDataProvider $pickups,
private readonly HotelDataProvider $hotels,
private readonly string $environment
private readonly PickupDataProvider $pickups,
private readonly string $environment
) {
}
@@ -47,7 +44,7 @@ class AppRuntime implements RuntimeExtensionInterface
return 'unbekannt';
}
return 'nationality' === $property ? $country->getNationality() : $country->getName();
return 'nationality' === $property ? $country->getNationality() : $country->getName();
}
public function bpnPickupLabel(int $id): string
@@ -61,17 +58,6 @@ class AppRuntime implements RuntimeExtensionInterface
return $pickup->getCity();
}
public function bpnDestinationLabel(int $id): string
{
$hotel = $this->hotels->get($id);
if (null === $hotel) {
return 'unbekannt';
}
return sprintf('%s, %s', $hotel->getName(), $hotel->getCity() ?? '-');
}
public function fileIconFilter(Environment $environment, string $mimeType, ?string $classes = 'w-4 h-4'): string
{
$icon = match ($mimeType) {
@@ -89,7 +75,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
@@ -108,6 +94,19 @@ class AppRuntime implements RuntimeExtensionInterface
]);
}
public function nl2List(string $content, string $class = 'list-disc pl-4'): string
{
$items = explode(PHP_EOL, $content);
$list = '<ul class="'.$class.'">';
foreach ($items as $item) {
$list .= '<li>'.$item.'</li>';
}
$list .= '<ul>';
return $list;
}
public function isCurrentRoute(string $route): bool
{
$requestedRoute = $this->requestStack->getMainRequest()->attributes->get('_route');
@@ -115,6 +114,17 @@ class AppRuntime implements RuntimeExtensionInterface
return $requestedRoute === $route;
}
public function getEncodedReturnUrl(): string
{
$masterRequest = $this->requestStack->getMainRequest();
if (null === $masterRequest) {
return '';
}
return rawurlencode($masterRequest->getRequestUri());
}
public function renderQaAttribute(string $label, string $value = null): string
{
if ('test' !== $this->environment) {