-
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.
Add asset collections and single asset
- Loading branch information
Showing
11 changed files
with
189 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/api/v1/assets: | ||
get: | ||
tags: [Assets] | ||
summary: Get all assets | ||
parameters: | ||
- in: query | ||
name: page | ||
description: Page number | ||
required: true | ||
schema: | ||
type: integer | ||
format: int | ||
example: 1 | ||
- in: query | ||
name: pageSize | ||
description: Number of items per page | ||
required: true | ||
schema: | ||
type: integer | ||
format: int | ||
example: 10 | ||
responses: | ||
'200': | ||
description: Successful response | ||
content: | ||
application/json: | ||
schema: | ||
ref: '#/components/schemas/Asset' | ||
'403': | ||
description: Unauthorized | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
message: | ||
type: string | ||
example: 'Unauthorized' |
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,30 @@ | ||
/api/v1/assets/{id}: | ||
get: | ||
tags: [Assets] | ||
summary: Get asset with id | ||
parameters: | ||
- in: path | ||
name: id | ||
description: Id of the asset | ||
required: true | ||
schema: | ||
type: integer | ||
format: int | ||
example: 1 | ||
responses: | ||
'200': | ||
description: Successful response | ||
content: | ||
application/json: | ||
schema: | ||
ref: '#/components/schemas/Asset' | ||
'403': | ||
description: Unauthorized | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
message: | ||
type: string | ||
example: 'Unauthorized' |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
api_platform: | ||
resource: . | ||
type: api_platform | ||
prefix: /testtesttest | ||
|
||
|
||
api_platform_swagger_ui: | ||
|
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
|
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,55 @@ | ||
<?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\StudioApiBundle\Controller\Api\V1\Assets; | ||
|
||
use Pimcore\Bundle\StudioApiBundle\Controller\Api\AbstractApiController; | ||
use Pimcore\Bundle\StudioApiBundle\Dto\Collection; | ||
use Pimcore\Bundle\StudioApiBundle\Service\AssetSearchServiceInterface; | ||
use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\AssetQuery; | ||
use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\AssetQueryProviderInterface; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpKernel\Attribute\MapQueryString; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
use Symfony\Component\Serializer\SerializerInterface; | ||
|
||
final class CollectionController extends AbstractApiController | ||
{ | ||
public function __construct( | ||
SerializerInterface $serializer, | ||
private readonly AssetQueryProviderInterface $assetQueryProvider, | ||
private readonly AssetSearchServiceInterface $assetSearchService, | ||
) | ||
{ | ||
parent::__construct($serializer); | ||
} | ||
|
||
#[Route('/v1/assets', name: 'pimcore_studio_api_v1_asets', methods: ['GET'])] | ||
public function getAssets(#[MapQueryString] Collection $collection): JsonResponse | ||
{ | ||
|
||
$assetQuery = $this->getAssetQuery() | ||
->setPage($collection->getPage()) | ||
->setPageSize($collection->getPageSize()); | ||
|
||
|
||
return $this->jsonLd($this->assetSearchService->searchAssets($assetQuery)); | ||
} | ||
|
||
private function getAssetQuery(): AssetQuery | ||
{ | ||
return $this->assetQueryProvider->createAssetQuery(); | ||
} | ||
} |
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\StudioApiBundle\Controller\Api\V1\Assets; | ||
|
||
use Pimcore\Bundle\StudioApiBundle\Controller\Api\AbstractApiController; | ||
use Pimcore\Bundle\StudioApiBundle\Service\AssetSearchServiceInterface; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
use Symfony\Component\Serializer\SerializerInterface; | ||
|
||
final class GetController extends AbstractApiController | ||
{ | ||
public function __construct( | ||
SerializerInterface $serializer, | ||
private readonly AssetSearchServiceInterface $assetSearchService, | ||
) | ||
{ | ||
parent::__construct($serializer); | ||
} | ||
|
||
#[Route('/v1/assets/{id}', name: 'pimcore_studio_api_v1_get_asset', methods: ['GET'])] | ||
public function getAssets(int $id): JsonResponse | ||
{ | ||
return $this->jsonLd($this->assetSearchService->getAssetById($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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* Pimcore | ||
* | ||
|
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 was deleted.
Oops, something went wrong.
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