Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[User Management] Endpoint to get User Image #569

Merged
merged 6 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ services:
Pimcore\Bundle\StudioBackendBundle\User\Service\KeyBindingServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\User\Service\KeyBindingService

Pimcore\Bundle\StudioBackendBundle\User\Service\ImageUploadServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\User\Service\ImageUploadService
Pimcore\Bundle\StudioBackendBundle\User\Service\ImageServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\User\Service\ImageService



Expand Down
4 changes: 2 additions & 2 deletions src/Asset/Controller/Document/PreviewStreamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace Pimcore\Bundle\StudioBackendBundle\Asset\Controller\Document;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Content\AssetMediaType;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Header\ContentDisposition;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\DocumentServiceInterface;
Expand All @@ -29,6 +28,7 @@
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\InvalidElementTypeException;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\UnprocessableContentException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\MediaType;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
Expand Down Expand Up @@ -82,7 +82,7 @@ public function __construct(
#[IdParameter(type: 'document')]
#[SuccessResponse(
description: 'asset_document_stream_preview_success_response',
content: new AssetMediaType('application/pdf'),
content: new MediaType('application/pdf'),
headers: [new ContentDisposition('inline')]
)]
#[DefaultResponses([
Expand Down
4 changes: 2 additions & 2 deletions src/Asset/Controller/Download/DownloadCsvController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace Pimcore\Bundle\StudioBackendBundle\Asset\Controller\Download;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Content\AssetMediaType;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Header\ContentDisposition;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\DownloadServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\ExecutionEngine\CsvServiceInterface;
Expand All @@ -27,6 +26,7 @@
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\StreamResourceNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\MediaType;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
Expand Down Expand Up @@ -65,7 +65,7 @@ public function __construct(
#[IdParameter(type: 'JobRun', name: 'jobRunId')]
#[SuccessResponse(
description: 'asset_download_csv_success_response',
content: [new AssetMediaType('application/csv')],
content: [new MediaType('application/csv')],
headers: [new ContentDisposition()]
)]
#[DefaultResponses([
Expand Down
4 changes: 2 additions & 2 deletions src/Asset/Controller/Download/DownloadZipController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace Pimcore\Bundle\StudioBackendBundle\Asset\Controller\Download;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Content\AssetMediaType;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Header\ContentDisposition;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\DownloadServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\ExecutionEngine\ZipServiceInterface;
Expand All @@ -27,6 +26,7 @@
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\StreamResourceNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\MediaType;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
Expand Down Expand Up @@ -65,7 +65,7 @@ public function __construct(
#[IdParameter(type: 'JobRun', name: 'jobRunId')]
#[SuccessResponse(
description: 'asset_download_zip_success_response',
content: [new AssetMediaType('application/zip')],
content: [new MediaType('application/zip')],
headers: [new ContentDisposition()]
)]
#[DefaultResponses([
Expand Down
4 changes: 2 additions & 2 deletions src/Asset/Controller/DownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace Pimcore\Bundle\StudioBackendBundle\Asset\Controller;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Content\AssetMediaType;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Header\ContentDisposition;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\DownloadServiceInterface;
Expand All @@ -28,6 +27,7 @@
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\UserNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\MediaType;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
Expand Down Expand Up @@ -73,7 +73,7 @@ public function __construct(
#[IdParameter(type: ElementTypes::TYPE_ASSET)]
#[SuccessResponse(
description: 'asset_download_by_id_success_response',
content: new AssetMediaType(),
content: new MediaType(),
headers: [new ContentDisposition()]
)]
#[DefaultResponses([
Expand Down
4 changes: 2 additions & 2 deletions src/Asset/Controller/Image/CustomDownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace Pimcore\Bundle\StudioBackendBundle\Asset\Controller\Image;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Content\AssetMediaType;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Header\ContentDisposition;
use Pimcore\Bundle\StudioBackendBundle\Asset\MappedParameter\ImageDownloadConfigParameter;
use Pimcore\Bundle\StudioBackendBundle\Asset\OpenApi\Attribute\Parameter\Query\ImageConfigParameter;
Expand All @@ -32,6 +31,7 @@
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\ThumbnailResizingFailedException;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\UserNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\MediaType;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
Expand Down Expand Up @@ -87,7 +87,7 @@ public function __construct(
#[ImageConfigParameter('dpi')]
#[SuccessResponse(
description: 'asset_image_download_custom_success_response',
content: [new AssetMediaType('image/jpeg'), new AssetMediaType('image/png')],
content: [new MediaType('image/jpeg'), new MediaType('image/png')],
headers: [new ContentDisposition()]
)]
#[DefaultResponses([
Expand Down
4 changes: 2 additions & 2 deletions src/Asset/Controller/Image/FormatDownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace Pimcore\Bundle\StudioBackendBundle\Asset\Controller\Image;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Content\AssetMediaType;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Header\ContentDisposition;
use Pimcore\Bundle\StudioBackendBundle\Asset\OpenApi\Attribute\Parameter\Path\FormatTypeParameter;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetServiceInterface;
Expand All @@ -30,6 +29,7 @@
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\ThumbnailResizingFailedException;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\UserNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\MediaType;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
Expand Down Expand Up @@ -82,7 +82,7 @@ public function __construct(
#[FormatTypeParameter]
#[SuccessResponse(
description: 'asset_image_download_by_format_success_response',
content: new AssetMediaType('image/jpeg'),
content: new MediaType('image/jpeg'),
headers: [new ContentDisposition()]
)]
#[DefaultResponses([
Expand Down
4 changes: 2 additions & 2 deletions src/Asset/Controller/Image/PreviewStreamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace Pimcore\Bundle\StudioBackendBundle\Asset\Controller\Image;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Content\AssetMediaType;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Header\ContentDisposition;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\BinaryServiceInterface;
Expand All @@ -28,6 +27,7 @@
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\UserNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\MediaType;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
Expand Down Expand Up @@ -77,7 +77,7 @@ public function __construct(
#[IdParameter(type: 'image')]
#[SuccessResponse(
description: 'asset_image_stream_preview_success_response',
content: [new AssetMediaType('image/*')],
content: [new MediaType('image/*')],
headers: [new ContentDisposition(HttpResponseHeaders::INLINE_TYPE->value)]
)]
#[DefaultResponses([
Expand Down
4 changes: 2 additions & 2 deletions src/Asset/Controller/Image/ThumbnailDownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace Pimcore\Bundle\StudioBackendBundle\Asset\Controller\Image;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Content\AssetMediaType;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Header\ContentDisposition;
use Pimcore\Bundle\StudioBackendBundle\Asset\OpenApi\Attribute\Parameter\Path\ThumbnailNameParameter;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetServiceInterface;
Expand All @@ -29,6 +28,7 @@
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\SearchException;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\UserNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\MediaType;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
Expand Down Expand Up @@ -78,7 +78,7 @@ public function __construct(
#[ThumbnailNameParameter]
#[SuccessResponse(
description: 'asset_image_download_by_thumbnail_success_response',
content: new AssetMediaType(),
content: new MediaType(),
headers: [new ContentDisposition()]
)]
#[DefaultResponses([
Expand Down
4 changes: 2 additions & 2 deletions src/Asset/Controller/Video/ImageThumbnailStreamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace Pimcore\Bundle\StudioBackendBundle\Asset\Controller\Video;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Content\AssetMediaType;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Header\ContentDisposition;
use Pimcore\Bundle\StudioBackendBundle\Asset\MappedParameter\VideoImageStreamConfigParameter;
use Pimcore\Bundle\StudioBackendBundle\Asset\OpenApi\Attribute\Parameter\Query\AspectRatioParameter;
Expand All @@ -35,6 +34,7 @@
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\InvalidThumbnailException;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\UserNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\MediaType;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
Expand Down Expand Up @@ -91,7 +91,7 @@ public function __construct(
#[AsyncGenerationParameter]
#[SuccessResponse(
description: 'asset_video_image_thumbnail_stream_success_response',
content: [new AssetMediaType('image/*')],
content: [new MediaType('image/*')],
headers: [new ContentDisposition(HttpResponseHeaders::INLINE_TYPE->value)]
)]
#[DefaultResponses([
Expand Down
4 changes: 2 additions & 2 deletions src/Asset/Controller/Video/ThumbnailDownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

