-
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.
[Task] Add batch edit based on folder ids (#496)
* Add batch edit for folders * Apply php-cs-fixer changes * Split lines * Add translations and refactor to use gridsearch and filters * Apply php-cs-fixer changes * Add type infos --------- Co-authored-by: mattamon <[email protected]>
- Loading branch information
Showing
28 changed files
with
843 additions
and
4 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
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
73 changes: 73 additions & 0 deletions
73
src/Asset/Attribute/Request/PatchAssetFolderRequestBody.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,73 @@ | ||
<?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\Attribute\Request; | ||
|
||
use Attribute; | ||
use OpenApi\Attributes\Items; | ||
use OpenApi\Attributes\JsonContent; | ||
use OpenApi\Attributes\Property; | ||
use OpenApi\Attributes\RequestBody; | ||
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Property\CustomMetadata; | ||
use Pimcore\Bundle\StudioBackendBundle\Asset\Schema\PatchCustomMetadata; | ||
use Pimcore\Bundle\StudioBackendBundle\Grid\Schema\Filter; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Property\UpdateIntegerProperty; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Property\UpdateStringProperty; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
#[Attribute(Attribute::TARGET_METHOD)] | ||
final class PatchAssetFolderRequestBody extends RequestBody | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct( | ||
required: true, | ||
content: new JsonContent( | ||
required: ['data'], | ||
properties: [ | ||
new Property( | ||
property: 'data', | ||
type: 'array', | ||
items: new Items( | ||
required: ['folderId'], | ||
properties: [ | ||
new Property( | ||
property: 'folderId', | ||
description: 'Folder ID', | ||
type: 'integer', | ||
example: 83 | ||
), | ||
new UpdateIntegerProperty('parentId'), | ||
new UpdateStringProperty('key'), | ||
new UpdateStringProperty('locked'), | ||
new CustomMetadata(PatchCustomMetadata::class), | ||
], | ||
type: 'object', | ||
), | ||
), | ||
new Property( | ||
property: 'filters', | ||
ref: Filter::class, | ||
type: 'object' | ||
), | ||
], | ||
type: 'object', | ||
), | ||
); | ||
} | ||
} |
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,89 @@ | ||
<?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\Controller; | ||
|
||
use OpenApi\Attributes\Patch; | ||
use Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Request\PatchAssetFolderRequestBody; | ||
use Pimcore\Bundle\StudioBackendBundle\Asset\MappedParameter\PatchFolderParameter; | ||
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; | ||
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\AccessDeniedException; | ||
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\ElementSavingFailedException; | ||
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\InvalidArgumentException; | ||
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException; | ||
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\UserNotFoundException; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\IdJson; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\CreatedResponse; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; | ||
use Pimcore\Bundle\StudioBackendBundle\Patcher\Service\PatchServiceInterface; | ||
use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityServiceInterface; | ||
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\ElementTypes; | ||
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes; | ||
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
use Symfony\Component\Security\Http\Attribute\IsGranted; | ||
use Symfony\Component\Serializer\SerializerInterface; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class PatchFolderController extends AbstractApiController | ||
{ | ||
public function __construct( | ||
SerializerInterface $serializer, | ||
private readonly PatchServiceInterface $patchService, | ||
private readonly SecurityServiceInterface $securityService | ||
) { | ||
parent::__construct($serializer); | ||
} | ||
|
||
/** | ||
* @throws AccessDeniedException|ElementSavingFailedException | ||
* @throws NotFoundException|UserNotFoundException|InvalidArgumentException | ||
*/ | ||
#[Route('/assets/folder', name: 'pimcore_studio_api_patch_asset_folder', methods: ['PATCH'])] | ||
#[IsGranted(UserPermissions::ASSETS->value)] | ||
#[Patch( | ||
path: self::PREFIX . '/assets/folder', | ||
operationId: 'asset_patch_folder_by_id', | ||
description: 'asset_patch_folder_by_id_description', | ||
summary: 'asset_patch_folder_by_id_summary', | ||
tags: [Tags::Assets->name] | ||
)] | ||
#[PatchAssetFolderRequestBody] | ||
#[CreatedResponse( | ||
description: 'asset_patch_by_id_created_response', | ||
content: new IdJson('ID of created jobRun', 'jobRunId') | ||
)] | ||
#[DefaultResponses([ | ||
HttpResponseCodes::UNAUTHORIZED, | ||
HttpResponseCodes::NOT_FOUND, | ||
])] | ||
public function assetPatchFolderById(#[MapRequestPayload] PatchFolderParameter $patchFolderParameter): Response | ||
{ | ||
|
||
$jobRunId = $this->patchService->patchFolder( | ||
ElementTypes::TYPE_ASSET, | ||
$patchFolderParameter, | ||
$this->securityService->getCurrentUser() | ||
); | ||
|
||
return $this->jsonResponse(['jobRunId' => $jobRunId], HttpResponseCodes::CREATED->value); | ||
} | ||
} |
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,42 @@ | ||
<?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\MappedParameter; | ||
|
||
use Pimcore\Bundle\StudioBackendBundle\Filter\MappedParameter\FilterParameter; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final readonly class PatchFolderParameter extends PatchAssetParameter | ||
{ | ||
public function __construct( | ||
private array $data, | ||
private ?FilterParameter $filters, | ||
) { | ||
parent::__construct($data); | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return $this->data; | ||
} | ||
|
||
public function getFilters(): FilterParameter | ||
{ | ||
return $this->filters ?? new FilterParameter(); | ||
} | ||
} |
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
Oops, something went wrong.