Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"ext-libxml": "*",
"ext-simplexml": "*",
"ext-xmlwriter": "*",
"ibexa/core": "~4.6.0@dev",
"ibexa/core": "dev-ibx-10458-content-type-search-papi as 4.6.0@dev",
"symfony/http-kernel": "^5.3",
"symfony/dependency-injection": "^5.3",
"symfony/routing": "^5.3",
Expand Down
2 changes: 2 additions & 0 deletions src/bundle/DependencyInjection/IbexaRestExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ protected function loadInternal(array $mergedConfig, ContainerBuilder $container
$loader->load('input_parsers.yml');
$loader->load('security.yml');
$loader->load('default_settings.yml');
$loader->load('criteria.yaml');
$loader->load('sort_clauses.yaml');

$processor = new ConfigurationProcessor($container, 'ibexa.site_access.config');
$processor->mapConfigArray('rest_root_resources', $mergedConfig);
Expand Down
40 changes: 40 additions & 0 deletions src/bundle/Resources/config/criteria.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
services:
Ibexa\Rest\Server\Input\Parser\ContentType\Criterion\CriterionProcessor:
parent: Ibexa\Contracts\Rest\Input\Parser\Query\Criterion\BaseCriterionProcessor

Ibexa\Rest\Server\Input\Parser\ContentType\SortClause\SortClauseProcessor:
parent: Ibexa\Contracts\Rest\Input\Parser\Query\SortClause\BaseSortClauseProcessor

_instanceof:
Ibexa\Rest\Server\Input\Parser\ContentType\Criterion\ContentTypeCriterionInterface:
tags:
- 'ibexa.rest.content_type.criterion'

Ibexa\Rest\Server\Input\Parser\ContentType\Criterion\ContentTypeCriteriaRegistry:
arguments:
- !tagged_iterator ibexa.rest.content_type.criterion

Ibexa\Rest\Server\Input\Parser\ContentType\Criterion\ContentTypeId:
parent: Ibexa\Rest\Server\Common\Parser
tags:
- { name: ibexa.rest.input.parser, mediaType: application/vnd.ibexa.api.internal.criterion.ContentTypeId }

Ibexa\Rest\Server\Input\Parser\ContentType\Criterion\ContentTypeIdentifier:
parent: Ibexa\Rest\Server\Common\Parser
tags:
- { name: ibexa.rest.input.parser, mediaType: application/vnd.ibexa.api.internal.criterion.ContentTypeIdentifier }

Ibexa\Rest\Server\Input\Parser\ContentType\Criterion\IsSystem:
parent: Ibexa\Rest\Server\Common\Parser
tags:
- { name: ibexa.rest.input.parser, mediaType: application/vnd.ibexa.api.internal.criterion.IsSystem }

Ibexa\Rest\Server\Input\Parser\ContentType\Criterion\ContentTypeGroupId:
parent: Ibexa\Rest\Server\Common\Parser
tags:
- { name: ibexa.rest.input.parser, mediaType: application/vnd.ibexa.api.internal.criterion.ContentTypeGroupId }

Ibexa\Rest\Server\Input\Parser\ContentType\Criterion\ContainsFieldDefinitionId:
parent: Ibexa\Rest\Server\Common\Parser
tags:
- { name: ibexa.rest.input.parser, mediaType: application/vnd.ibexa.api.internal.criterion.ContainsFieldDefinitionId }
15 changes: 15 additions & 0 deletions src/bundle/Resources/config/input_parsers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ services:
tags:
- { name: ibexa.rest.input.parser, mediaType: application/vnd.ibexa.api.ContentTypeUpdate }

Ibexa\Rest\Server\Input\Parser\ContentType\RestViewInput:
parent: Ibexa\Rest\Server\Common\Parser
arguments:
$validator: '@validator'
tags:
- { name: ibexa.rest.input.parser, mediaType: application/vnd.ibexa.api.ContentTypeViewInput }

Ibexa\Rest\Server\Input\Parser\ContentType\Query\ContentTypeQuery:
parent: Ibexa\Rest\Server\Common\Parser
arguments:
$criterionProcessor: '@Ibexa\Rest\Server\Input\Parser\ContentType\Criterion\CriterionProcessor'
$sortClauseProcessor: '@Ibexa\Rest\Server\Input\Parser\ContentType\SortClause\SortClauseProcessor'
tags:
- { name: ibexa.rest.input.parser, mediaType: application/vnd.ibexa.api.internal.ContentTypeQuery }

Ibexa\Rest\Server\Input\Parser\FieldDefinitionCreate:
parent: Ibexa\Rest\Server\Common\Parser
class: Ibexa\Rest\Server\Input\Parser\FieldDefinitionCreate
Expand Down
7 changes: 7 additions & 0 deletions src/bundle/Resources/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,13 @@ ibexa.rest.list_content_types:
_controller: Ibexa\Rest\Server\Controller\ContentType:listContentTypes
methods: [GET]

ibexa.rest.content_types.view:
path: /content/types/view
methods: [ POST ]
controller: Ibexa\Rest\Server\Controller\ContentType::createView
options:
expose: true

ibexa.rest.copy_content_type:
path: /content/types/{contentTypeId}
defaults:
Expand Down
24 changes: 24 additions & 0 deletions src/bundle/Resources/config/sort_clauses.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
services:
Ibexa\Rest\Server\Input\Parser\ContentType\SortClause\ContentTypeSortClausesRegistry:
arguments:
- !tagged_iterator ibexa.rest.content_type.sort_clause

ibexa.rest.input.parser.internal.sortclause.id:
parent: Ibexa\Rest\Server\Common\Parser
class: Ibexa\Rest\Server\Input\Parser\SortClause\DataKeyValueObjectClass
arguments:
$dataKey: 'Id'
$valueObjectClass: 'Ibexa\Contracts\Core\Repository\Values\ContentType\Query\SortClause\Id'
tags:
- { name: ibexa.rest.input.parser, mediaType: application/vnd.ibexa.api.internal.sortclause.Id }
- { name: ibexa.rest.content_type.sort_clause }

ibexa.rest.input.parser.internal.sortclause.identifier:
parent: Ibexa\Rest\Server\Common\Parser
class: Ibexa\Rest\Server\Input\Parser\SortClause\DataKeyValueObjectClass
arguments:
$dataKey: 'Identifier'
$valueObjectClass: 'Ibexa\Contracts\Core\Repository\Values\ContentType\Query\SortClause\Identifier'
tags:
- { name: ibexa.rest.input.parser, mediaType: application/vnd.ibexa.api.internal.sortclause.Identifier }
- { name: ibexa.rest.content_type.sort_clause }
21 changes: 20 additions & 1 deletion src/lib/Server/Controller/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Rest\Server\Controller;

use Ibexa\Contracts\Core\Repository\ContentTypeService;
Expand All @@ -21,7 +23,6 @@
use Ibexa\Rest\Server\Exceptions\BadRequestException;
use Ibexa\Rest\Server\Exceptions\ForbiddenException;
use Ibexa\Rest\Server\Values;
use JMS\TranslationBundle\Annotation\Ignore;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down Expand Up @@ -905,6 +906,24 @@ public function unlinkContentTypeFromGroup($contentTypeId, $contentTypeGroupId)
);
}

public function createView(Request $request): Values\ContentTypeList
{
/** @var \Ibexa\Rest\Server\Values\ContentTypeRestViewInput $viewInput */
$viewInput = $this->inputDispatcher->parse(
new Message(
['Content-Type' => $request->headers->get('Content-Type')],
$request->getContent()
)
);

$contentTypes = $this->contentTypeService->findContentTypes($viewInput->query);

return new Values\ContentTypeList(
$contentTypes->getContentTypes(),
'',
);
}

/**
* Converts the provided ContentTypeGroupCreateStruct to ContentTypeGroupUpdateStruct.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Rest\Server\Input\Parser\ContentType\Criterion;

use Ibexa\Contracts\Core\Repository\Values\ContentType\Query\Criterion\ContainsFieldDefinitionId as ContainsFieldDefinitionIdCriterion;
use Ibexa\Contracts\Rest\Exceptions;
use Ibexa\Contracts\Rest\Input\ParsingDispatcher;
use Ibexa\Rest\Input\BaseParser;

final class ContainsFieldDefinitionId extends BaseParser implements ContentTypeCriterionInterface
{
private const ID_CRITERION = 'ContainsFieldDefinitionIdCriterion';

/**
* @param array<mixed> $data
*
* @throws \Ibexa\Contracts\Rest\Exceptions\Parser
*/
public function parse(array $data, ParsingDispatcher $parsingDispatcher): ContainsFieldDefinitionIdCriterion
{
if (!array_key_exists(self::ID_CRITERION, $data)) {
throw new Exceptions\Parser('Invalid <' . self::ID_CRITERION . '> format');
}

$ids = $data[self::ID_CRITERION];

return new ContainsFieldDefinitionIdCriterion($ids);
}

