mirror of
https://github.com/scummvm/scummvm-web.git
synced 2026-06-20 05:45:49 +00:00
WEB: Add new Models and Objects to support the new data files
This commit is contained in:
1 parent
c6207590c9
commit
a75a6c70ee
11 files changed
+333
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user