feat: dedicated logos per country for accommodation bookings
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Entity\BlameableEntity;
|
||||
use App\Entity\BlameableEntityInterface;
|
||||
use App\Entity\TimestampableEntity;
|
||||
use App\Entity\TimestampableEntityInterface;
|
||||
use App\Enum\Groups\AccommodationCountry;
|
||||
use App\Repository\Groups\AccommodationRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
@@ -64,6 +65,10 @@ class Accommodation implements BlameableEntityInterface, TimestampableEntityInte
|
||||
#[Assert\Choice(choices: ['EUR', 'CHF'], message: 'invalid')]
|
||||
private ?string $currency = 'EUR';
|
||||
|
||||
#[ORM\Column(length: 2, enumType: AccommodationCountry::class)]
|
||||
#[Assert\NotNull(message: 'required')]
|
||||
private ?AccommodationCountry $country = AccommodationCountry::Germany;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->accommodationPrices = new ArrayCollection();
|
||||
@@ -171,6 +176,18 @@ class Accommodation implements BlameableEntityInterface, TimestampableEntityInte
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCountry(): ?AccommodationCountry
|
||||
{
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
public function setCountry(AccommodationCountry $country): self
|
||||
{
|
||||
$this->country = $country;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, BoardService>
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enum\Groups;
|
||||
|
||||
enum AccommodationCountry: string
|
||||
{
|
||||
case Germany = 'DE';
|
||||
case Austria = 'AT';
|
||||
case Switzerland = 'CH';
|
||||
case Italy = 'IT';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'enum.accommodation_country.'.$this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logo of the legal entity operating this country's accommodations, shown in the
|
||||
* header of the public booking and offer pages. Null falls back to the logo of the
|
||||
* request host — Germany has no dedicated entity.
|
||||
*/
|
||||
public function logo(): ?string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Austria => 'logo_cllt.svg',
|
||||
self::Switzerland => 'logo_alpinevacation.svg',
|
||||
self::Italy => 'logo_ep.svg',
|
||||
self::Germany => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,10 @@ declare(strict_types=1);
|
||||
namespace App\Form\Admin\Groups;
|
||||
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use App\Enum\Groups\AccommodationCountry;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -38,6 +40,11 @@ class AccommodationType extends AbstractType
|
||||
'CHF' => 'CHF',
|
||||
],
|
||||
])
|
||||
->add('country', EnumType::class, [
|
||||
'label' => 'Land',
|
||||
'class' => AccommodationCountry::class,
|
||||
'choice_label' => fn (AccommodationCountry $country): string => $country->label(),
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user