use League\Flysystem\FilesystemException;
use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Content\AssetMediaType;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Header\ContentDisposition;
use Pimcore\Bundle\StudioBackendBundle\Asset\OpenApi\Attribute\Parameter\Path\ThumbnailNameParameter;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetServiceInterface;
Expand All @@ -31,6 +30,7 @@
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\UserNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\MediaType;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
Expand Down Expand Up @@ -82,7 +82,7 @@ public function __construct(
#[ThumbnailNameParameter]
#[SuccessResponse(
description: 'asset_video_download_by_thumbnail_success_response',
content: new AssetMediaType('video/mp4'),
content: new MediaType('video/mp4'),
headers: [new ContentDisposition()]
)]
#[DefaultResponses([
Expand Down
4 changes: 2 additions & 2 deletions src/Asset/Controller/Video/ThumbnailStreamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

use League\Flysystem\FilesystemException;
use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Content\AssetMediaType;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Header\ContentDisposition;
use Pimcore\Bundle\StudioBackendBundle\Asset\OpenApi\Attribute\Parameter\Path\ThumbnailNameParameter;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetServiceInterface;
Expand All @@ -31,6 +30,7 @@
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\UserNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\MediaType;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
Expand Down Expand Up @@ -82,7 +82,7 @@ public function __construct(
#[ThumbnailNameParameter]
#[SuccessResponse(
description: 'asset_video_stream_by_thumbnail_success_response',
content: new AssetMediaType('video/mp4'),
content: new MediaType('video/mp4'),
headers: [new ContentDisposition('inline')]
)]
#[DefaultResponses([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Response\Content;
namespace Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content;

