Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-8190: Add Symfony's Serializer support #121

Open
wants to merge 98 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
cb4e61d
Add Symfony's Serializer support
barw4 Aug 12, 2024
5bf3e43
Add `AdapterNormalizer`
barw4 Aug 22, 2024
b478bae
Remove `ValueObjectVisitorDispatcher`
barw4 Aug 23, 2024
8e1ddf2
Rollback
barw4 Aug 23, 2024
1faaf7d
Rollback
barw4 Aug 23, 2024
d59508e
Rollback
barw4 Aug 23, 2024
2e731e3
Fixup
barw4 Aug 23, 2024
b56999e
Applied review remarks
barw4 Aug 27, 2024
a6cb018
Code cleanup
barw4 Aug 27, 2024
6bc9690
Code cleanup
barw4 Aug 27, 2024
97dc64b
Code cleanup
barw4 Aug 27, 2024
9659e6a
Fixup
barw4 Aug 27, 2024
8697942
Change login code to 200
barw4 Aug 27, 2024
d182d85
Set proper encoding format
barw4 Aug 28, 2024
ae726ac
Handle XML
barw4 Sep 4, 2024
be01db6
Rollback
barw4 Sep 4, 2024
a373e56
Rollback
barw4 Sep 4, 2024
f3b23cc
Use dispatched visitor instead of creating a new one
barw4 Sep 4, 2024
a515652
Reuse already initialized visitor
barw4 Sep 5, 2024
20b0b1e
Fixup
barw4 Sep 5, 2024
ed2f886
Fix PHPStan issues
barw4 Sep 5, 2024
3d01d41
Fixups
barw4 Sep 5, 2024
847a54d
Fixups
barw4 Sep 6, 2024
5cf488f
Make unit tests use the new XML generator
barw4 Oct 1, 2024
89572a8
Rollback
barw4 Oct 1, 2024
7a6e45c
Stan
barw4 Oct 1, 2024
3b6da3a
Made `transformData` method private
Steveb-p Oct 2, 2024
176ea72
Introduced normalizers for Generator state
Steveb-p Oct 8, 2024
7c5c50a
Introduced normalizers for Generator state
Steveb-p Oct 8, 2024
81e18ea
Introduced normalizers for Generator state
Steveb-p Oct 8, 2024
6e5d5b4
Introduced normalizers for Generator state
Steveb-p Oct 8, 2024
0babd33
Introduced normalizers for Generator state
Steveb-p Oct 8, 2024
26fd4bb
Introduced normalizers for Generator state
Steveb-p Oct 8, 2024
264eb4f
Introduced normalizers for Generator state
Steveb-p Oct 8, 2024
a78bb4b
Introduced normalizers for Generator state
Steveb-p Oct 8, 2024
4a63396
Add Symfony's Serializer support
barw4 Aug 12, 2024
179d53e
Add `AdapterNormalizer`
barw4 Aug 22, 2024
5bd9f48
Remove `ValueObjectVisitorDispatcher`
barw4 Aug 23, 2024
0f4433d
Rollback
barw4 Aug 23, 2024
8c35ac3
Rollback
barw4 Aug 23, 2024
a8ab8f6
Rollback
barw4 Aug 23, 2024
07d16a9
Fixup
barw4 Aug 23, 2024
5ba013a
Applied review remarks
barw4 Aug 27, 2024
9b751b8
Code cleanup
barw4 Aug 27, 2024
2bf13b9
Code cleanup
barw4 Aug 27, 2024
23aea91
Code cleanup
barw4 Aug 27, 2024
4d82929
Fixup
barw4 Aug 27, 2024
3e2ed35
Change login code to 200
barw4 Aug 27, 2024
cca8fa2
Set proper encoding format
barw4 Aug 28, 2024
d4741e1
Handle XML
barw4 Sep 4, 2024
b918595
Rollback
barw4 Sep 4, 2024
5b34e35
Rollback
barw4 Sep 4, 2024
f7edd5a
Use dispatched visitor instead of creating a new one
barw4 Sep 4, 2024
5a60415
Reuse already initialized visitor
barw4 Sep 5, 2024
0404793
Fixup
barw4 Sep 5, 2024
effe8d8
Fix PHPStan issues
barw4 Sep 5, 2024
12d2a5c
Fixups
barw4 Sep 5, 2024
4f23fca
Fixups
barw4 Sep 6, 2024
737877a
Make unit tests use the new XML generator
barw4 Oct 1, 2024
8b57228
Rollback
barw4 Oct 1, 2024
b12d06d
Made `transformData` method private
Steveb-p Oct 2, 2024
ea56426
Introduced normalizers for Generator state
Steveb-p Oct 8, 2024
be241a3
Introduced normalizers for Generator state
Steveb-p Oct 8, 2024
a934afd
Introduced normalizers for Generator state
Steveb-p Oct 8, 2024
6b77b59
Introduced normalizers for Generator state
Steveb-p Oct 8, 2024
91976bf
Introduced normalizers for Generator state
Steveb-p Oct 8, 2024
64aeee9
Introduced normalizers for Generator state
Steveb-p Oct 8, 2024
b5e74ab
Introduced normalizers for Generator state
Steveb-p Oct 8, 2024
bb2b396
Introduced normalizers for Generator state
Steveb-p Oct 8, 2024
1243dd6
Update Generator normalizers
barw4 Oct 10, 2024
f67ee78
Generate baseline
barw4 Oct 10, 2024
730868f
Refactor encoder context
barw4 Oct 10, 2024
b08f735
Handle empty `ArrayList` object
barw4 Oct 10, 2024
d781e88
`outer_element` context item
barw4 Oct 10, 2024
d7db4db
Remove dependencies to old Xml generator
barw4 Oct 15, 2024
b59b5bc
Merge remote-tracking branch 'origin/serializer-support' into seriali…
barw4 Oct 15, 2024
e16ec64
Remove old Xml generator
barw4 Oct 15, 2024
e692018
Merge branch 'main' into serializer-support
barw4 Oct 15, 2024
46032c9
CS
barw4 Oct 15, 2024
31fcff8
Merge remote-tracking branch 'origin/serializer-support' into seriali…
barw4 Oct 15, 2024
6330b60
Update services.yml
barw4 Oct 16, 2024
9d014ce
Rollback
barw4 Oct 16, 2024
3318577
Implement integration tests
barw4 Oct 18, 2024
8f232cf
Fixup
barw4 Oct 18, 2024
b567473
CS
barw4 Oct 18, 2024
bee695f
Fixup
barw4 Oct 18, 2024
cc840b3
Fix tests
barw4 Oct 21, 2024
66deeb9
Fixup
barw4 Oct 21, 2024
d8e19c1
Cleanup generators
barw4 Oct 23, 2024
32801e9
PHPStan
barw4 Oct 23, 2024
d608d6a
CS
barw4 Oct 23, 2024
c13ec95
Remove comment
barw4 Oct 23, 2024
32ca57e
Clean up field generators
barw4 Oct 24, 2024
8db052a
PHPStan
barw4 Oct 24, 2024
c0a09bf
Applied review remarks
barw4 Nov 4, 2024
44bcf9e
Applied review remark
barw4 Nov 4, 2024
7247d64
Applied review remarks
barw4 Nov 4, 2024
b2e42de
Merge branch 'main' into serializer-support
barw4 Nov 4, 2024
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
791 changes: 23 additions & 768 deletions phpstan-baseline.neon

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,31 @@

