parent
05952b9434
commit
681d5ded9e
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once "commentaryEntity.php";
|
||||
require_once "commentaryGateway.php";
|
||||
class CommentaryModel {
|
||||
|
||||
private commentaryGateway $gw;
|
||||
|
||||
function __construct(commentaryGateway $gw) {
|
||||
$this->gw = $gw;
|
||||
}
|
||||
|
||||
public function createComment(int $id_comment, string $comment, string $date): bool {
|
||||
|
||||
$c = new CommentaryEntity($id_comment, $comment, $date);
|
||||
return $this->gw->create($c);
|
||||
}
|
||||
|
||||
public function getComment(int $id_comment): ?commentaryEntity {
|
||||
return $this -> gw -> findById($id_comment);
|
||||
}
|
||||
|
||||
public function getComments(): array {
|
||||
return $this -> gw -> findAll();
|
||||
}
|
||||
|
||||
public function deleteComment(int $id_comment): bool {
|
||||
return $this -> gw -> delete($id_comment);
|
||||
}
|
||||
|
||||
public function updateComment(int $id_comment, string $comment): bool {
|
||||
|
||||
$c = $this -> gw -> findById($id_comment);
|
||||
|
||||
if($c){
|
||||
$c -> setComment($comment);
|
||||
return $this->gw -> update($c);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue