File tree Expand file tree Collapse file tree
lib/Server/Input/Parser/Criterion
tests/bundle/Functional/SearchView/Criterion Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -441,6 +441,13 @@ services:
441441 tags :
442442 - { name: ibexa.rest.input.parser, mediaType: application/vnd.ibexa.api.internal.criterion.UserMetadata }
443443
444+ Ibexa\Rest\Server\Input\Parser\Criterion\IsContainer :
445+ parent : Ibexa\Rest\Server\Common\Parser
446+ arguments :
447+ $parserTools : ' @Ibexa\Rest\Input\ParserTools'
448+ tags :
449+ - { name: ibexa.rest.input.parser, mediaType: application/vnd.ibexa.api.internal.criterion.IsContainer }
450+
444451 Ibexa\Rest\Server\Input\Parser\Criterion\IsUserBased :
445452 parent : Ibexa\Rest\Server\Common\Parser
446453 arguments :
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * @copyright Copyright (C) Ibexa AS. All rights reserved.
5+ * @license For full copyright and license information view LICENSE file distributed with this source code.
6+ */
7+ declare (strict_types=1 );
8+
9+ namespace Ibexa \Rest \Server \Input \Parser \Criterion ;
10+
11+ use Ibexa \Contracts \Core \Repository \Values \Content \Query \Criterion \IsContainer as IsContainerCriterion ;
12+ use Ibexa \Contracts \Rest \Exceptions ;
13+ use Ibexa \Contracts \Rest \Input \ParsingDispatcher ;
14+ use Ibexa \Rest \Input \BaseParser ;
15+ use Ibexa \Rest \Input \ParserTools ;
16+
17+ final class IsContainer extends BaseParser
18+ {
19+ private ParserTools $ parserTools ;
20+
21+ public function __construct (ParserTools $ parserTools )
22+ {
23+ $ this ->parserTools = $ parserTools ;
24+ }
25+
26+ /**
27+ * @param array<mixed> $data
28+ */
29+ public function parse (array $ data , ParsingDispatcher $ parsingDispatcher ): IsContainerCriterion
30+ {
31+ if (!array_key_exists ('IsContainerCriterion ' , $ data )) {
32+ throw new Exceptions \Parser ('Invalid <IsContainer> format ' );
33+ }
34+
35+ return new IsContainerCriterion ($ this ->parserTools ->parseBooleanValue ($ data ['IsContainerCriterion ' ]));
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * @copyright Copyright (C) Ibexa AS. All rights reserved.
5+ * @license For full copyright and license information view LICENSE file distributed with this source code.
6+ */
7+ declare (strict_types=1 );
8+
9+ namespace Ibexa \Tests \Bundle \Rest \Functional \SearchView \Criterion ;
10+
11+ use Ibexa \Tests \Bundle \Rest \Functional \SearchView \SearchCriterionTestCase ;
12+
13+ final class IsContainerTest extends SearchCriterionTestCase
14+ {
15+ /**
16+ * @phpstan-return iterable<
17+ * string,
18+ * array{
19+ * string,
20+ * string,
21+ * int,
22+ * },
23+ * >
24+ */
25+ public function getCriteriaPayloads (): iterable
26+ {
27+ return [
28+ 'is container ' => [
29+ 'json ' ,
30+ $ this ->buildJsonCriterionQuery ('"IsContainerCriterion": true ' ),
31+ 10 ,
32+ ],
33+ 'is not container ' => [
34+ 'json ' ,
35+ $ this ->buildJsonCriterionQuery ('"IsContainerCriterion": false ' ),
36+ 2 ,
37+ ],
38+ ];
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments