Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N°5619 - Hide newsroom menu when no provider #363

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -21,6 +21,7 @@


use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenu;
use MetaModel;

/**
* Class NewsroomMenu
Expand Down Expand Up @@ -65,4 +66,15 @@ public function GetParamsAsJson(): string
{
return json_encode($this->aParams);
}

/**
* Check if there is any Newsroom provider configured
* @since 3.1.0 N°5619
* @return bool
*/
public static function HasProviders(): bool
{
$aProviders = MetaModel::EnumPlugins('iNewsroomProvider');
return count($aProviders) > 0;
}
}
Expand Up @@ -269,7 +269,7 @@ public function GetSubBlocks(): array
*/
public function IsNewsroomEnabled(): bool
{
return MetaModel::GetConfig()->Get('newsroom_enabled');
return (MetaModel::GetConfig()->Get('newsroom_enabled') && NewsroomMenu::HasProviders());
}

/**
Expand Down
Expand Up @@ -21,6 +21,7 @@


use ApplicationContext;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\NewsroomMenu\NewsroomMenu;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\NewsroomMenu\NewsroomMenuFactory;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuFactory;
use MetaModel;
Expand Down Expand Up @@ -48,7 +49,7 @@ public static function MakeStandard()
{

$oNewsroomMenu = null;
if (MetaModel::GetConfig()->Get('newsroom_enabled'))
if (MetaModel::GetConfig()->Get('newsroom_enabled') && NewsroomMenu::HasProviders())
{
$oNewsroomMenu = NewsroomMenuFactory::MakeNewsroomMenuForNavigationMenu();
}
Expand Down