Created
March 2, 2018 15:16
-
-
Save wizhippo/555d891dbe84a1e3196825b601908f06 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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