Replace count(getEntries()) with countEntries()

This commit is contained in:
Yonas Habteab 2022-06-13 09:31:35 +02:00
parent d0b3437995
commit c56cbf25d6
3 changed files with 6 additions and 6 deletions

View File

@ -505,7 +505,7 @@ class DashboardsController extends CompatController
$activeHome = $this->dashboard->getActiveHome();
// We can't grant access the user to the dashboard manager if there aren't any dashboards to manage
if (! $activeHome || (! $activeHome->hasEntries() && count($this->dashboard->getEntries()) === 1)) {
if (! $activeHome || (! $activeHome->hasEntries() && $this->dashboard->countEntries() === 1)) {
$this->redirectNow(Dashboard::BASE_ROUTE);
}
@ -538,7 +538,7 @@ class DashboardsController extends CompatController
&& (
! $activeHome->isDefaultHome()
|| $activeHome->hasEntries()
|| count($this->dashboard->getEntries()) > 1
|| $this->dashboard->countEntries() > 1
)
) {
$params = [];

View File

@ -157,13 +157,13 @@ trait DashboardManager
$homes = is_array($entryOrEntries) ? $entryOrEntries : [$entryOrEntries];
// Highest priority is 0, so count($entries) are always lowest prio + 1
$priority = count($this->getEntries());
$priority = $this->countEntries();
/** @var DashboardHome $home */
foreach ($homes as $home) {
if (! $this->hasEntry($home->getName())) {
$conn->insert(DashboardHome::TABLE, [
'user_id' => self::getUser()->getAdditional('id'),
'user_id' => $this::getUser()->getAdditional('id'),
'name' => $home->getName(),
'label' => $home->getTitle(),
'priority' => $home->isDefaultHome() ? 0 : $priority++,
@ -184,7 +184,7 @@ trait DashboardManager
}
/**
* Get and|or init the default dashboard home
* Initialize and get the default dashboard home
*
* @return DashboardHome
*/

View File

@ -24,7 +24,7 @@ class Settings extends BaseHtmlElement
protected function assemble()
{
$activeHome = $this->dashboard->getActiveHome();
if (count($this->dashboard->getEntries()) === 1 && $activeHome->isDefaultHome()) {
if ($this->dashboard->countEntries() === 1 && $activeHome->isDefaultHome()) {
$this->setAttribute('data-icinga-home', DashboardHome::DEFAULT_HOME);
$this->addFrom((new DashboardHomeList($activeHome))->setHeaderDisabled());
} else {