Ran a pass through image and attachment routes

Added some stronger types, formatting changes and simplifications along
the way.
This commit is contained in:
Dan Brown
2021-11-01 11:17:30 +00:00
parent c7fea8fe08
commit 4360da03d4
5 changed files with 28 additions and 53 deletions

View File

@ -67,13 +67,12 @@ class DrawioImageController extends Controller
public function getAsBase64($id)
{
$image = $this->imageRepo->getById($id);
$page = $image->getPage();
if ($image === null || $image->type !== 'drawio' || !userCan('page-view', $page)) {
if (is_null($image) || $image->type !== 'drawio' || !userCan('page-view', $image->getPage())) {
return $this->jsonError('Image data could not be found');
}
$imageData = $this->imageRepo->getImageData($image);
if ($imageData === null) {
if (is_null($imageData)) {
return $this->jsonError('Image data could not be found');
}