/** * Get all menu * * @param string $siteKey site key * @param array $with relation * @return Menu[] */ public function all($siteKey, $with = []) { $menus = $this->repo->all($siteKey, $with); foreach ($menus as $menu) { $this->bag[$menu->getKey()] = $menu; } return $menus; }
/** * Get all menu * * @param string $siteKey site key * @param array $with relation * @return Menu[] */ public function all($siteKey, $with = []) { $key = $this->getCacheKey($siteKey . '_all'); return $this->cache->has($key) ? $this->cache->get($key) : call_user_func(function () use($key, $siteKey, $with) { if ($menu = $this->repo->all($siteKey, $with)) { $this->cache->put($key, $menu); } return $menu; }); }
/** * Get all menu * * @param string $siteKey site key * @param array $with relation * @return Menu[] */ public function all($siteKey, $with = []) { $key = $this->getCacheKey($siteKey . '_all'); $subKey = $this->getWithKey($with); $data = $this->cache->get($key); if (!$data || !isset($data[$subKey])) { $menus = $this->repo->all($siteKey, $with); if (!empty($menus)) { $data = $data ?: []; $data[$subKey] = $menus; $this->cache->put($key, $data); } } else { $menus = $data[$subKey]; } return $menus; }
/** * Get all menu * * @param string $siteKey site key * @param array $with relation * @return Menu[] */ public function getAll($siteKey, $with = []) { return $this->repo->all($siteKey, $with); }