feat: custom destinations

This commit is contained in:
Björn Fromme committed 2024-05-15 17:32:07 +02:00
1 parent 57e1082f2f
commit efc4b58077
27 files changed
+826 -40

No files matched your search

@@ -2,25 +2,26 @@
namespace App\Form\ChoiceLoader;
use App\BusProNet\DataProvider\ProductDataProvider;
use App\BusProNet\Model\Product;
use App\BusProNet\DataProvider\HotelDataProvider;
use App\BusProNet\Model\Hotel;
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
class BpnProductsChoiceLoader implements ChoiceLoaderInterface
class BpnHotelChoiceLoader implements ChoiceLoaderInterface
{
public function __construct(private readonly ProductDataProvider $products)
public function __construct(private readonly HotelDataProvider $dataProvider)
{}
public function loadChoiceList(callable $value = null): ChoiceListInterface
{
$choices = [];
/** @var Product[] $products */
$products = $this->products->getAll();
/** @var Hotel[] $hotels */
$hotels = $this->dataProvider->getAll();
foreach ($products as $product) {
$choices[$product->getName()] = $product->getId();
foreach ($hotels as $hotel) {
$label = sprintf('%s (%s)', $hotel->getName(), $hotel->getCode());
$choices[$label] = $hotel->getBusProId();
}
ksort($choices);
@@ -8,16 +8,16 @@ use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
class BpnPickupsChoiceLoader implements ChoiceLoaderInterface
class BpnPickupChoiceLoader implements ChoiceLoaderInterface
{
public function __construct(private readonly PickupDataProvider $pickups)
public function __construct(private readonly PickupDataProvider $dataProvider)
{}
public function loadChoiceList(callable $value = null): ChoiceListInterface
{
$choices = [];
/** @var Pickup[] $pickups */
$pickups = $this->pickups->getAll();
$pickups = $this->dataProvider->getAll();
foreach ($pickups as $pickup) {
$choices[$pickup->getCity()] = $pickup->getBusProId();