Clean code
This commit is contained in:
@@ -133,9 +133,11 @@ class Post extends DB\SQL\Mapper
|
||||
public function delete(int $id): void
|
||||
{
|
||||
$this->load(['id = ?', $id]);
|
||||
if (!$this->dry()) {
|
||||
$this->erase();
|
||||
if ($this->dry()) {
|
||||
throw new RuntimeException('Article introuvable.');
|
||||
}
|
||||
|
||||
$this->erase();
|
||||
}
|
||||
|
||||
private function payload(array $input): array
|
||||
@@ -168,7 +170,7 @@ class Post extends DB\SQL\Mapper
|
||||
}
|
||||
}
|
||||
|
||||
$bodyHtml = MarkdownService::compile($bodyMarkdown, $media);
|
||||
$bodyHtml = MarkdownService::instance()->compile($bodyMarkdown, $media);
|
||||
|
||||
return [
|
||||
'title' => $title,
|
||||
@@ -193,10 +195,7 @@ class Post extends DB\SQL\Mapper
|
||||
'excerpt' => (string) $row['excerpt'],
|
||||
'cover_media_id' => (int) ($row['cover_media_id'] ?? 0),
|
||||
'created_at' => (string) $row['created_at'],
|
||||
'created_at_label' => app_format_datetime_fr((string) $row['created_at']),
|
||||
'updated_at' => (string) $row['updated_at'],
|
||||
'updated_at_label' => app_format_datetime_fr((string) $row['updated_at']),
|
||||
'has_updated_at' => (string) $row['updated_at'] !== (string) $row['created_at'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user