Skip to content

Instantly share code, notes, and snippets.

@wizhippo
Created March 2, 2018 15:16
Show Gist options
  • Save wizhippo/555d891dbe84a1e3196825b601908f06 to your computer and use it in GitHub Desktop.
Save wizhippo/555d891dbe84a1e3196825b601908f06 to your computer and use it in GitHub Desktop.
<?php
namespace EzSystems\EzPlatformAdminUi\Tab\Event\Subscriber;
use EzSystems\EzPlatformAdminUi\Tab\Event\TabEvents;
use EzSystems\EzPlatformAdminUi\Tab\Event\TabGroupEvent;
use EzSystems\EzPlatformAdminUi\Tab\TabRegistry;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class LocationViewTabSubscriber implements EventSubscriberInterface
{
/** @var TabRegistry */
protected $tabRegistry;
public function __construct(TabRegistry $tabRegistry)
{
$this->tabRegistry = $tabRegistry;
}
public static function getSubscribedEvents(): array
{
return [
TabEvents::TAB_GROUP_PRE_RENDER => ['onTabGroupPreRender'],
];
}
public function onTabGroupPreRender(TabGroupEvent $tabGroupEvent)
{
$tabGroup = $tabGroupEvent->getData();
if ('location-view' !== $tabGroup->getIdentifier()) {
return;
}
$paramters = $tabGroupEvent->getParamters();
$content = $paramters['content'];
if ($this->isSomeContentType($content)) {
$this->tabRegistry->addTab(
...,
'location-view'
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment