Skip to content

Commit

Permalink
Add permissions schema
Browse files Browse the repository at this point in the history
  • Loading branch information
mattamon committed Apr 10, 2024
1 parent 7275d91 commit 0c329c6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/Config/OpenApi/Spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@
use OpenApi\Attributes\License;

#[Info(
version: 'v1',
description: 'Rest API for Studio generated by OpenAPI Generator via zircote/swagger-php',
version: '0.0.1',
description: 'API for Studio generated by OpenApi Generator via zircote/swagger-php',
title: 'Studio API'
)]
#[License(name: 'MIT', identifier: 'MIT')]
#[License(
name: 'GNU General Public License version 3 & Pimcore Commercial License',
identifier: 'GPLv3 & PCL',
url: 'https://www.pimcore.org/license'
)]

final class Spec
{
}
1 change: 1 addition & 0 deletions src/Dto/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function __construct(
?int $creationDate,
#[Property(description: 'Modification date', type: 'integer', example: 1634025800)]
?int $modificationDate,
#[Property(ref: Permissions::class)]
Permissions $permissions
) {
parent::__construct(
Expand Down
20 changes: 18 additions & 2 deletions src/Dto/Asset/Permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,34 @@

namespace Pimcore\Bundle\StudioApiBundle\Dto\Asset;

readonly class Permissions
use OpenApi\Attributes\Property;
use OpenApi\Attributes\Schema;

#[Schema(
title: 'Permissions',
type: 'object'
)]
final readonly class Permissions
{
//TODO: remove or change default permissions

public function __construct(
#[Property(description: 'List', type: 'bool', example: true)]
private bool $list = true,
#[Property(description: 'View', type: 'bool', example: true)]
private bool $view = true,
#[Property(description: 'Publish', type: 'bool', example: true)]
private bool $publish = true,
#[Property(description: 'Delete', type: 'bool', example: true)]
private bool $delete = true,
#[Property(description: 'Rename', type: 'bool', example: true)]
private bool $rename = true,
#[Property(description: 'Create', type: 'bool', example: true)]
private bool $create = true,
#[Property(description: 'Settings', type: 'bool', example: true)]
private bool $settings = true,
#[Property(description: 'Versions', type: 'bool', example: true)]
private bool $versions = true,
#[Property(description: 'Properties', type: 'bool', example: true)]
private bool $properties = true
) {
}
Expand Down
5 changes: 4 additions & 1 deletion src/Service/GenericData/V1/DataObjectQueryProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

namespace Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1;

use Pimcore\Bundle\GenericDataIndexBundle\Model\Search\DataObject\DataObjectSearchInterface;
use Pimcore\Bundle\GenericDataIndexBundle\Service\Search\SearchService\SearchProviderInterface;
use Pimcore\Bundle\StaticResolverBundle\Models\DataObject\ClassDefinitionResolverInterface;

Expand All @@ -29,6 +30,8 @@ public function __construct(

public function createDataObjectQuery(): DataObjectQuery
{
return new DataObjectQuery($this->searchProvider->createDataObjectSearch(), $this->classDefinitionResolver);
/** @var DataObjectSearchInterface $dataObjectSearch */
$dataObjectSearch = $this->searchProvider->createDataObjectSearch();
return new DataObjectQuery($dataObjectSearch, $this->classDefinitionResolver);
}
}

0 comments on commit 0c329c6

Please sign in to comment.