namespace Ibexa\Bundle\Rest\DependencyInjection\Compiler;

use Ibexa\Contracts\Rest\Output\ValueObjectVisitorDispatcher;
use Ibexa\Contracts\Rest\Output\ValueObjectVisitorResolver;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
* Compiler pass for the ibexa.rest.output.value_object.visitor tag.
* Maps an fully qualified class to a value object visitor.
* Maps a fully qualified class to a value object visitor.
*/
class ValueObjectVisitorPass implements CompilerPassInterface
final readonly class ValueObjectVisitorResolverPass implements CompilerPassInterface
{
public const OUTPUT_VALUE_OBJECT_VISITOR_SERVICE_TAG = 'ibexa.rest.output.value_object.visitor';
public const string OUTPUT_VALUE_OBJECT_VISITOR_SERVICE_TAG = 'ibexa.rest.output.value_object.visitor';

public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition(ValueObjectVisitorDispatcher::class)) {
if (!$container->hasDefinition(ValueObjectVisitorResolver::class)) {
return;
}

$definition = $container->getDefinition(ValueObjectVisitorDispatcher::class);
$definition = $container->getDefinition(ValueObjectVisitorResolver::class);

$taggedServiceIds = $container->findTaggedServiceIds(
self::OUTPUT_VALUE_OBJECT_VISITOR_SERVICE_TAG
);

foreach ($taggedServiceIds as $id => $attributes) {
foreach ($attributes as $attribute) {
if (!isset($attribute['type'])) {
Expand Down
1 change: 1 addition & 0 deletions src/bundle/DependencyInjection/IbexaRestExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected function loadInternal(array $mergedConfig, ContainerBuilder $container
$loader->load('input_parsers.yml');
$loader->load('security.yml');
$loader->load('default_settings.yml');
$loader->load('serializer.yaml');

$processor = new ConfigurationProcessor($container, 'ibexa.site_access.config');
$processor->mapConfigArray('rest_root_resources', $mergedConfig);
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/IbexaRestBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function build(ContainerBuilder $container): void
$container->addCompilerPass(new Compiler\InputHandlerPass());
$container->addCompilerPass(new Compiler\InputParserPass());
$container->addCompilerPass(new Compiler\OutputVisitorPass());
$container->addCompilerPass(new Compiler\ValueObjectVisitorPass());
$container->addCompilerPass(new Compiler\ValueObjectVisitorResolverPass());

if ($container->hasExtension('lexik_jwt_authentication')) {
$container->addCompilerPass(new Compiler\LexikAuthorizationHeaderBridgePass());
Expand Down
30 changes: 30 additions & 0 deletions src/bundle/Resources/config/serializer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
services:
ibexa.rest.serializer.encoder.json:
class: Symfony\Component\Serializer\Encoder\JsonEncoder
tags:
- ibexa.rest.serializer.encoder

ibexa.rest.serializer.encoder.xml:
class: Symfony\Component\Serializer\Encoder\XmlEncoder
tags:
- ibexa.rest.serializer.encoder

Ibexa\Contracts\Rest\Output\VisitorAdapterNormalizer:
arguments:
$jsonEncoder: '@ibexa.rest.serializer.encoder.json'
$xmlEncoder: '@ibexa.rest.serializer.encoder.xml'
$valueObjectVisitorResolver: '@Ibexa\Contracts\Rest\Output\ValueObjectVisitorResolver'
tags:
- { name: ibexa.rest.serializer.normalizer, priority: -1000 }

Ibexa\Rest\Output\Normalizer\JsonObjectNormalizer:
tags:
- { name: ibexa.rest.serializer.normalizer, priority: -500 }

Ibexa\Rest\Output\Normalizer\ArrayListNormalizer:
tags:
- { name: ibexa.rest.serializer.normalizer, priority: -400 }

Ibexa\Rest\Output\Normalizer\ArrayObjectNormalizer:
tags:
- { name: ibexa.rest.serializer.normalizer, priority: -400 }
24 changes: 15 additions & 9 deletions src/bundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -316,25 +316,29 @@ services:
ibexa.rest.output.visitor.json:
class: Ibexa\Contracts\Rest\Output\Visitor
arguments:
- '@Ibexa\Rest\Output\Generator\Json'
- '@Ibexa\Contracts\Rest\Output\ValueObjectVisitorDispatcher'
$generator: '@Ibexa\Rest\Output\Generator\Json'
$normalizer: '@ibexa.rest.serializer'
$encoder: '@ibexa.rest.serializer.encoder.json'
$valueObjectVisitorResolver: '@Ibexa\Contracts\Rest\Output\ValueObjectVisitorResolver'
$format: 'json'
tags:
- { name: ibexa.rest.output.visitor, regexps: ibexa.rest.output.visitor.json.regexps }

ibexa.rest.output.visitor.xml:
class: Ibexa\Contracts\Rest\Output\Visitor
arguments:
- '@Ibexa\Rest\Output\Generator\Xml'
- '@Ibexa\Contracts\Rest\Output\ValueObjectVisitorDispatcher'
$generator: '@Ibexa\Rest\Output\Generator\Xml'
$normalizer: '@ibexa.rest.serializer'
$encoder: '@ibexa.rest.serializer.encoder.xml'
$valueObjectVisitorResolver: '@Ibexa\Contracts\Rest\Output\ValueObjectVisitorResolver'
$format: 'xml'
tags:
- { name: ibexa.rest.output.visitor, regexps: ibexa.rest.output.visitor.xml.regexps }

# format output generators
Ibexa\Rest\Output\Generator\Xml:
arguments:
- '@Ibexa\Rest\Output\Generator\Xml\FieldTypeHashGenerator'
calls:
- [ setFormatOutput, [ "%kernel.debug%" ] ]
$fieldTypeHashGenerator: '@Ibexa\Rest\Output\Generator\Xml\FieldTypeHashGenerator'

Ibexa\Rest\Output\Generator\Xml\FieldTypeHashGenerator:
arguments:
Expand All @@ -359,8 +363,6 @@ services:
- { name: monolog.logger, channel: ibexa.rest }

# value objects visitors
Ibexa\Contracts\Rest\Output\ValueObjectVisitorDispatcher: ~

ibexa.rest.output.value_object_visitor.Exception.InvalidArgumentException:
class: Ibexa\Rest\Server\Output\ValueObjectVisitor\InvalidArgumentException
tags:
Expand Down Expand Up @@ -404,6 +406,10 @@ services:
arguments:
$parsingDispatcher: '@Ibexa\Contracts\Rest\Input\ParsingDispatcher'

Ibexa\Contracts\Rest\Output\ValueObjectVisitorResolverInterface: '@Ibexa\Contracts\Rest\Output\ValueObjectVisitor'

Ibexa\Contracts\Rest\Output\ValueObjectVisitorResolver: ~

Ibexa\Contracts\Rest\Input\Parser\Query\SortClause\BaseSortClauseProcessor:
abstract: true
arguments:
Expand Down
Loading
Loading