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

How to upcast events with Prooph #57

Open
webdevilopers opened this issue Jan 8, 2021 · 1 comment
Open

How to upcast events with Prooph #57

webdevilopers opened this issue Jan 8, 2021 · 1 comment

Comments

@webdevilopers
Copy link
Owner

webdevilopers commented Jan 8, 2021

Came from:

Symfony DI integeration:

services:
  Prooph\EventSourcing\EventStoreIntegration\AggregateTranslator: null

  # Metadata enrichers
  Acme\Common\Infrastructure\Prooph\EventStore\IPAddressMetadataEnricher:
    tags:
      - { name: 'prooph_event_store.default.metadata_enricher' }
    arguments:
      - '@request_stack'
  
  # Upcasters
  Acme\Common\Infrastructure\Prooph\EventStore\Upcaster: ~

  Prooph\EventStore\Plugin\UpcastingPlugin:
    arguments: ['@Acme\Common\Infrastructure\Prooph\EventStore\Upcaster']
    tags:
      - { name: 'prooph_event_store.default.plugin' }

The Upcaster implementation:

<?php

namespace Acme\Common\Infrastructure\Prooph\EventStore;

use Prooph\Common\Messaging\Message;
use Prooph\EventStore\Upcasting\SingleEventUpcaster;

final class Upcaster extends SingleEventUpcaster
{
    public function upcast(Message $message): array
    {
        dd($message);
    }

    protected function canUpcast(Message $message): bool
    {
        dd(__METHOD__);
    }

    protected function doUpcast(Message $message): array
    {
        dd(__METHOD__);
    }
}

Using the class already provided by Prooph:

@webdevilopers
Copy link
Owner Author

webdevilopers commented Mar 30, 2021

Related:
prooph/event-store-symfony-bundle#73

Registered Upcaster Plugin is not recognized by Projection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant