Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.x' into 218-reset-password
Browse files Browse the repository at this point in the history
  • Loading branch information
mattamon committed Jun 4, 2024
2 parents 1ebe4ee + 8369c21 commit bb329c3
Show file tree
Hide file tree
Showing 64 changed files with 463 additions and 267 deletions.
4 changes: 2 additions & 2 deletions config/assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ services:
Pimcore\Bundle\StudioBackendBundle\Asset\Service\DataServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Asset\Service\DataService



Pimcore\Bundle\StudioBackendBundle\Asset\Updater\Adapter\ImageAdapter:
tags: [ 'pimcore.studio_backend.update_adapter' ]
36 changes: 36 additions & 0 deletions src/Asset/Attributes/Property/UpdateAssetImage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?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\Asset\Attributes\Property;

use OpenApi\Attributes\Property;
use Pimcore\Bundle\StudioBackendBundle\Asset\Schema\Type\Image\ImageData;

/**
* @internal
*/
final class UpdateAssetImage extends Property
{
public function __construct()
{
parent::__construct(
'image',
ref: ImageData::class,
type: 'object',
nullable: true,
);
}
}
2 changes: 2 additions & 0 deletions src/Asset/Attributes/Request/UpdateAssetRequestBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\Property;
use OpenApi\Attributes\RequestBody;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attributes\Property\UpdateAssetImage;
use Pimcore\Bundle\StudioBackendBundle\Property\Attributes\Property\UpdateElementProperties;

/**
Expand All @@ -37,6 +38,7 @@ public function __construct()
new Property('data',
properties: [
new UpdateElementProperties(),
new UpdateAssetImage(),
],
type: 'object',
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct()
parent::__construct(
properties: [
new Property(
'customSettings',
'items',
ref: CustomSettings::class,
type: 'object'
),
Expand Down
2 changes: 1 addition & 1 deletion src/Asset/Controller/CustomSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ public function __construct(
])]
public function getAssetCustomSettingsById(int $id): JsonResponse
{
return $this->jsonResponse($this->customSettingsService->getCustomSettings($id));
return $this->jsonResponse(['items' => $this->customSettingsService->getCustomSettings($id)]);
}
}
4 changes: 2 additions & 2 deletions src/Asset/Controller/UpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use OpenApi\Attributes\Put;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attributes\Request\UpdateAssetRequestBody;
use Pimcore\Bundle\StudioBackendBundle\Asset\Attributes\Response\Content\OneOfAssetJson;
use Pimcore\Bundle\StudioBackendBundle\Asset\Request\UpdateAsset;
use Pimcore\Bundle\StudioBackendBundle\Asset\MappedParameter\UpdateAssetParameter;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter;
Expand Down Expand Up @@ -67,7 +67,7 @@ public function __construct(
HttpResponseCodes::UNAUTHORIZED,
HttpResponseCodes::NOT_FOUND,
])]
public function updateAsset(int $id, #[MapRequestPayload] UpdateAsset $updateAsset): JsonResponse
public function updateAsset(int $id, #[MapRequestPayload] UpdateAssetParameter $updateAsset): JsonResponse
{
$this->updateService->update('asset', $id, $updateAsset->getData());
return $this->jsonResponse($this->assetService->getAsset($id));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioBackendBundle\Asset\Request;
namespace Pimcore\Bundle\StudioBackendBundle\Asset\MappedParameter;

/**
* @internal
*/
final readonly class UpdateAsset
final readonly class UpdateAssetParameter
{
public function __construct(
private array $data
Expand Down
49 changes: 49 additions & 0 deletions src/Asset/Schema/Type/Image/FocalPoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?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\Asset\Schema\Type\Image;

use OpenApi\Attributes\Property;
use OpenApi\Attributes\Schema;

/**
* @internal
*/
#[Schema(
title: 'FocalPoint',
type: 'object'
)]
final readonly class FocalPoint
{

public function __construct(
#[Property(description: 'x', type: 'integer', example: 50)]
private int $x,
#[Property(description: 'y', type: 'integer', example: 50)]
private int $y,
) {
}

public function getX(): int
{
return $this->x;
}

public function getY(): int
{
return $this->y;
}
}
41 changes: 41 additions & 0 deletions src/Asset/Schema/Type/Image/ImageData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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\Asset\Schema\Type\Image;

use OpenApi\Attributes\Property;
use OpenApi\Attributes\Schema;

/**
* @internal
*/
#[Schema(
title: 'ImageData',
type: 'object'
)]
final readonly class ImageData
{
public function __construct(
#[Property(ref: FocalPoint::class, description: 'focalPoint', type: 'object')]
private array $focalPoint,
) {
}

public function getFocalPoint(): array
{
return $this->focalPoint;
}
}
69 changes: 69 additions & 0 deletions src/Asset/Updater/Adapter/ImageAdapter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?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\Asset\Updater\Adapter;

