|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright since 2007 PrestaShop SA and Contributors |
| 4 | + * PrestaShop is an International Registered Trademark & Property of PrestaShop SA |
| 5 | + * |
| 6 | + * NOTICE OF LICENSE |
| 7 | + * |
| 8 | + * This source file is subject to the Academic Free License version 3.0 |
| 9 | + * that is bundled with this package in the file LICENSE.md. |
| 10 | + * It is also available through the world-wide-web at this URL: |
| 11 | + * https://opensource.org/licenses/AFL-3.0 |
| 12 | + * If you did not receive a copy of the license and are unable to |
| 13 | + * obtain it through the world-wide-web, please send an email |
| 14 | + * to license@prestashop.com so we can send you a copy immediately. |
| 15 | + * |
| 16 | + * @author PrestaShop SA and Contributors <contact@prestashop.com> |
| 17 | + * @copyright Since 2007 PrestaShop SA and Contributors |
| 18 | + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 |
| 19 | + */ |
| 20 | + |
| 21 | +declare(strict_types=1); |
| 22 | + |
| 23 | +namespace PrestaShop\Module\APIResources\ApiPlatform\Resources\ImageSettings; |
| 24 | + |
| 25 | +use ApiPlatform\Metadata\ApiProperty; |
| 26 | +use ApiPlatform\Metadata\ApiResource; |
| 27 | +use PrestaShop\PrestaShop\Core\Domain\ImageSettings\Command\EditImageSettingsCommand; |
| 28 | +use PrestaShop\PrestaShop\Core\Domain\ImageSettings\Exception\ImageTypeException; |
| 29 | +use PrestaShop\PrestaShop\Core\Domain\ImageSettings\Query\GetImageSettingsForEditing; |
| 30 | +use PrestaShopBundle\ApiPlatform\Metadata\CQRSGet; |
| 31 | +use PrestaShopBundle\ApiPlatform\Metadata\CQRSUpdate; |
| 32 | +use Symfony\Component\HttpFoundation\Response; |
| 33 | + |
| 34 | +#[ApiResource( |
| 35 | + operations: [ |
| 36 | + new CQRSGet( |
| 37 | + uriTemplate: '/image-settings', |
| 38 | + openapiContext: ['summary' => 'Get image settings', 'description' => 'Retrieves current image settings configuration'], |
| 39 | + CQRSQuery: GetImageSettingsForEditing::class, |
| 40 | + scopes: [ |
| 41 | + 'image_settings_read', |
| 42 | + ], |
| 43 | + ), |
| 44 | + new CQRSUpdate( |
| 45 | + uriTemplate: '/image-settings', |
| 46 | + openapiContext: ['summary' => 'Edit image settings', 'description' => 'Updates image settings configuration'], |
| 47 | + CQRSCommand: EditImageSettingsCommand::class, |
| 48 | + CQRSQuery: GetImageSettingsForEditing::class, |
| 49 | + scopes: [ |
| 50 | + 'image_settings_write', |
| 51 | + ], |
| 52 | + ), |
| 53 | + ], |
| 54 | + exceptionToStatus: [ |
| 55 | + ImageTypeException::class => Response::HTTP_UNPROCESSABLE_ENTITY, |
| 56 | + ], |
| 57 | +)] |
| 58 | +class ImageSettings |
| 59 | +{ |
| 60 | + #[ApiProperty(openapiContext: ['type' => 'array', 'items' => ['type' => 'string'], 'example' => ['jpg', 'webp', 'avif']])] |
| 61 | + public array $formats; |
| 62 | + |
| 63 | + public string $baseFormat; |
| 64 | + |
| 65 | + public int $avifQuality; |
| 66 | + |
| 67 | + public int $jpegQuality; |
| 68 | + |
| 69 | + public int $pngQuality; |
| 70 | + |
| 71 | + public int $webpQuality; |
| 72 | + |
| 73 | + public int $generationMethod; |
| 74 | + |
| 75 | + public int $pictureMaxSize; |
| 76 | + |
| 77 | + public int $pictureMaxWidth; |
| 78 | + |
| 79 | + public int $pictureMaxHeight; |
| 80 | +} |
0 commit comments