Skip to content

Commit

Permalink
fix: add missing docs for exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
lukmzig committed Jun 6, 2024
1 parent 81e47ed commit 0b7b614
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 8 deletions.
10 changes: 10 additions & 0 deletions src/Asset/Controller/Download/DownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\DownloadServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\AccessDeniedException;
use Pimcore\Bundle\StudioBackendBundle\Exception\ElementNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Exception\ElementStreamResourceNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidElementTypeException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse;
Expand All @@ -46,6 +50,12 @@ public function __construct(
parent::__construct($serializer);
}

/**
* @throws AccessDeniedException
* @throws ElementStreamResourceNotFoundException
* @throws ElementNotFoundException
* @throws InvalidElementTypeException
*/
#[Route('/assets/{id}/download', name: 'pimcore_studio_api_download_asset', methods: ['GET'])]
//#[IsGranted('STUDIO_API')]
//#[IsGranted(UserPermissions::ASSETS->value)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\DownloadServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\AccessDeniedException;
use Pimcore\Bundle\StudioBackendBundle\Exception\ElementNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Exception\SearchException;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidElementTypeException;
use Pimcore\Bundle\StudioBackendBundle\Exception\ThumbnailResizingFailedException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse;
Expand All @@ -54,7 +56,10 @@ public function __construct(
}

/**
* @throws ElementNotFoundException|SearchException
* @throws AccessDeniedException
* @throws ElementNotFoundException
* @throws InvalidElementTypeException
* @throws ThumbnailResizingFailedException
*/
#[Route(
'/assets/{id}/image/download/custom',
Expand Down
11 changes: 9 additions & 2 deletions src/Asset/Controller/Download/Image/FormatDownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\DownloadServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\AccessDeniedException;
use Pimcore\Bundle\StudioBackendBundle\Exception\ElementNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Exception\SearchException;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidAssetFormatTypeException;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidElementTypeException;
use Pimcore\Bundle\StudioBackendBundle\Exception\ThumbnailResizingFailedException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse;
Expand All @@ -50,7 +53,11 @@ public function __construct(
}

/**
* @throws ElementNotFoundException|SearchException
* @throws AccessDeniedException
* @throws ElementNotFoundException
* @throws InvalidAssetFormatTypeException
* @throws InvalidElementTypeException
* @throws ThumbnailResizingFailedException
*/
#[Route(
'/assets/{id}/image/download/{format}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\DownloadServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\AccessDeniedException;
use Pimcore\Bundle\StudioBackendBundle\Exception\ElementNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidElementTypeException;
use Pimcore\Bundle\StudioBackendBundle\Exception\SearchException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Content\DataJson;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Serializer\SerializerInterface;

Expand All @@ -51,7 +51,7 @@ public function __construct(
parent::__construct($serializer);
}
/**
* @throws ElementNotFoundException|SearchException
* @throws AccessDeniedException|ElementNotFoundException|InvalidElementTypeException|SearchException
*/
#[Route(
'/assets/{id}/image/download/{thumbnailName}',
Expand Down
2 changes: 1 addition & 1 deletion src/Asset/Service/AssetService.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Pimcore\Bundle\StudioBackendBundle\DataIndex\AssetSearchServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\DataIndex\OpenSearchFilterInterface;
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Request\ElementParameters;
use Pimcore\Bundle\StudioBackendBundle\Exception\AccessDeniedException;
use Pimcore\Bundle\StudioBackendBundle\Exception\ElementNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidFilterServiceTypeException;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidFilterTypeException;
Expand All @@ -44,7 +45,6 @@
use Pimcore\Model\Element\ElementInterface;
use Pimcore\Model\UserInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Finder\Exception\AccessDeniedException;

/**
* @internal
Expand Down
13 changes: 13 additions & 0 deletions src/Asset/Service/DownloadService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Pimcore\Bundle\StudioBackendBundle\Exception\ElementStreamResourceNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidAssetFormatTypeException;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidElementTypeException;
use Pimcore\Bundle\StudioBackendBundle\Exception\ThumbnailResizingFailedException;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\Asset\FormatTypes;
use Pimcore\Model\Asset;
use Pimcore\Model\Asset\Image;
Expand All @@ -39,6 +40,9 @@ public function __construct(
{
}

/**
* @throws InvalidElementTypeException|ElementStreamResourceNotFoundException
*/
public function downloadAsset(
ElementInterface $asset
): StreamedResponse
Expand All @@ -64,6 +68,9 @@ public function downloadAsset(
]);
}

