예제 #1
0
     throw new \Symfony\Component\HttpKernel\Exception\NotFoundHttpException();
 }
 $templateParams = [];
 if ($page === 'index') {
     $manifestFile = new SplFileInfo($app['releases.path'] . '/manifest.json');
     // Getting the latest stable release
     $manifestData = json_decode(file_get_contents($manifestFile->getPathname()), true);
     $stable = '';
     $latest = new \Herrera\Version\Version();
     $builder = new \Herrera\Version\Builder();
     foreach ($manifestData as $versionData) {
         $version = $builder->importString($versionData['version'])->getVersion();
         if ($stable === '' && !$version->isStable()) {
             continue;
         }
         if (\Herrera\Version\Comparator::isLessThan($latest, $version)) {
             $latest = $version;
         }
     }
     $templateParams['latest_deployer_version'] = $latest;
     $templateLastModified = new DateTime('@' . $templateFile->getMTime());
     $manifestLastModified = new DateTime('@' . $manifestFile->getMTime());
     $response->setLastModified($templateLastModified > $manifestLastModified ? $templateLastModified : $manifestLastModified);
     if ($response->isNotModified($request)) {
         return $response;
     }
 } else {
     $response->setLastModified(new DateTime('@' . $templateFile->getMTime()));
     if ($response->isNotModified($request)) {
         return $response;
     }
예제 #2
0
 $response->setPublic();
 // Handling the manifest data
 if ($file->isReadable()) {
     // If there were no new releases, then just return with the last on
     $response->setLastModified(new DateTime('@' . $file->getMTime()));
     if ($response->isNotModified($request)) {
         return $response;
     }
     $manifestData = json_decode(file_get_contents($file->getPathname()), true);
     // Sorting the versions in descending order
     $builder = new \Herrera\Version\Builder();
     uasort($manifestData, function ($a, $b) use($builder) {
         if ($a['version'] === $b['version']) {
             return 0;
         }
         return \Herrera\Version\Comparator::isLessThan($builder->importString($a['version'])->getVersion(), $builder->importString($b['version'])->getVersion());
     });
     // Adding the "highlighted" bool value to every version.
     // Only the latest stable release is highlighted in every major version.
     $prevMajorVersion = null;
     foreach ($manifestData as $key => $data) {
         $manifestData[$key]['highlighted'] = false;
         $version = $builder->importString($data['version'])->getVersion();
         if ($version->getMajor() !== $prevMajorVersion && $version->isStable()) {
             $manifestData[$key]['highlighted'] = true;
             $prevMajorVersion = $version->getMajor();
         }
     }
 }
 // Rendering the template, setting up the response
 $response->headers->set('Content-Type', 'text/html');
 /**
  * @dataProvider getLess
  */
 public function testIsLessThan($left, $right)
 {
     $this->assertTrue(Comparator::isLessThan(Builder::create()->importString($left), Builder::create()->importString($right)));
 }