-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
794 additions
and
419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?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\Bundle\Core\Fragment; | ||
|
||
use Ibexa\Core\MVC\Symfony\SiteAccess; | ||
use Symfony\Component\HttpKernel\Controller\ControllerReference; | ||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; | ||
use Symfony\Component\Serializer\SerializerInterface; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class SiteAccessSerializer implements SiteAccessSerializerInterface | ||
{ | ||
private SerializerInterface $serializer; | ||
|
||
public function __construct(SerializerInterface $serializer) | ||
{ | ||
$this->serializer = $serializer; | ||
} | ||
|
||
/** | ||
* @throws \JsonException | ||
*/ | ||
public function serializeSiteAccessAsControllerAttributes(SiteAccess $siteAccess, ControllerReference $controller): void | ||
{ | ||
// Serialize the SiteAccess to get it back after. @see \Ibexa\Core\MVC\Symfony\EventListener\SiteAccessMatchListener | ||
$controller->attributes['serialized_siteaccess'] = json_encode($siteAccess, JSON_THROW_ON_ERROR); | ||
$controller->attributes['serialized_siteaccess_matcher'] = $this->serializer->serialize( | ||
$siteAccess->matcher, | ||
'json', | ||
[AbstractNormalizer::IGNORED_ATTRIBUTES => ['request', 'container', 'matcherBuilder', 'connection']] | ||
); | ||
if ($siteAccess->matcher instanceof SiteAccess\Matcher\CompoundInterface) { | ||
$subMatchers = $siteAccess->matcher->getSubMatchers(); | ||
foreach ($subMatchers as $subMatcher) { | ||
$controller->attributes['serialized_siteaccess_sub_matchers'][get_class($subMatcher)] = $this->serializer->serialize( | ||
$subMatcher, | ||
'json', | ||
[AbstractNormalizer::IGNORED_ATTRIBUTES => ['request', 'container', 'matcherBuilder', 'connection']] | ||
); | ||
} | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/bundle/Core/Fragment/SiteAccessSerializerInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?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\Bundle\Core\Fragment; | ||
|
||
use Ibexa\Core\MVC\Symfony\SiteAccess; | ||
use Symfony\Component\HttpKernel\Controller\ControllerReference; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
interface SiteAccessSerializerInterface | ||
{ | ||
public function serializeSiteAccessAsControllerAttributes(SiteAccess $siteAccess, ControllerReference $controller): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
services: | ||
ibexa.core.mvc.serializer: | ||
class: Symfony\Component\Serializer\Serializer | ||
arguments: | ||
$normalizers: | ||
- '@ibexa.core.mvc.serializer.normalizer.array_denormalizer' | ||
- '@Ibexa\Core\MVC\Symfony\Component\Serializer\SiteAccessNormalizer' | ||
- '@Ibexa\Core\MVC\Symfony\Component\Serializer\MatcherDenormalizer' | ||
- '@Ibexa\Core\MVC\Symfony\Component\Serializer\CompoundMatcherNormalizer' | ||
- '@Ibexa\Core\MVC\Symfony\Component\Serializer\HostElementNormalizer' | ||
- '@Ibexa\Core\MVC\Symfony\Component\Serializer\MapNormalizer' | ||
- '@Ibexa\Core\MVC\Symfony\Component\Serializer\URITextNormalizer' | ||
- '@Ibexa\Core\MVC\Symfony\Component\Serializer\HostTextNormalizer' | ||
- '@Ibexa\Core\MVC\Symfony\Component\Serializer\RegexURINormalizer' | ||
- '@Ibexa\Core\MVC\Symfony\Component\Serializer\RegexHostNormalizer' | ||
- '@Ibexa\Core\MVC\Symfony\Component\Serializer\RegexNormalizer' | ||
- '@Ibexa\Core\MVC\Symfony\Component\Serializer\URIElementNormalizer' | ||
- '@Ibexa\Core\MVC\Symfony\Component\Serializer\SimplifiedRequestNormalizer' | ||
- '@ibexa.core.mvc.serializer.normalizer.json_serializable_normalizer' | ||
- '@ibexa.core.mvc.serializer.normalizer.property_normalizer' | ||
$encoders: | ||
- '@ibexa.core.mvc.serializer.json_encoder' | ||
|
||
Ibexa\Bundle\Core\Fragment\SiteAccessSerializer: | ||
arguments: | ||
$serializer: '@ibexa.core.mvc.serializer' | ||
|
||
Ibexa\Bundle\Core\Fragment\SiteAccessSerializerInterface: | ||
alias: Ibexa\Bundle\Core\Fragment\SiteAccessSerializer | ||
|
||
ibexa.core.mvc.serializer.json_encoder: | ||
class: Symfony\Component\Serializer\Encoder\JsonEncoder | ||
|
||
Ibexa\Core\MVC\Symfony\Component\Serializer\MatcherDenormalizer: | ||
arguments: | ||
$registry: '@Ibexa\Bundle\Core\SiteAccess\SiteAccessMatcherRegistryInterface' | ||
|
||
Ibexa\Core\MVC\Symfony\Component\Serializer\SiteAccessNormalizer: ~ | ||
|
||
Ibexa\Core\MVC\Symfony\Component\Serializer\HostElementNormalizer: ~ | ||
|
||
Ibexa\Core\MVC\Symfony\Component\Serializer\MapNormalizer: ~ | ||
|
||
Ibexa\Core\MVC\Symfony\Component\Serializer\URITextNormalizer: ~ | ||
|
||
Ibexa\Core\MVC\Symfony\Component\Serializer\HostTextNormalizer: ~ | ||
|
||
Ibexa\Core\MVC\Symfony\Component\Serializer\RegexURINormalizer: ~ | ||
|
||
Ibexa\Core\MVC\Symfony\Component\Serializer\RegexHostNormalizer: ~ | ||
|
||
Ibexa\Core\MVC\Symfony\Component\Serializer\RegexNormalizer: ~ | ||
|
||
Ibexa\Core\MVC\Symfony\Component\Serializer\URIElementNormalizer: ~ | ||
|
||
Ibexa\Core\MVC\Symfony\Component\Serializer\SimplifiedRequestNormalizer: ~ | ||
|
||
ibexa.core.mvc.serializer.normalizer.json_serializable_normalizer: | ||
class: Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer | ||
|
||
ibexa.core.mvc.serializer.normalizer.property_normalizer: | ||
class: Symfony\Component\Serializer\Normalizer\PropertyNormalizer | ||
|
||
ibexa.core.mvc.serializer.normalizer.array_denormalizer: | ||
class: Symfony\Component\Serializer\Normalizer\ArrayDenormalizer |
Oops, something went wrong.