use OpenApi\Attributes\MediaType;
use OpenApi\Attributes\MediaType as OpenApiMediaType;
use OpenApi\Attributes\Schema;

/**
* @internal
*/
final class AssetMediaType extends MediaType
final class MediaType extends OpenApiMediaType
{
public function __construct(string $mimeType = 'application/*')
{
Expand Down
4 changes: 2 additions & 2 deletions src/User/Controller/UploadUserImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\User\Service\ImageUploadServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\User\Service\ImageServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions;
use Pimcore\Bundle\StudioBackendBundle\Util\Trait\PaginatedResponseTrait;
Expand All @@ -49,7 +49,7 @@ final class UploadUserImageController extends AbstractApiController

public function __construct(
SerializerInterface $serializer,
private readonly ImageUploadServiceInterface $imageUploadService
private readonly ImageServiceInterface $imageUploadService
) {
parent::__construct($serializer);
}
Expand Down
74 changes: 74 additions & 0 deletions src/User/Controller/UserImageController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
declare(strict_types=1);

/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioBackendBundle\User\Controller;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\MediaType;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\User\Service\ImageServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions;
use Pimcore\Bundle\StudioBackendBundle\Util\Trait\PaginatedResponseTrait;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
* @internal
*/
final class UserImageController extends AbstractApiController
{
use PaginatedResponseTrait;

public function __construct(
SerializerInterface $serializer,
private readonly ImageServiceInterface $imageUploadService
) {
parent::__construct($serializer);
}

/**
* @throws NotFoundException
*/
#[Route('/user/image/{id}', name: 'pimcore_studio_api_get_user_image', methods: ['GET'])]
#[IsGranted(UserPermissions::USER_MANAGEMENT->value)]
#[Get(
path: self::PREFIX . '/user/image/{id}',
operationId: 'user_get_image',
summary: 'user_get_image_summary',
tags: [Tags::User->value]
)]
#[IdParameter(type: 'User')]
#[SuccessResponse(
description: 'user_get_image_success_response',
content: new MediaType('image/png'),
)]
#[DefaultResponses([
HttpResponseCodes::NOT_FOUND,
])]
public function getUserImage(
int $id,
): StreamedResponse {
return $this->imageUploadService->getImageFromUserAsStreamedResponse($id);
}
}
Loading
Loading