WIP: posting shiai to the wkKalendar via api
This commit is contained in:
@@ -21,10 +21,10 @@ class Shiai
|
||||
*/
|
||||
private static $tableName = "wettkampfkalender";
|
||||
|
||||
public function __construct($id, $date, $name, $ageclasses, $place, $announcementUrl, $routeUrl, $galleryUrl, $promoImgUrl)
|
||||
public function __construct($id, $date, $name, $ageclasses, $place, $announcementUrl, $routeUrl, $galleryUrl=null, $promoImgUrl=null)
|
||||
{
|
||||
//! @todo input validation and sanitation
|
||||
$this->id = (int) $id;
|
||||
$this->id = filterId($id);
|
||||
$this->date = DateTime::createFromFormat('Y-m-d', $date);
|
||||
$this->name = $name;
|
||||
$this->ageclasses = $ageclasses ? self::akListString2jgArray($ageclasses) : null;
|
||||
@@ -35,6 +35,32 @@ class Shiai
|
||||
$this->promoImgUrl = $promoImgUrl;
|
||||
}
|
||||
|
||||
public static function fromArray(array $shiai){
|
||||
$id = $shiai['id'] ?? null;
|
||||
$date = $shiai['date'] ?? null;
|
||||
$name = $shiai['name'] ?? null;
|
||||
$ageclasses = $shiai['ageclasses'] ?? null;
|
||||
$place = $shiai['place'] ?? null;
|
||||
$announcementUrl = $shiai['announcementUrl'] ?? null;
|
||||
$routeUrl = $shiai['routeUrl'] ?? null;
|
||||
// gallery stuff removed for now
|
||||
|
||||
return new Shiai($id, $date, $name, $ageclasses, $place, $announcementUrl, $routeUrl);
|
||||
}
|
||||
|
||||
public function asArray(){
|
||||
return [
|
||||
'id'=>$this->id,
|
||||
'date'=>$this->date->format('Y-m-d'),
|
||||
'name'=>$this->name,
|
||||
// @todo at least in theory this should again hold age categories
|
||||
'ageclasses'=>implode(" ", $this->ageclasses),
|
||||
'place'=>$this->place,
|
||||
'announcementUrl'=>$this->announcementUrl,
|
||||
'routeUrl'=>$this->announcementUrl
|
||||
];
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
|
||||
Reference in New Issue
Block a user