*/ public function getAllGroupsAndDemos(): array { $groupedData = $this->getFromCache(); if (is_null($groupedData)) { $demos = DirectorDemoQuery::create() ->orderByVersion() ->orderByTitle() ->find(); $groupedData = $this->createGroups($demos); $this->saveToCache($groupedData); } return $groupedData; } /** * @return array */ private function createGroups(Collection $demos): array { $groups = []; foreach ($demos as $demo) { $version = $demo->getVersion(); if (!isset($groups[$version])) { $groups[$version] = [ 'name' => "Version $version Demos", 'href' => $version, 'demos' => [] ]; } $groups[$version]['demos'][] = $demo; } return $groups; } }