/** * @param string|array $imageIds * * @return Image[] * @throw HttpException */ protected function validateImages($imageIds) { if (!is_array($imageIds)) { $imageIds = explode(',', $imageIds); } $images = []; foreach ($imageIds as $imageId) { /** @var Image $image */ $image = Image::find($imageId); if (!$image) { throw new HttpException(404, "Image ({$imageId}) not found."); } if ($image->userId !== $this->user->id) { throw new HttpException(403, "User does not own image ({$imageId})."); } $images[] = $image; } return $images; }