コード例 #1
0
 private function getPackagesJsonData()
 {
     if ($this->cache->contains('packages_json_downloads') !== FALSE) {
         // If we have it in cache, get the packages.json file
         $packagesDataJson = $this->cache->fetch('packages_json_downloads');
         $cacheStatus = 'Hit';
     } else {
         // If we don't have it in cache, find it & load it
         $locator = new FileLocator($this->kernel->getRootDir());
         $locator->locate('packages.json', null, true);
         $packagesDataJson = $locator->getContents();
         $this->cache->save('packages_json_downloads', $packagesDataJson, 86400);
         $cacheStatus = 'Miss';
     }
     // Parse JSON response and discard irrelevant branches
     return json_decode($packagesDataJson, true);
 }