Skip to content

Commit

Permalink
pkp#10668 code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Jan 21, 2025
1 parent 0b2ca57 commit 69319c0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions classes/announcement/Announcement.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function save(array $options = [])

Hook::call('Announcement::add', [$this]);

$hasNewImage = isset($this?->image?->temporaryFileId) ? $this->image->temporaryFileId : null;
$hasNewImage = $this?->image?->temporaryFileId ?? null;

// if announcement is being inserted and includes new image, upload it
if ($newlyCreated) {
Expand All @@ -135,7 +135,7 @@ public function save(array $options = [])
$this->handleImageUpload();
}

// If there is no new image and image data exists in DB and it's now removed
// If there is no new image and image data exists in DB and it's now removed as part of update
// need to delete the image for this announcement model instance
if (!$hasNewImage && !$this?->image && $this->fresh()->image) {
$this->deleteImage();
Expand Down Expand Up @@ -290,7 +290,7 @@ protected function imageUrl(bool $withTimestamp = true): Attribute
protected function imageAltText(): Attribute
{
return Attribute::make(
get: fn () => isset($this->image?->altText) ? $this->image->altText : ''
get: fn () => $this->image?->altText ?? ''
);
}

Expand Down Expand Up @@ -363,7 +363,7 @@ protected function getImageData(TemporaryFile $temporaryFile): array
'name' => $temporaryFile->getOriginalFileName(),
'uploadName' => $this->getImageFilename($temporaryFile),
'dateUploaded' => Core::getCurrentDate(),
'altText' => isset($image->altText) ? $image->altText : '',
'altText' => $image->altText ?? '',
];
}

Expand Down

0 comments on commit 69319c0

Please sign in to comment.