use Pimcore\Bundle\StudioBackendBundle\Updater\Adapter\UpdateAdapterInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\ElementTypes;
use Pimcore\Model\Asset\Image;
use Pimcore\Model\Element\ElementInterface;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;

/**
* @internal
*/
#[AutoconfigureTag('pimcore.studio_backend.update_adapter')]
final readonly class ImageAdapter implements UpdateAdapterInterface
{
private const INDEX_KEY = 'image';

public function update(ElementInterface $element, array $data): void
{
if (!$element instanceof Image) {
return;
}

$this->checkFocalPoint($element, $data);

}

public function getIndexKey(): string
{
return self::INDEX_KEY;
}

public function supportedElementTypes(): array
{
return [
ElementTypes::TYPE_ASSET,
];
}

private function checkFocalPoint(Image $image, array $data): void
{
if (
!array_key_exists(self::INDEX_KEY, $data) ||
!array_key_exists('focalPoint', $data[self::INDEX_KEY])
) {
$image->removeCustomSetting('focalPointX');
$image->removeCustomSetting('focalPointY');
return;
}

$image->setCustomSetting('focalPointX', $data[self::INDEX_KEY]['focalPoint']['x']);
$image->setCustomSetting('focalPointY', $data[self::INDEX_KEY]['focalPoint']['y']);
}
}
2 changes: 1 addition & 1 deletion src/DataIndex/Filter/DataObject/ClassNameFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Query\DataObjectQuery;
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Query\QueryInterface;
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Request\DataObjectParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\Request\CollectionParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\CollectionParametersInterface;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/DataIndex/Filter/ExcludeFolderFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use Pimcore\Bundle\StudioBackendBundle\DataIndex\Query\QueryInterface;
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Request\ElementParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\Request\CollectionParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\CollectionParametersInterface;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/DataIndex/Filter/FilterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace Pimcore\Bundle\StudioBackendBundle\DataIndex\Filter;

use Pimcore\Bundle\StudioBackendBundle\DataIndex\Query\QueryInterface;
use Pimcore\Bundle\StudioBackendBundle\Request\CollectionParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\CollectionParametersInterface;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/DataIndex/Filter/IdSearchFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use Pimcore\Bundle\StudioBackendBundle\DataIndex\Query\QueryInterface;
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Request\ElementParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\Request\CollectionParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\CollectionParametersInterface;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/DataIndex/Filter/PageFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace Pimcore\Bundle\StudioBackendBundle\DataIndex\Filter;

use Pimcore\Bundle\StudioBackendBundle\DataIndex\Query\QueryInterface;
use Pimcore\Bundle\StudioBackendBundle\Request\CollectionParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\CollectionParametersInterface;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/DataIndex/Filter/PageSizeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace Pimcore\Bundle\StudioBackendBundle\DataIndex\Filter;

use Pimcore\Bundle\StudioBackendBundle\DataIndex\Query\QueryInterface;
use Pimcore\Bundle\StudioBackendBundle\Request\CollectionParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\CollectionParametersInterface;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/DataIndex/Filter/ParentIdFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use Pimcore\Bundle\StudioBackendBundle\DataIndex\Query\QueryInterface;
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Request\ElementParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\Request\CollectionParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\CollectionParametersInterface;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/DataIndex/Filter/PathFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use Pimcore\Bundle\StudioBackendBundle\DataIndex\Query\QueryInterface;
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Request\ElementParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\Request\CollectionParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\CollectionParametersInterface;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/DataIndex/OpenSearchFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidQueryTypeException;
use Pimcore\Bundle\StudioBackendBundle\Factory\QueryFactoryInterface;
use Pimcore\Bundle\StudioBackendBundle\Filter\Service\FilterServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Request\CollectionParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\CollectionParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\ElementTypes;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/DataIndex/OpenSearchFilterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Query\QueryInterface;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidFilterTypeException;
use Pimcore\Bundle\StudioBackendBundle\Exception\InvalidQueryTypeException;
use Pimcore\Bundle\StudioBackendBundle\Request\CollectionParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\CollectionParametersInterface;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/DataIndex/Request/ElementParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace Pimcore\Bundle\StudioBackendBundle\DataIndex\Request;

use Pimcore\Bundle\StudioBackendBundle\Request\CollectionParameters;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\CollectionParameters;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion src/DataIndex/Request/ElementParametersInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace Pimcore\Bundle\StudioBackendBundle\DataIndex\Request;

use Pimcore\Bundle\StudioBackendBundle\Request\CollectionParametersInterface;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\CollectionParametersInterface;

/**
* @internal
Expand Down
Loading

0 comments on commit bb329c3

Please sign in to comment.