-
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.
Restructure metadata and add collection endpoint
- Loading branch information
Showing
17 changed files
with
350 additions
and
43 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
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,72 @@ | ||
<?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\Metadata\Controller; | ||
|
||
|
||
use OpenApi\Attributes\Get; | ||
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; | ||
use Pimcore\Bundle\StudioBackendBundle\Metadata\MappedParameter\MetadataParameters; | ||
use Pimcore\Bundle\StudioBackendBundle\Metadata\Schema\PredefinedMetadata; | ||
use Pimcore\Bundle\StudioBackendBundle\Metadata\Service\MetadataServiceInterface; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Content\ItemsJson; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\FilterParameter; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; | ||
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes; | ||
use Pimcore\Bundle\StudioBackendBundle\Util\Trait\PaginatedResponseTrait; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpKernel\Attribute\MapQueryString; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
use Symfony\Component\Serializer\SerializerInterface; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class CollectionController extends AbstractApiController | ||
{ | ||
use PaginatedResponseTrait; | ||
|
||
public function __construct( | ||
SerializerInterface $serializer, | ||
private readonly MetadataServiceInterface $metadataService, | ||
) { | ||
parent::__construct($serializer); | ||
} | ||
|
||
#[Route('/metadata', name: 'pimcore_studio_api_metadata', methods: ['GET'])] | ||
#[Get( | ||
path: self::PREFIX . '/metadata', | ||
operationId: 'metadata_get_collection', | ||
description: 'metadata_get_collection_description', | ||
summary: 'metadata_get_collection_summary', | ||
tags: [Tags::Metadata->name] | ||
)] | ||
#[FilterParameter] | ||
#[SuccessResponse( | ||
description: 'metadata_get_collection_success_response', | ||
content: new ItemsJson(PredefinedMetadata::class) | ||
)] | ||
#[DefaultResponses([ | ||
HttpResponseCodes::UNAUTHORIZED, | ||
])] | ||
public function getMetadata( | ||
#[MapQueryString] MetadataParameters $parameters = new MetadataParameters() | ||
): JsonResponse { | ||
return $this->jsonResponse(['items' => $this->metadataService->getPredefinedMetadata($parameters)]); | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
src/Metadata/Event/PreResponse/PredefinedMetadataEvent.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,39 @@ | ||
<?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\Metadata\Event\PreResponse; | ||
|
||
use Pimcore\Bundle\StudioBackendBundle\Event\AbstractPreResponseEvent; | ||
use Pimcore\Bundle\StudioBackendBundle\Metadata\Schema\PredefinedMetadata; | ||
|
||
final class PredefinedMetadataEvent extends AbstractPreResponseEvent | ||
{ | ||
public const EVENT_NAME = 'pre_response.asset_predefined_metadata'; | ||
|
||
public function __construct( | ||
private readonly PredefinedMetadata $predefinedMetadata | ||
) { | ||
parent::__construct($predefinedMetadata); | ||
} | ||
|
||
/** | ||
* Use this to get additional infos out of the response object | ||
*/ | ||
public function getPredefinedMetadata(): PredefinedMetadata | ||
{ | ||
return $this->predefinedMetadata; | ||
} | ||
} |
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,31 @@ | ||
<?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\Metadata\Hydrator; | ||
|
||
use Pimcore\Bundle\StudioBackendBundle\Metadata\Schema\CustomMetadata; | ||
use Pimcore\Bundle\StudioBackendBundle\Metadata\Schema\PredefinedMetadata; | ||
use Pimcore\Model\Metadata\Predefined; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
interface MetadataHydratorInterface | ||
{ | ||
public function hydrate(array $customMetadata): CustomMetadata; | ||
|
||
public function hydratePredefined(Predefined $predefined): PredefinedMetadata; | ||
} |
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.