Files
scummvm-web/include/Models/VersionsModel.php
T
Mataniko 41f028310c WEB: Use symfony/yaml and predis if redis is not available
This removes the hard requirements on pecl modules making development easier.
2020-10-21 23:08:08 -04:00

37 lines
982 B
PHP

<?php
namespace ScummVM\Models;
use ScummVM\Objects\Version;
use Symfony\Component\Yaml\Yaml;
/**
* The VersionsModel is used to cross reference versions across the website
*/
class VersionsModel extends BasicModel
{
/* Get all versions from YAML */
public function getAllVersions()
{
$data = $this->getFromCache();
if (is_null($data)) {
$fname = $this->getLocalizedFile('versions.yaml');
$versions = Yaml::parseFile($fname);
$data = [];
foreach ($versions as $version) {
$obj = new Version($version);
$data[$obj->getId()] = $obj;
}
\uasort($data, "version_compare");
if (!array_key_exists('DEV', $data)) {
$data['DEV'] = new Version(["id" => 'DEV', "date" => "1/1/2099"]);
}
$data = array_reverse($data, true);
$this->saveToCache($data);
}
return $data;
}
}