public function listMonths() { if (!is_null($this->months)) { return $this->months; } $months = []; foreach (FlyerModel::countsPerMonth() as $year => $counts) { $months[$year] = ['months' => [], 'url' => $this->controller->pageUrl($this->flyersPage, ['year' => $year], false), 'active' => $year === $this->year]; foreach ($counts as $month => $count) { $months[$year]['months'][$month] = ['count' => $count, 'url' => $this->controller->pageUrl($this->flyersPage, ['year' => $year, 'month' => $month], false), 'active' => $year === $this->year && $month === $this->month]; } } return $this->months = $months; }