get('system.gpm.releases', 'stable'); $cache_dir = Grav::instance()['locator']->findResource('cache://gpm', true, true); $this->cache = new FilesystemCache($cache_dir); $this->repository = $repository . '?v=' . GRAV_VERSION . '&' . $channel . '=1'; $this->raw = $this->cache->fetch(md5($this->repository)); $this->fetch($refresh, $callback); foreach (json_decode($this->raw, true) as $slug => $data) { // Temporarily fix for using multisites if (isset($data['install_path'])) { $path = preg_replace('~^user/~i', 'user://', $data['install_path']); $data['install_path'] = Grav::instance()['locator']->findResource($path, false, true); } $this->items[$slug] = new Package($data, $this->type); } } public function fetch($refresh = false, $callback = null) { if (!$this->raw || $refresh) { $response = Response::get($this->repository, [], $callback); $this->raw = $response; $this->cache->save(md5($this->repository), $this->raw, $this->lifetime); } return $this->raw; } }