-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
299 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/OpenApi/Attributes/Request/ElementPropertyRequestBody.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?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\OpenApi\Attributes\Request; | ||
|
||
use Attribute; | ||
use OpenApi\Attributes\Items; | ||
use OpenApi\Attributes\JsonContent; | ||
use OpenApi\Attributes\RequestBody; | ||
use Pimcore\Bundle\StudioBackendBundle\Property\Schema\UpdateElementProperty; | ||
|
||
#[Attribute(Attribute::TARGET_METHOD)] | ||
final class ElementPropertyRequestBody extends RequestBody | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct( | ||
required: true, | ||
content: new JsonContent( | ||
type: 'array', | ||
items: new Items(ref: UpdateElementProperty::class) | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?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\Property\Controller\Element; | ||
|
||
use OpenApi\Attributes\Put; | ||
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\ElementTypeParameter; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Request\ElementPropertyRequestBody; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Content\ItemsJson; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\MethodNotAllowedResponse; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\NotFoundResponse; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnauthorizedResponse; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnprocessableContentResponse; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Error\UnsupportedMediaTypeResponse; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; | ||
use Pimcore\Bundle\StudioBackendBundle\Property\Request\UpdateElementProperties; | ||
use Pimcore\Bundle\StudioBackendBundle\Property\Schema\ElementProperty; | ||
use Pimcore\Bundle\StudioBackendBundle\Property\Service\PropertyHydratorServiceInterface; | ||
use Pimcore\Bundle\StudioBackendBundle\Property\Service\PropertyServiceInterface; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
use Symfony\Component\Serializer\SerializerInterface; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class PutController extends AbstractApiController | ||
Check notice on line 44 in src/Property/Controller/Element/PutController.php GitHub Actions / Qodana for PHPEfferent coupling between objects
|
||
{ | ||
public function __construct( | ||
SerializerInterface $serializer, | ||
private readonly PropertyServiceInterface $propertyService, | ||
private readonly PropertyHydratorServiceInterface $hydratorService, | ||
) { | ||
parent::__construct($serializer); | ||
} | ||
|
||
#[Route('/properties/{elementType}/{id}', name: 'pimcore_studio_api_update_element_properties', methods: ['PUT'])] | ||
//#[IsGranted('STUDIO_API')] | ||
#[Put( | ||
path: self::API_PATH . '/properties/{elementType}/{id}', | ||
operationId: 'updatePropertiesForElementByTypeAndId', | ||
summary: 'Update properties for an element based on the element type and the element id', | ||
security: self::SECURITY_SCHEME, | ||
tags: [Tags::PropertiesForElement->value] | ||
)] | ||
#[ElementTypeParameter] | ||
#[IdParameter(type: 'element')] | ||
#[ElementPropertyRequestBody] | ||
#[SuccessResponse( | ||
description: 'Element Properties data as json', | ||
content: new ItemsJson(ElementProperty::class) | ||
)] | ||
#[UnauthorizedResponse] | ||
#[NotFoundResponse] | ||
#[MethodNotAllowedResponse] | ||
#[UnsupportedMediaTypeResponse] | ||
#[UnprocessableContentResponse] | ||
public function updateProperties( | ||
string $elementType, | ||
int $id, | ||
#[MapRequestPayload] UpdateElementProperties $items | ||
): JsonResponse | ||
{ | ||
$this->propertyService->updateElementProperties($elementType, $id, $items); | ||
return $this->jsonResponse($this->hydratorService->getHydratedPropertyForElement($elementType, $id)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?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\Property\Request; | ||
|
||
|
||
use Pimcore\Bundle\StudioBackendBundle\Property\Schema\UpdateElementProperty; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final readonly class UpdateElementProperties | ||
{ | ||
private array $properties; | ||
public function __construct( | ||
array $items | ||
) { | ||
$this->properties = array_map(static function(array $propertyData) { | ||
return new UpdateElementProperty( | ||
$propertyData['key'], | ||
$propertyData['data'], | ||
$propertyData['type'], | ||
$propertyData['inheritable'], | ||
); | ||
}, $items); | ||
} | ||
|
||
public function getProperties(): array | ||
{ | ||
return $this->properties; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.