-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TASK: Remove hard dependency from fusion cache serialization to flows…
… property mapping
- Loading branch information
Showing
3 changed files
with
70 additions
and
10 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
Neos.Fusion/Classes/Core/Cache/FusionContextSerializer.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,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neos\Fusion\Core\Cache; | ||
|
||
use Neos\Flow\Property\PropertyMapper; | ||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; | ||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; | ||
|
||
/** | ||
* Serializer for Fusion's [at]cache.context values | ||
* | ||
* Uses the flow property mapper as implementation. | ||
* It relies on a converter being available from the context value type to string and reverse. | ||
* | ||
* {@see RuntimeContentCache::serializeContext()} | ||
* {@see RuntimeContentCache::unserializeContext()} | ||
* | ||
* @internal | ||
*/ | ||
final class FusionContextSerializer implements NormalizerInterface, DenormalizerInterface | ||
{ | ||
public function __construct( | ||
private readonly PropertyMapper $propertyMapper | ||
) { | ||
} | ||
|
||
public function denormalize(mixed $data, string $type, string $format = null, array $context = []) | ||
{ | ||
return $this->propertyMapper->convert($data, $type); | ||
} | ||
|
||
public function normalize(mixed $object, string $format = null, array $context = []) | ||
{ | ||
return $this->propertyMapper->convert($object, 'string'); | ||
} | ||
|
||
public function supportsDenormalization(mixed $data, string $type, string $format = null) | ||
{ | ||
throw new \BadMethodCallException(sprintf('Method %s is not supported.', __METHOD__), 1706978912); | ||
} | ||
|
||
public function supportsNormalization(mixed $data, string $format = null) | ||
{ | ||
throw new \BadMethodCallException(sprintf('Method %s is not supported.', __METHOD__), 1706978913); | ||
} | ||
|
||
public function getSupportedTypes(?string $format): array | ||
{ | ||
throw new \BadMethodCallException(sprintf('Method %s is not supported.', __METHOD__), 1706978914); | ||
} | ||
} |
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