Skip to content

Commit

Permalink
Merge pull request #1 from PcComponentes/feature/change-definition-al…
Browse files Browse the repository at this point in the history
…iases

Change definition aliases
  • Loading branch information
zoilomora authored Mar 18, 2020
2 parents a66bd67 + 1ae1db4 commit 00a9612
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/DependencyInjection/MappingRegistryCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

final class MappingRegistryCompilerPass implements CompilerPassInterface
{
private const PREFIX_SERVICE_ALIAS = 'mybundle.mapping_registry';
private const PREFIX_SERVICE_ALIAS = 'pccom.messenger_bundle.mapping_registry';
private const INTERFACES = [
'simple_message' => SimpleMessage::class,
'command' => Command::class,
Expand Down
24 changes: 12 additions & 12 deletions src/DependencyInjection/SerializerCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,41 @@ public function process(ContainerBuilder $container): void
$container->register(Tracker::class, Tracker::class);

$container->addDefinitions([
'mybundle.aggregate_message.serializer' => new Definition(
'pccom.messenger_bundle.aggregate_message.serializer' => new Definition(
AggregateMessageSerializer::class,
[
new Reference(Tracker::class),
new Reference('mybundle.aggregate_message.serializer.json_api_serializer'),
new Reference('mybundle.aggregate_message.serializer.stream_deserializer'),
new Reference('pccom.messenger_bundle.aggregate_message.serializer.json_api_serializer'),
new Reference('pccom.messenger_bundle.aggregate_message.serializer.stream_deserializer'),
],
),
'mybundle.aggregate_message.serializer.json_api_serializer' => new Definition(
'pccom.messenger_bundle.aggregate_message.serializer.json_api_serializer' => new Definition(
AggregateMessageJsonApiSerializable::class,
),
'mybundle.aggregate_message.serializer.stream_deserializer' => new Definition(
'pccom.messenger_bundle.aggregate_message.serializer.stream_deserializer' => new Definition(
AggregateMessageStreamDeserializer::class,
[
new Reference('mybundle.mapping_registry.aggregate_message'),
new Reference('pccom.messenger_bundle.mapping_registry.aggregate_message'),
],
),
]);

$container->addDefinitions([
'mybundle.simple_message.serializer' => new Definition(
'pccom.messenger_bundle.simple_message.serializer' => new Definition(
SimpleMessageSerializer::class,
[
new Reference(Tracker::class),
new Reference('mybundle.simple_message.serializer.json_api_serializer'),
new Reference('mybundle.simple_message.serializer.stream_deserializer'),
new Reference('pccom.messenger_bundle.simple_message.serializer.json_api_serializer'),
new Reference('pccom.messenger_bundle.simple_message.serializer.stream_deserializer'),
],
),
'mybundle.simple_message.serializer.json_api_serializer' => new Definition(
'pccom.messenger_bundle.simple_message.serializer.json_api_serializer' => new Definition(
SimpleMessageJsonApiSerializable::class,
),
'mybundle.simple_message.serializer.stream_deserializer' => new Definition(
'pccom.messenger_bundle.simple_message.serializer.stream_deserializer' => new Definition(
SimpleMessageStreamDeserializer::class,
[
new Reference('mybundle.mapping_registry.simple_message'),
new Reference('pccom.messenger_bundle.mapping_registry.simple_message'),
],
),
]);
Expand Down
9 changes: 8 additions & 1 deletion src/Serializer/AggregateMessageSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

use Assert\Assert;
use Pccomponentes\Ddd\Domain\Model\ValueObject\DateTimeValueObject;
use Pccomponentes\Ddd\Util\Message\Serialization\Exception\MessageClassNotFoundException;
use Pccomponentes\Ddd\Util\Message\Serialization\JsonApi\AggregateMessageJsonApiSerializable;
use Pccomponentes\Ddd\Util\Message\Serialization\JsonApi\AggregateMessageStream;
use Pccomponentes\Ddd\Util\Message\Serialization\JsonApi\AggregateMessageStreamDeserializer;
use PcComponentes\DddLogging\DomainTrace\Tracker;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Exception\MessageDecodingFailedException;

final class AggregateMessageSerializer extends DomainSerializer
{
Expand All @@ -32,7 +34,12 @@ public function __construct(
public function decode(array $encodedEnvelope): Envelope
{
$message = $this->streamFromEncodedEnvelope($encodedEnvelope);
$aggregateMessage = $this->deserializer->unserialize($message);

try {
$aggregateMessage = $this->deserializer->unserialize($message);
} catch (MessageClassNotFoundException $exception) {
throw new MessageDecodingFailedException();
}

$this->obtainDomainTrace($aggregateMessage, $encodedEnvelope);

Expand Down
9 changes: 8 additions & 1 deletion src/Serializer/SimpleMessageSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
namespace PcComponentes\SymfonyMessengerBundle\Serializer;

use Assert\Assert;
use Pccomponentes\Ddd\Util\Message\Serialization\Exception\MessageClassNotFoundException;
use Pccomponentes\Ddd\Util\Message\Serialization\JsonApi\SimpleMessageJsonApiSerializable;
use Pccomponentes\Ddd\Util\Message\Serialization\JsonApi\SimpleMessageStream;
use Pccomponentes\Ddd\Util\Message\Serialization\JsonApi\SimpleMessageStreamDeserializer;
use PcComponentes\DddLogging\DomainTrace\Tracker;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Exception\MessageDecodingFailedException;

final class SimpleMessageSerializer extends DomainSerializer
{
Expand All @@ -29,7 +31,12 @@ public function __construct(
public function decode(array $encodedEnvelope): Envelope
{
$message = $this->streamFromEncodedEnvelope($encodedEnvelope);
$simpleMessage = $this->deserializer->unserialize($message);

try {
$simpleMessage = $this->deserializer->unserialize($message);
} catch (MessageClassNotFoundException $exception) {
throw new MessageDecodingFailedException();
}

$this->obtainDomainTrace($simpleMessage, $encodedEnvelope);

Expand Down

0 comments on commit 00a9612

Please sign in to comment.