49 lines
994 B
PHP
49 lines
994 B
PHP
<?php
|
|
|
|
class MediaModel extends Model implements MediaInterface{
|
|
private $mediaRenderer;
|
|
|
|
public function __construct($saveableObject = null){
|
|
if(property_exists($saveableObject, mediaType)){
|
|
parent::__construct($saveableObject);
|
|
if ($this->type == self::TYPE_HTML5){
|
|
$this->mediaRenderer = new MediaHtml5($this);
|
|
}
|
|
}
|
|
else{
|
|
throw new MediaException("Invalid media type for Media; mediatype '".$mediaType."'");
|
|
}
|
|
}
|
|
|
|
private function asText(){
|
|
return $this->mediaRenderer->asText();
|
|
}
|
|
|
|
public function renderMedia(){
|
|
$this->mediaRenderer->render();
|
|
}
|
|
|
|
public function getType(){
|
|
return $this->type;
|
|
}
|
|
|
|
public function getTitle(){
|
|
return $this->details;
|
|
}
|
|
|
|
public static function getCollectionName(){
|
|
return "media";
|
|
}
|
|
|
|
public function setOwner(HasMediaInterface $model){
|
|
$this->owner = $model->getReference();
|
|
}
|
|
public function getOwnerReference(){
|
|
return $this->owner;
|
|
}
|
|
|
|
public function getReference(){
|
|
return $this->id;
|
|
}
|
|
}
|
|
?>
|