Skip to content

Commit 3388ef2

Browse files
committed
IBX-5135: Added IsMainLocation criterion parser
1 parent 5703ff5 commit 3388ef2

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed

src/bundle/Resources/config/input_parsers.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ services:
296296
tags:
297297
- { name: ibexa.rest.input.parser, mediaType: application/vnd.ibexa.api.internal.criterion.LocationDepth }
298298

299+
Ibexa\Rest\Server\Input\Parser\Criterion\Location\IsMainLocation:
300+
parent: Ibexa\Rest\Server\Common\Parser
301+
tags:
302+
- { name: ibexa.rest.input.parser, mediaType: application/vnd.ibexa.api.internal.criterion.IsMainLocation }
303+
299304
Ibexa\Rest\Server\Input\Parser\Criterion\Ancestor:
300305
parent: Ibexa\Rest\Server\Common\Parser
301306
class: Ibexa\Rest\Server\Input\Parser\Criterion\Ancestor
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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\Location;
10+
11+
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Location\IsMainLocation as IsMainLocationCriterion;
12+
use Ibexa\Contracts\Rest\Exceptions;
13+
use Ibexa\Contracts\Rest\Input\ParsingDispatcher;
14+
use Ibexa\Rest\Input\BaseParser;
15+
16+
final class IsMainLocation extends BaseParser
17+
{
18+
public function parse(array $data, ParsingDispatcher $parsingDispatcher): IsMainLocationCriterion
19+
{
20+
if (!array_key_exists('IsMainLocation', $data)) {
21+
throw new Exceptions\Parser('Invalid <IsMainLocation> format');
22+
}
23+
24+
return new IsMainLocationCriterion($data['IsMainLocation']);
25+
}
26+
}

tests/bundle/Functional/ViewTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ public function provideForViewTest(): iterable
101101
file_get_contents(__DIR__ . '/_input/search/LocationDepth.in.json'),
102102
'json',
103103
];
104+
105+
yield $template('IsMainLocation', 'eq', 'xml') => [
106+
file_get_contents(__DIR__ . '/_input/search/IsMainLocation.xml'),
107+
'xml',
108+
];
109+
110+
yield $template('IsMainLocation', 'eq', 'json') => [
111+
file_get_contents(__DIR__ . '/_input/search/IsMainLocation.json'),
112+
'json',
113+
];
104114
}
105115

106116
/**
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"ViewInput": {
3+
"identifier": "TitleView",
4+
"Query": {
5+
"LocationFilter": {
6+
"IsMainLocation": 1
7+
},
8+
"limit": 10,
9+
"offset": 0
10+
}
11+
}
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ViewInput>
3+
<identifier>TitleView</identifier>
4+
<Query>
5+
<LocationFilter>
6+
<IsMainLocation>1</IsMainLocation>
7+
</LocationFilter>
8+
<limit>10</limit>
9+
<offset>0</offset>
10+
</Query>
11+
</ViewInput>

0 commit comments

Comments
 (0)