Skip to content

Commit

Permalink
Merge pull request #1551 from ezsystems/empty-tab-group
Browse files Browse the repository at this point in the history
EZP-31983: Catched exception thrown by empty tab group
  • Loading branch information
adamwojs authored Oct 6, 2020
2 parents cd03671 + a6677ea commit c8c1ead
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/lib/Tab/Event/Subscriber/ConditionalTabSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
use EzSystems\EzPlatformAdminUi\Tab\ConditionalTabInterface;
use EzSystems\EzPlatformAdminUi\Tab\Event\TabEvents;
use EzSystems\EzPlatformAdminUi\Tab\Event\TabGroupEvent;
use EzSystems\EzPlatformAdminUi\Tab\OrderedTabInterface;
use EzSystems\EzPlatformAdminUi\UI\Service\TabService;
use InvalidArgumentException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* Reorders tabs according to their Order value (Tabs implementing OrderedTabInterface).
* Tabs without order specified are pushed to the end of the group.
* Evaluates if tabs should be visible (Tabs implementing ConditionalTabInterface).
*
* @see OrderedTabInterface
* @see ConditionalTabInterface
*/
class ConditionalTabSubscriber implements EventSubscriberInterface
{
Expand Down Expand Up @@ -51,7 +50,11 @@ public function onTabGroupInitialize(TabGroupEvent $tabGroupEvent)
$tabGroup = $tabGroupEvent->getData();
$tabGroupIdentifier = $tabGroupEvent->getData()->getIdentifier();
$parameters = $tabGroupEvent->getParameters();
$tabs = $this->tabService->getTabGroup($tabGroupIdentifier)->getTabs();
try {
$tabs = $this->tabService->getTabGroup($tabGroupIdentifier)->getTabs();
} catch (InvalidArgumentException $e) {
$tabs = [];
}

foreach ($tabs as $tab) {
if (!$tab instanceof ConditionalTabInterface || $tab->evaluate($parameters)) {
Expand Down

0 comments on commit c8c1ead

Please sign in to comment.