1 2 @@ -6,13 +6,94 @@ 4 5 6 -7+7 +8 +9
// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;
-return function (RoutingConfigurator $routes) {
- $routes->add('about_us', ['nl' => '/over-ons', 'en' => '/about-us'])
- ->controller('App\Controller\CompanyController::about');
+ use App\Controller\CompanyController;
+
+return static function (RoutingConfigurator $routes): void {
+ $routes->add('about_us', ['nl' => '/over-ons', 'en' => '/about-us'])
+ ->controller(CompanyController::class.'::about');
};
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16+
+enum TextAlign: string implements TranslatableInterface
+{
+ case Left = 'Left aligned';
+ case Center = 'Center aligned';
+ case Right = 'Right aligned';
+
+ public function trans(TranslatorInterface $translator, ?string $locale = null): string
+ {
+ // Translate enum using custom labels
+ return match ($this) {
+ self::Left => $translator->trans('text_align.left.label', locale: $locale),
+ self::Center => $translator->trans('text_align.center.label', locale: $locale),
+ self::Right => $translator->trans('text_align.right.label', locale: $locale),
+ };
+ }
+}
+
+
+ 1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16+
+public function getUserBadgeFrom(string $accessToken): UserBadge
+{
+ // get the data from the token
+ $payload = ...;
+
+ return new UserBadge(
+ $payload->getUserId(),
+ fn (string $userIdentifier): User => new User($userIdentifier, $payload->getRoles())
+ );
+
+ // or
+ return new UserBadge(
+ $payload->getUserId(),
+ $this->loadUser(...)
+ );
+}
+
+