mirror of
https://github.com/scummvm/scummvm-web.git
synced 2026-05-21 05:40:47 +00:00
42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
namespace ScummVM\Models;
|
|
|
|
use ScummVM\Objects\WebLink;
|
|
use Symfony\Component\Yaml\Yaml;
|
|
|
|
/**
|
|
* The LinksModel class will generate WebLink objects.
|
|
* LinkGroup-objects representing a group of external links on the website.
|
|
*/
|
|
class LinksModel extends BasicModel
|
|
{
|
|
/**
|
|
* Get all the groups and the respectively demos.
|
|
*
|
|
* @return array<array{'name': string, 'notes': string, 'links': array<WebLink>}>
|
|
*/
|
|
public function getAllGroupsAndLinks(): array
|
|
{
|
|
$entries = $this->getFromCache();
|
|
if (is_null($entries)) {
|
|
$fname = $this->getLocalizedFile('links.yaml');
|
|
$parsedData = Yaml::parseFile($fname);
|
|
$entries = [];
|
|
foreach ($parsedData as $value) {
|
|
/* Get all links. */
|
|
$links = [];
|
|
foreach ($value['links'] as $data) {
|
|
$links[] = new WebLink($data);
|
|
}
|
|
$entries[] = [
|
|
'name' => $value['name'],
|
|
'notes' => $value['notes'],
|
|
'links' => $links,
|
|
];
|
|
}
|
|
$this->saveToCache($entries);
|
|
}
|
|
return $entries;
|
|
}
|
|
}
|