Skip to content

Commit

Permalink
Remove body param from batch requests, unify MappedParams
Browse files Browse the repository at this point in the history
  • Loading branch information
alexz707 committed Jun 4, 2024
1 parent c50f4d7 commit a5b0bcd
Show file tree
Hide file tree
Showing 22 changed files with 52 additions and 151 deletions.
6 changes: 3 additions & 3 deletions src/OpenApi/Attributes/Parameters/Path/IdParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
use OpenApi\Attributes\PathParameter;
use OpenApi\Attributes\Schema;

#[Attribute(Attribute::TARGET_METHOD)]
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
final class IdParameter extends PathParameter
{
public function __construct(string $type = 'element', Schema $schema = new Schema(type: 'integer', example: 83))
public function __construct(string $type = 'element', string $name = 'id', Schema $schema = new Schema(type: 'integer', example: 83))
{
parent::__construct(
name: 'id',
name: $name,
description: 'ID of the ' . $type,
in: 'path',
required: true,
Expand Down
2 changes: 1 addition & 1 deletion src/Tag/Attributes/Request/CreateTagRequestBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Attribute;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\RequestBody;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\CreateTagParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\CreateTagParameters;

#[Attribute(Attribute::TARGET_METHOD)]
final class CreateTagRequestBody extends RequestBody
Expand Down
34 changes: 0 additions & 34 deletions src/Tag/Attributes/Request/ElementTagRequestBody.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Tag/Attributes/Request/UpdateTagRequestBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Attribute;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\RequestBody;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\UpdateTagParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\UpdateTagParameters;

#[Attribute(Attribute::TARGET_METHOD)]
final class UpdateTagRequestBody extends RequestBody
Expand Down
2 changes: 1 addition & 1 deletion src/Tag/Controller/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
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\Tag\Request\TagsParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\TagsParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Schema\Tag;
use Pimcore\Bundle\StudioBackendBundle\Tag\Service\TagServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\UserPermissions;
Expand Down
2 changes: 1 addition & 1 deletion src/Tag/Controller/CreateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Tag\Attributes\Request\CreateTagRequestBody;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\CreateTagParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\CreateTagParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Schema\Tag;
use Pimcore\Bundle\StudioBackendBundle\Tag\Service\TagServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\UserPermissions;
Expand Down
17 changes: 6 additions & 11 deletions src/Tag/Controller/Element/AssignController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,11 @@
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Tag\Attributes\Request\ElementTagRequestBody;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\ElementParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Schema\TagId;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\ElementParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Service\TagServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\UserPermissions;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
Expand All @@ -52,28 +47,28 @@ public function __construct(
/**
* @throws ElementSavingFailedException|ElementNotFoundException
*/
#[Route('/tags/{elementType}/{id}', name: 'pimcore_studio_api_assign_element_tag', methods: ['POST'])]
#[Route('/tags/{elementType}/{id}/{tagId}', name: 'pimcore_studio_api_assign_element_tag', methods: ['POST'])]
//#[IsGranted(UserPermissions::TAGS_ASSIGNMENT->value)]
#[Post(
path: self::API_PATH . '/tags/{elementType}/{id}',
path: self::API_PATH . '/tags/{elementType}/{id}/{tagId}',
operationId: 'assignTagForElement',
summary: 'Assign tag for element',
security: self::SECURITY_SCHEME,
tags: [Tags::TagsForElement->value]
)]
#[ElementTypeParameter]
#[IdParameter(type: 'element')]
#[ElementTagRequestBody]
#[IdParameter(type: 'tag', name: 'tagId')]
#[DefaultResponses([
HttpResponseCodes::UNAUTHORIZED
])]
public function assignTag(
string $elementType,
int $id,
#[MapRequestPayload] TagId $assignTag
int $tagId
): JsonResponse
{
$this->tagService->assignTagToElement(new ElementParameters($elementType, $id), $assignTag->getTagId());
$this->tagService->assignTagToElement(new ElementParameters($elementType, $id), $tagId);
return $this->jsonResponse(['id' => $id]);
}
}
4 changes: 1 addition & 3 deletions src/Tag/Controller/Element/BatchAssignController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Tag\Attributes\Request\ElementsTagsCollectionRequestBody;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\BatchCollectionParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\BatchCollectionParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Schema\ElementTagIdCollection;
use Pimcore\Bundle\StudioBackendBundle\Tag\Service\TagServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\UserPermissions;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Tag/Controller/Element/BatchReplaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Tag\Attributes\Request\ElementsTagsCollectionRequestBody;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\BatchCollectionParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\BatchCollectionParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Schema\ElementTagIdCollection;
use Pimcore\Bundle\StudioBackendBundle\Tag\Service\TagServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\UserPermissions;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
Expand Down
11 changes: 2 additions & 9 deletions src/Tag/Controller/Element/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,19 @@
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\Parameters\Query\FieldFilterParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\FilterParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\PageParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\PageSizeParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Query\SortOrderParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Content\CollectionJson;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Tag\Attributes\Response\Property\TagCollection;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\ElementParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\TagsParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\ElementParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\TagsParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Service\TagServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\UserPermissions;
use Pimcore\Bundle\StudioBackendBundle\Util\Traits\PaginatedResponseTrait;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;
use function count;

