This package is abandoned and no longer maintained. No replacement package was suggested.

Some classes for basic functionality required in DDD applications.

dev-master 2018-09-26 21:13 UTC

This package is auto-updated.

Last update: 2019-08-18 18:30:27 UTC


README

These utils provide some classes for basic functionality required in DDD applications. These utils include:

  • Static Domain Event Publisher and Domain Events
  • An Event Store Repository and Doctrine Implementation
  • An Static Event Publishing Implementation
  • An Event Notification Service with a RabbitMQ Implementation
  • A Collection interface with a Doctrine Implementation (Paginatable)
  • Doctrine Transaction Middleware for Messenger Component
  • Event Persister Implementation
  • Interfaces for Application Services and Transactional Operations
  • Some Basic Value Objects
  • Problem Details Interface for Exceptions
  • Static Symfony Serializer

Dependencies:

  • ext-json: For json serialization.
  • Berbelei Assert: For validation of Value Objects.

Some Considerations

Using the Static Event Publisher

Registering Doctrine Repositories in Symfony Container

Doctrine repositories cannot be auto-injected into the container because they don't extend ServiceEntityRepository from the doctrine/doctrine-bundle package. You will have to use the old way of injecting them, calling a factory method on the Entity Manager:

    # Also, a very good idea is to alias the Interfaces to the concrete implementations
    # This is for Symfony's Autowiring Feature
    MNC\DDD\Domain\Event\EventStore:
        alias: '@app.event_store'
        
    MNC\DDD\Application\Notification\PublishedMessageTracker:
        alias: '@app.message_tracker'
    
    app.event_store:
        class: MNC\DDD\Infrastructure\Domain\DoctrineEventStore
        factory: ["@doctrine.orm.entity_manager", getRepository]
        arguments:
            - 'MNC\DDD\Domain\Event\StoredEvent'
    
    app.message_tracker:
        class: MNC\DDD\Infrastructure\Application\Notification\DoctrineMessageTracker
        factory: ["@doctrine.orm.entity_manager", getRepository]
        arguments:
            - 'MNC\DDD\Domain\Event\PublishedMessage'

You also have to register the mappings with Doctrine Bundle for this in order to work:

doctrine:
    orm:
        mappings:
            DDD:
                is_bundle: false
                type: xml
                dir: '%kernel.project_dir%/vendor/mnavarrocarter/ddd/src/Infrastructure/Persistence/Doctrine/Mapping'
                prefix: 'MNC\DDD'
                alias: DDD

Symfony Config:

This package comes with a Symfony Bundle in case you want to easily include it in your project.

doctrine:
    orm:
        mappings:
            MNCDDDBundle:
                is_bundle: true
                type: xml
                prefix: 'MNC\DDD\Domain\Event'
                alias: MNCDDD

mnc_ddd:
    implementations:
        event_store: mnc_ddd.doctrine_event_store
        notification_tracker: mnc_ddd.doctrine_notification_tracker                        
    doctrine:
        manager: doctrine.orm.entity_manager