-
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.
Wrap collection response into an object and set total items (#31)
* Wrap collection response into an object and set total items * Apply php-cs-fixer changes * Restructure * Rename property * Update minor stuff * CS fix * Remove unecessary brackets * Add DataObjectCollection * Apply php-cs-fixer changes --------- Co-authored-by: mattamon <[email protected]>
- Loading branch information
Showing
10 changed files
with
203 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?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\Attributes\Response\Content; | ||
|
||
use OpenApi\Attributes\JsonContent; | ||
use OpenApi\Attributes\Property; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class CollectionJson extends JsonContent | ||
{ | ||
public function __construct(Property $collection) | ||
{ | ||
parent::__construct( | ||
properties: [ | ||
new Property('totalItems', title: 'totalItems', type: 'integer', example: 666), | ||
$collection, | ||
], | ||
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,56 @@ | ||
<?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\Attributes\Response\Property; | ||
|
||
use OpenApi\Attributes\Items; | ||
use OpenApi\Attributes\Property; | ||
use OpenApi\Attributes\Schema; | ||
use Pimcore\Bundle\StudioApiBundle\Response\Asset\Archive; | ||
use Pimcore\Bundle\StudioApiBundle\Response\Asset\Audio; | ||
use Pimcore\Bundle\StudioApiBundle\Response\Asset\Document; | ||
use Pimcore\Bundle\StudioApiBundle\Response\Asset\Folder; | ||
use Pimcore\Bundle\StudioApiBundle\Response\Asset\Image; | ||
use Pimcore\Bundle\StudioApiBundle\Response\Asset\Text; | ||
use Pimcore\Bundle\StudioApiBundle\Response\Asset\Unknown; | ||
use Pimcore\Bundle\StudioApiBundle\Response\Asset\Video; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class AssetCollection extends Property | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct( | ||
'items', | ||
title: 'items', | ||
type: 'array', | ||
items: new Items( | ||
anyOf: [ | ||
new Schema(ref: Image::class), | ||
new Schema(ref: Document::class), | ||
new Schema(ref: Audio::class), | ||
new Schema(ref: Video::class), | ||
new Schema(ref: Archive::class), | ||
new Schema(ref: Text::class), | ||
new Schema(ref: Folder::class), | ||
new Schema(ref: Unknown::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
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\StudioApiBundle\Attributes\Response\Property; | ||
|
||
use OpenApi\Attributes\Items; | ||
use OpenApi\Attributes\Property; | ||
use OpenApi\Attributes\Schema; | ||
use Pimcore\Bundle\StudioApiBundle\Response\DataObject; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class DataObjectCollection extends Property | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct( | ||
'items', | ||
title: 'items', | ||
type: 'array', | ||
items: new Items( | ||
anyOf: [ | ||
new Schema(ref: DataObject::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
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,48 @@ | ||
<?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\Response; | ||
|
||
use OpenApi\Attributes\Property; | ||
use OpenApi\Attributes\Schema; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
#[Schema( | ||
title: 'Collection', | ||
type: 'object' | ||
)] | ||
final readonly class Collection | ||
{ | ||
public function __construct( | ||
#[Property(description: 'total items', type: 'integer', example: 666)] | ||
private int $totalItems, | ||
#[Property(description: 'items', type: 'mixed', example: ['Asset', 'Folder', 'Document', 'DataObject'])] | ||
private array $items | ||
) { | ||
} | ||
|
||
public function getTotalItems(): int | ||
{ | ||
return $this->totalItems; | ||
} | ||
|
||
public function getItems(): array | ||
{ | ||
return $this->items; | ||
} | ||
} |
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