Skip to content
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
3 changes: 3 additions & 0 deletions config/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ services:
Pimcore\Bundle\StudioBackendBundle\Setting\Service\ElementServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Setting\Service\ElementService

Pimcore\Bundle\StudioBackendBundle\Setting\Service\ThumbnailServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Setting\Service\ThumbnailService

#
# Hydrators
#
Expand Down
59 changes: 59 additions & 0 deletions src/Setting/Controller/ImageAdapterController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\StudioBackendBundle\Setting\Controller;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
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\Setting\Service\ThumbnailServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Serializer\SerializerInterface;

/**
* @internal
*/
final class ImageAdapterController extends AbstractApiController
{
private const string ROUTE = '/settings/adapter/image';

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

#[Route(path: self::ROUTE, name: 'pimcore_studio_api_settings_image_adapter', methods: ['GET'])]
#[Get(
path: self::PREFIX . self::ROUTE,
operationId: 'settings_image_adapter_check',
description: 'settings_image_adapter_check_description',
summary: 'settings_image_adapter_check_summary',
tags: [Tags::Settings->value]
)]
#[SuccessResponse(
description: 'settings_image_adapter_check_success_response'
)]
#[DefaultResponses([
HttpResponseCodes::UNAUTHORIZED,
])]
public function checkImageAdapter(): JsonResponse
{
return $this->jsonResponse($this->thumbnailService->isImageAdapterValid());
}
}
63 changes: 63 additions & 0 deletions src/Setting/Controller/VideoAdapterController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\StudioBackendBundle\Setting\Controller;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
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\Setting\Service\ThumbnailServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Serializer\SerializerInterface;

/**
* @internal
*/
final class VideoAdapterController extends AbstractApiController
{
private const string ROUTE = '/settings/adapter/video';

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

#[Route(
path: self::ROUTE,
name: 'pimcore_studio_api_settings_video_adapter',
methods: ['GET']
)]
#[Get(
path: self::ROUTE,
operationId: 'settings_video_adapter_check',
description: 'settings_video_adapter_check_description',
summary: 'settings_video_adapter_check_summary',
tags: [Tags::Settings->value]
)]
#[SuccessResponse(
description: 'settings_video_adapter_check_success_response'
)]
#[DefaultResponses([
HttpResponseCodes::UNAUTHORIZED,
])]
public function checkVideoAdapter(): JsonResponse
{
return $this->jsonResponse($this->thumbnailService->isVideoAdapterValid());
}
}
40 changes: 40 additions & 0 deletions src/Setting/Service/ThumbnailService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\StudioBackendBundle\Setting\Service;

use Pimcore\Bundle\StaticResolverBundle\Lib\VideoResolverInterface;
use Pimcore\Image\Adapter\GD;
use Pimcore\Image\AdapterInterface;

/**
* @internal
*/
final readonly class ThumbnailService implements ThumbnailServiceInterface
{
public function __construct(
private AdapterInterface $imageAdapter,
private VideoResolverInterface $videoResolver
) {
}

public function isImageAdapterValid(): bool
{
return !$this->imageAdapter instanceof GD;
}

public function isVideoAdapterValid(): bool
{
return $this->videoResolver->isAvailable();
}
}
29 changes: 29 additions & 0 deletions src/Setting/Service/ThumbnailServiceInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\StudioBackendBundle\Setting\Service;

interface ThumbnailServiceInterface
{
/**
* Returns true if the image adapter is valid (Imagick).
* Returns false if using GD (fallback with less quality).
*/
public function isImageAdapterValid(): bool;

/**
* Returns true if video processing is available (FFmpeg configured).
* Returns false if video processing is not configured.
*/
public function isVideoAdapterValid(): bool;
}
12 changes: 12 additions & 0 deletions translations/studio_api_docs.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,18 @@ settings_country_collection_description: |
Returns a list of countries with their codes and names
settings_country_collection_summary: Get all available countries
settings_country_collection_success_response: List of available countries
settings_image_adapter_check_description: |
Check what image adapter is used. <br>
Returns <strong>true</strong> if Imagick extension is used for image processing. <br>
Returns <strong>false</strong> if the GD library fallback is used, which provides lower quality image processing.
settings_image_adapter_check_summary: Check image adapter
settings_image_adapter_check_success_response: Image adapter availability
settings_video_adapter_check_description: |
Check if the video adapter is valid. <br>
Returns <strong>true</strong> if FFmpeg is properly configured for video processing. <br>
Returns <strong>false</strong> if video processing is not available due to missing PHP CLI binary or FFmpeg binary configuration.
settings_video_adapter_check_summary: Check video adapter validity
settings_video_adapter_check_success_response: Video adapter validity status
simple_search_preview_get_description: |
Returns search preview for elements based on the given type <strong>{elementType}</strong> and <strong>{id}</strong>. <br>
The <strong>{id}</strong> must be an ID of an existing element of the provided <strong>{elementType}</strong>.
Expand Down
Loading