/**
* @throws InvalidElementTypeException|ThumbnailResizingFailedException
*/
public function downloadCustomImage(
ElementInterface $image,
ImageDownloadConfigParameter $parameters
Expand All @@ -79,6 +86,9 @@ public function downloadCustomImage(
);
}

/**
* @throws InvalidElementTypeException|InvalidAssetFormatTypeException|ThumbnailResizingFailedException
*/
public function downloadImageByFormat(ElementInterface $image, string $format): BinaryFileResponse
{
if (!$image instanceof Image) {
Expand Down Expand Up @@ -107,6 +117,9 @@ public function downloadImageByFormat(ElementInterface $image, string $format):
);
}

/**
* @throws InvalidElementTypeException
*/
public function downloadImageByThumbnail(
ElementInterface $image,
string $thumbnailName
Expand Down
16 changes: 16 additions & 0 deletions src/Asset/Service/DownloadServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
namespace Pimcore\Bundle\StudioBackendBundle\Asset\Service;

use Pimcore\Bundle\StudioBackendBundle\Asset\MappedParameter\ImageDownloadConfigParameter;
use Pimcore\Bundle\StudioBackendBundle\Exception\ElementStreamResourceNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidAssetFormatTypeException;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidElementTypeException;
use Pimcore\Bundle\StudioBackendBundle\Exception\ThumbnailResizingFailedException;
use Pimcore\Model\Element\ElementInterface;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;
Expand All @@ -26,20 +30,32 @@
*/
interface DownloadServiceInterface
{
/**
* @throws InvalidElementTypeException|ElementStreamResourceNotFoundException
*/
public function downloadAsset(
ElementInterface $asset
): StreamedResponse;

/**
* @throws InvalidElementTypeException|ThumbnailResizingFailedException
*/
public function downloadCustomImage(
ElementInterface $image,
ImageDownloadConfigParameter $parameters
): BinaryFileResponse;

/**
* @throws InvalidElementTypeException|InvalidAssetFormatTypeException|ThumbnailResizingFailedException
*/
public function downloadImageByFormat(
ElementInterface $image,
string $format
): BinaryFileResponse;

/**
* @throws InvalidElementTypeException
*/
public function downloadImageByThumbnail(
ElementInterface $image,
string $thumbnailName
Expand Down
6 changes: 6 additions & 0 deletions src/Asset/Service/ThumbnailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
{
use ConsoleExecutableTrait;

/**
* @throws ThumbnailResizingFailedException
*/
public function getThumbnailFromConfiguration(
Image $image,
ImageDownloadConfigParameter $parameters
Expand Down Expand Up @@ -133,6 +136,9 @@ private function setThumbnailConfigResizeParameters(
return $thumbnailConfig;
}

/**
* @throws ThumbnailResizingFailedException
*/
private function resizeThumbnailFile(
ThumbnailInterface $thumbnail,
int $dpi
Expand Down
4 changes: 4 additions & 0 deletions src/Asset/Service/ThumbnailServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace Pimcore\Bundle\StudioBackendBundle\Asset\Service;

use Pimcore\Bundle\StudioBackendBundle\Asset\MappedParameter\ImageDownloadConfigParameter;
use Pimcore\Bundle\StudioBackendBundle\Exception\ThumbnailResizingFailedException;
use Pimcore\Model\Asset\Image;
use Pimcore\Model\Asset\Image\ThumbnailInterface;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
Expand All @@ -26,6 +27,9 @@
*/
interface ThumbnailServiceInterface
{
/**
* @throws ThumbnailResizingFailedException
*/
public function getThumbnailFromConfiguration(
Image $image,
ImageDownloadConfigParameter $parameters
Expand Down

0 comments on commit 0b7b614

Please sign in to comment.