Expand Down
17 changes: 6 additions & 11 deletions src/Tag/Controller/Element/UnassignController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,11 @@
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Tag\Attributes\Request\ElementTagRequestBody;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\ElementParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Schema\TagId;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\ElementParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Service\TagServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\UserPermissions;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
Expand All @@ -52,28 +47,28 @@ public function __construct(
/**
* @throws ElementSavingFailedException|ElementNotFoundException
*/
#[Route('/tags/{elementType}/{id}', name: 'pimcore_studio_api_unassign_element_tag', methods: ['DELETE'])]
#[Route('/tags/{elementType}/{id}/{tagId}', name: 'pimcore_studio_api_unassign_element_tag', methods: ['DELETE'])]
//#[IsGranted(UserPermissions::TAGS_ASSIGNMENT->value)]
#[Delete(
path: self::API_PATH . '/tags/{elementType}/{id}',
path: self::API_PATH . '/tags/{elementType}/{id}/{tagId}',
operationId: 'unassignTagFromElement',
summary: 'Unassign tag from element',
security: self::SECURITY_SCHEME,
tags: [Tags::TagsForElement->value]
)]
#[ElementTypeParameter]
#[IdParameter(type: 'element')]
#[ElementTagRequestBody]
#[IdParameter(type: 'tag', name: 'tagId')]
#[DefaultResponses([
HttpResponseCodes::UNAUTHORIZED
])]
public function unassignTag(
string $elementType,
int $id,
#[MapRequestPayload] TagId $unassignTag
int $tagId
): JsonResponse
{
$this->tagService->unassignTagFromElement(new ElementParameters($elementType, $id), $unassignTag->getTagId());
$this->tagService->unassignTagFromElement(new ElementParameters($elementType, $id), $tagId);
return $this->jsonResponse(['id' => $id]);
}
}
5 changes: 2 additions & 3 deletions src/Tag/Controller/UpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@

use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\Put;
use OpenApi\Attributes\Schema;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Tag\Attributes\Request\UpdateTagRequestBody;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\UpdateTagParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\UpdateTagParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Schema\Tag;
use Pimcore\Bundle\StudioBackendBundle\Tag\Service\TagServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes;
Expand Down Expand Up @@ -57,7 +56,7 @@ public function __construct(
tags: [Tags::Tags->name]
)]
#[IsGranted(UserPermissions::TAGS_CONFIGURATION->value)]
#[IdParameter(type: 'tag', schema: new Schema(type: 'integer', example: 10))]
#[IdParameter(type: 'tag')]
#[UpdateTagRequestBody]
#[SuccessResponse(
description: 'Updated tag data as json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

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

/**
* @internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

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

use OpenApi\Attributes\Property;
use OpenApi\Attributes\Schema;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

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

/**
* @internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

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

use Pimcore\Bundle\StudioBackendBundle\Request\CollectionParameters;

use Pimcore\Bundle\StudioBackendBundle\MappedParameter\CollectionParameters;

/**
* @internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

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

use OpenApi\Attributes\Property;
use OpenApi\Attributes\Schema;
Expand Down
11 changes: 5 additions & 6 deletions src/Tag/Repository/TagRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
use Pimcore\Bundle\StudioBackendBundle\Exception\ElementDeletingFailedException;
use Pimcore\Bundle\StudioBackendBundle\Exception\ElementNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\BatchCollectionParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\CreateTagParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\ElementParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\TagsParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\UpdateTagParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Schema\ElementTagIdCollection;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\BatchCollectionParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\CreateTagParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\ElementParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\TagsParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\UpdateTagParameters;
use Pimcore\Bundle\StudioBackendBundle\Util\Traits\ElementProviderTrait;
use Pimcore\Model\Element\Tag;
use Pimcore\Model\Element\Tag\Listing as TagListing;
Expand Down
10 changes: 5 additions & 5 deletions src/Tag/Repository/TagRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

use Pimcore\Bundle\StudioBackendBundle\Exception\ElementDeletingFailedException;
use Pimcore\Bundle\StudioBackendBundle\Exception\ElementNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\BatchCollectionParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\CreateTagParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\ElementParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\TagsParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\Request\UpdateTagParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\BatchCollectionParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\CreateTagParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\ElementParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\TagsParameters;
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\UpdateTagParameters;
use Pimcore\Model\Element\Tag;
use Pimcore\Model\Element\Tag\Listing as TagListing;

Expand Down
Loading

0 comments on commit a5b0bcd

Please sign in to comment.