<?php
namespace App\Component\AdminMenu\EventSubscriber;
use App\Component\AdminMenu\Event\AbstractBuildMenuEvent;
use App\EventListener\FeatureFlagListener;
class MarketingMenuSubscriber extends AbstractMenuBuildEventSubscriber
{
protected static int $priority = -80;
public function buildMenu(AbstractBuildMenuEvent $event)
{
if (!$this->authorizationChecker->isGranted('ROLE_ADMIN_USER')) {
return;
}
if (
!$this->checkCommonColumnPersmissions()
&& !$this->checkGoogleColumnPermissions()
&& !$this->checkAdsColumnPermissions()
) {
return;
}
$menuBuilder = $this->getMenuBuilder($event->getMenu())
->addMainItem('Marketing', 'fal fa-bullseye-arrow')
->addOverlay()
->addSection('Marketing');
if ($this->checkCommonColumnPersmissions()) {
$menuBuilder->addColumn('Common', 'fal fa-globe');
if ($this->checkFeatures([FeatureFlagListener::FEATURE_REDIRECTS])) {
$menuBuilder->addItem('Redirects', 'admin_redirect_index')
->addItem('Redirects (legacy)', 'admin_redirects_index');
}
if ($this->checkFeatures([FeatureFlagListener::FEATURE_SEO_SNIPPET])) {
$menuBuilder->addItem('SEO snippets', 'admin_seo_snippet_index')
->addItem('SEO templates', 'admin_meta_templates_index');
}
$menuBuilder->addItem('Robots', 'robots');
$menuBuilder->end();
}
if ($this->checkGoogleColumnPermissions()) {
$menuBuilder->addColumn('Google', 'fab fa-google')
->addItem('Google for Jobs', 'google_for_jobs_mapping');
if ($this->checkFeatures([FeatureFlagListener::FEATURE_GOOGLE_TAG_MANAGER])) {
$menuBuilder->addItem('Google Trackingpixels', 'admin_trackingpixels')
->addItem('Google Tag-manager', 'admin_googletagmanager');
}
$menuBuilder->end();
}
if ($this->checkAdsColumnPermissions()) {
$menuBuilder->addColumn('Ads', 'fal fa-hand-holding-usd')
->addItem('View ads', 'admin_ad')
->addItem('Ad categories', 'admin_ad_categories')
->end();
}
}
public function checkCommonColumnPersmissions(): bool
{
// Robots has no feature flag, so this column should always be shown
return true;
}
public function checkGoogleColumnPermissions(): bool
{
// Google for jobs has no feature, this column should always show
return true;
}
public function checkAdsColumnPermissions(): bool
{
return $this->checkFeatures([
FeatureFlagListener::FEATURE_ADS,
]);
}
}