feat: all-season assignments
This commit is contained in:
1 parent
675cec1b69
commit
cf876ed224
119 files changed
+6194
-294
No files matched your search
@@ -2,10 +2,27 @@
|
||||
|
||||
namespace App\Menu;
|
||||
|
||||
use App\Entity\SeasonAssignment;
|
||||
use App\Entity\User;
|
||||
use App\Service\Season\SeasonAssignmentResolver;
|
||||
use Knp\Menu\FactoryInterface;
|
||||
use Knp\Menu\ItemInterface;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class TeamerMenuBuilder extends AbstractMenuBuilder
|
||||
{
|
||||
public function __construct(
|
||||
FactoryInterface $factory,
|
||||
Security $security,
|
||||
RequestStack $requestStack,
|
||||
TranslatorInterface $translator,
|
||||
private readonly SeasonAssignmentResolver $seasonAssignmentResolver,
|
||||
) {
|
||||
parent::__construct($factory, $security, $requestStack, $translator);
|
||||
}
|
||||
|
||||
public function createMainMenu(array $options): ItemInterface
|
||||
{
|
||||
$menu = $this->createRootElement();
|
||||
@@ -36,6 +53,23 @@ class TeamerMenuBuilder extends AbstractMenuBuilder
|
||||
'icon' => 'profile',
|
||||
],
|
||||
]);
|
||||
|
||||
// Only for an all-season teamer who actually has an assignment this season: the page
|
||||
// would have nothing to show otherwise, and it throws a 404 in exactly that case.
|
||||
if (null !== $this->resolveSeasonAssignment()) {
|
||||
$profileMenu->addChild('Saison-Teamer:in', [
|
||||
'route' => 'app_teamer_season_index',
|
||||
'linkAttributes' => [
|
||||
'title' => 'Saison-Teamer:in',
|
||||
],
|
||||
'extras' => [
|
||||
'routes' => [
|
||||
['pattern' => '/^app_teamer_season_/'],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
$profileMenu->addChild('Stammdaten & Foto', [
|
||||
'route' => 'app_teamer_profile_index',
|
||||
'linkAttributes' => [
|
||||
@@ -120,4 +154,15 @@ class TeamerMenuBuilder extends AbstractMenuBuilder
|
||||
|
||||
return $menu;
|
||||
}
|
||||
|
||||
private function resolveSeasonAssignment(): ?SeasonAssignment
|
||||
{
|
||||
$user = $this->security->getUser();
|
||||
|
||||
if (false === $user instanceof User || null === $teamer = $user->getTeamer()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->seasonAssignmentResolver->resolveFor($teamer);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user