<?php
namespace App\Component\AdminMenu\EventSubscriber;
use App\Component\AdminMenu\Event\AbstractBuildMenuEvent;
use App\Component\AdminMenu\Event\BuildVacancyMenuEvent;
use App\Component\UserRole\Permission\UserRolePermission;
use App\Entity\JobAlert;
use App\Entity\JobAlertAd;
use App\EventListener\FeatureFlagListener;
class JobAlertMenuSubscriber extends AbstractMenuBuildEventSubscriber
{
protected static int $priority = -90;
protected static string $eventClass = BuildVacancyMenuEvent::class;
public function buildMenu(AbstractBuildMenuEvent $event)
{
if (
!$this->hasAccess(['ROLE_ADMIN_USER', [UserRolePermission::MASK_VIEW, JobAlert::class]])
|| !$this->checkFeatures([FeatureFlagListener::FEATURE_JOBALERT])
) {
return;
}
if ($this->checkFeatures([FeatureFlagListener::FEATURE_JOBALERT_ADS])) {
$menuBuilder = $this->getMenuBuilder($event->getMenu(), 'Vacancies')
->addMainItem('Job alert', 'fal fa-bell')
->addOverlay()
->addSection('Job alert')
->addColumn('General', 'fal fa-bell')
;
} else {
$this->getMenuBuilder($event->getMenu(), 'Vacancies')
->addMainItem('Job alert', 'fal fa-bell', 'admin_jobalerts')
->end();
return;
}
if (
$this->hasAccess(['ROLE_ADMIN_USER', [UserRolePermission::MASK_VIEW, JobAlertAd::class]])
&& $this->checkFeatures([FeatureFlagListener::FEATURE_JOBALERT_ADS])
) {
$menuBuilder
->addItem('Job alerts', 'admin_jobalerts')
->addItem('Job alert ads', 'admin_jobalert_ads')
->addItem('Job alert targetaudience', 'admin_targetaudiences')
->end()
;
}
}
}