WEB: Add new Models and Objects to support the new data files

This commit is contained in:
Mataniko authored and Matan Bareket committed 2020-09-27 22:08:07 -04:00
1 parent c6207590c9
commit a75a6c70ee
11 files changed
+333

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
<?php
namespace ScummVM\Objects;
/**
* The DataObject class is inherited by all other new data objects
* and houses all common functions.
*/
abstract class DataObject
{
protected $id;
public function __construct($data)
{
if (array_key_exists('id', $data)) {
$this->id = $data['id'];
} elseif (array_key_exists('support', $data)) { // Compatibility
$this->id = join("_",[$data['game_id'],$data['version']]);
}
}
/* Get the ID. */
public function getId()
{
return $this->id;
}
public function getDescription()
{
return $this->description;
}
/**
* If the input array doesn't contain the numerical key 0, wrap it inside
* an array. This functions operates on the data directly.
*
* @param mixed $data the input
*/
public static function toArray(&$data)
{
if (!is_array($data) || !array_key_exists(0, $data)) {
$data = array($data);
}
}
}