public function getName(): string
{
return self::ID_CRITERION;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Rest\Server\Input\Parser\ContentType\Criterion;

final class ContentTypeCriteriaRegistry
{
/** @var iterable<\Ibexa\Rest\Server\Input\Parser\ContentType\Criterion\ContentTypeCriterionInterface> */
private iterable $criteria;

/**
* @param iterable<\Ibexa\Rest\Server\Input\Parser\ContentType\Criterion\ContentTypeCriterionInterface> $criteria
*/
public function __construct(iterable $criteria)
{
$this->criteria = $criteria;
}

/**
* @return iterable<\Ibexa\Rest\Server\Input\Parser\ContentType\Criterion\ContentTypeCriterionInterface>
*/
public function getCriteria(): iterable
{
return $this->criteria;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Rest\Server\Input\Parser\ContentType\Criterion;

interface ContentTypeCriterionInterface
{
public function getName(): string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Rest\Server\Input\Parser\ContentType\Criterion;

use Ibexa\Contracts\Core\Repository\Values\ContentType\Query\Criterion\ContentTypeGroupId as ContentTypeGroupIdCriterion;
use Ibexa\Contracts\Rest\Exceptions;
use Ibexa\Contracts\Rest\Input\ParsingDispatcher;
use Ibexa\Rest\Input\BaseParser;

final class ContentTypeGroupId extends BaseParser implements ContentTypeCriterionInterface
{
private const GROUP_ID = 'ContentTypeGroupIdCriterion';

/**
* @param array<mixed> $data
*
* @throws \Ibexa\Contracts\Rest\Exceptions\Parser
*/
public function parse(array $data, ParsingDispatcher $parsingDispatcher): ContentTypeGroupIdCriterion
{
if (!array_key_exists(self::GROUP_ID, $data)) {
throw new Exceptions\Parser('Invalid <' . self::GROUP_ID . '> format');
}

$ids = $data[self::GROUP_ID];

return new ContentTypeGroupIdCriterion($ids);
}

public function getName(): string
{
return self::GROUP_ID;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Rest\Server\Input\Parser\ContentType\Criterion;

use Ibexa\Contracts\Core\Repository\Values\ContentType\Query\Criterion\ContentTypeId as ContentTypeIdCriterion;
use Ibexa\Contracts\Rest\Exceptions;
use Ibexa\Contracts\Rest\Input\ParsingDispatcher;
use Ibexa\Rest\Input\BaseParser;

final class ContentTypeId extends BaseParser implements ContentTypeCriterionInterface
{
private const ID_CRITERION = 'ContentTypeIdCriterion';

/**
* @param array<mixed> $data
*
* @throws \Ibexa\Contracts\Rest\Exceptions\Parser
*/
public function parse(array $data, ParsingDispatcher $parsingDispatcher): ContentTypeIdCriterion
{
if (!array_key_exists(self::ID_CRITERION, $data)) {
throw new Exceptions\Parser('Invalid <' . self::ID_CRITERION . '> format');
}

$ids = $data[self::ID_CRITERION];

return new ContentTypeIdCriterion($ids);
}

public function getName(): string
{
return self::ID_CRITERION;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Rest\Server\Input\Parser\ContentType\Criterion;

use Ibexa\Contracts\Core\Repository\Values\ContentType\Query\Criterion\ContentTypeIdentifier as ContentTypeIdentifierCriterion;
use Ibexa\Contracts\Rest\Exceptions;
use Ibexa\Contracts\Rest\Input\ParsingDispatcher;
use Ibexa\Rest\Input\BaseParser;

final class ContentTypeIdentifier extends BaseParser implements ContentTypeCriterionInterface
{
private const IDENTIFIER_CRITERION = 'ContentTypeIdentifierCriterion';

/**
* @param array<mixed> $data
*
* @throws \Ibexa\Contracts\Rest\Exceptions\Parser
*/
public function parse(array $data, ParsingDispatcher $parsingDispatcher): ContentTypeIdentifierCriterion
{
if (!array_key_exists(self::IDENTIFIER_CRITERION, $data)) {
throw new Exceptions\Parser('Invalid <' . self::IDENTIFIER_CRITERION . '> format');
}

$ids = $data[self::IDENTIFIER_CRITERION];

return new ContentTypeIdentifierCriterion($ids);
}

public function getName(): string
{
return self::IDENTIFIER_CRITERION;
}
}
Loading
Loading