Skip to content

Commit

Permalink
Merge branch 'release/3.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsimonbennett committed Nov 30, 2016
2 parents afba369 + 3a5d7a1 commit c902c32
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 18 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

## Unreleased

#3.1.0
* Deprecated Projection interface. Will remove in next major release

#3.0.1
* Added exception for duplicate aggregate play head

#3.0.0
* Change event store to allow better production rebuilding

# 2.0.0
* Middleware on command bus
# 1.1.2

* Event Dispatcher how has priority
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
Via Composer

``` bash
$ composer require smoothphp/crqs-es-framework
$ composer require smoothphp/cqrs-es-framework
```

## Usage

* [Command Bus](src/CommandBus/readme.md)
* [Serialization](src/Serialization/README.md)

## Change log

Expand Down Expand Up @@ -58,6 +59,6 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
[link-travis]: https://travis-ci.org/SmoothPhp/CQRS-ES-Framework
[link-scrutinizer]: https://scrutinizer-ci.com/g/SmoothPhp/CQRS-ES-Framework/code-structure
[link-code-quality]: https://scrutinizer-ci.com/g/SmoothPhp/CQRS-ES-Framework
[link-downloads]: https://packagist.org/packages/SmoothPhp/CQRS-ES-Framework
[link-downloads]: https://packagist.org/packages/smoothphp/cqrs-es-framework
[link-author]: https://github.com/mrsimonbennett
[link-contributors]: ../../contributors
1 change: 1 addition & 0 deletions src/Contracts/EventDispatcher/Projection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

/**
* Interface Projection
* @deprecated No Longer Required with projection service providers
* @package SmoothPhp\Contracts\EventDispatcher
* @author Simon Bennett <simon@bennett.im>
*/
Expand Down
15 changes: 1 addition & 14 deletions src/EventDispatcher/ProjectEnabledDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace SmoothPhp\EventDispatcher;

use SmoothPhp\Contracts\EventDispatcher\EventDispatcher;
use SmoothPhp\Contracts\EventDispatcher\Projection;
use SmoothPhp\Contracts\EventDispatcher\Subscriber;

/**
Expand Down Expand Up @@ -33,9 +32,7 @@ public function dispatch($eventName, array $arguments, $runProjectionsOnly = fal
return;
}
foreach ($this->getListenersInOrder($eventName) as $listener) {
if ($this->listenerCanRun($runProjectionsOnly, $listener)) {
call_user_func_array($listener, $arguments);
}
call_user_func_array($listener, $arguments);
}
}

Expand Down Expand Up @@ -72,16 +69,6 @@ public function addSubscriber(Subscriber $subscriber)
}
}

/**
* @param $runProjectionsOnly
* @param $listener
* @return bool
*/
protected function listenerCanRun($runProjectionsOnly, $listener)
{
return !$runProjectionsOnly || (is_array($listener) && $listener[0] instanceof Projection);
}

/**
* @param $eventName
* @return array
Expand Down
46 changes: 46 additions & 0 deletions src/Serialization/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Serialization
==========

The Smooth PHP CQRS ES framework comes with a simple serializer, designed to get you started as quickly as possible. Usage of the serializer will allow you to quick convert complex DTO's to simple associative arrays.

### Examples
```php
<?php
namespace App;
use SmoothPhp\Contracts\Serialization\Serializable;

class MyDTO implements Serializable {
public function __construct(Id $id, DateTime $creationDate) {
$this->id = $id;
$this-creationDate = $creationDate;
}

// getters

public function serialize()
{
return [
'id' => (string) $this->id,
'date' => $this->creationDate->serialize(),
];
}

public static function deserialize(array $data)
{
return new static(
new Id($data['id']),
DateTime::deserialize($data['date'])
);
}
}

$dto = new App\MyDTO(new App\Id(uuid()), App\DateTime::now());

$serializer = new \SmoothPhp\Serialization\ObjectSelfSerializer;

// Store in database, job queue, etc
$serialized = $serializer->serialize($dto);

// Use in app
$object = $serializer->deserialize($serialized);
```
3 changes: 1 addition & 2 deletions tests/EventDispatcher/ProjectEnabledDispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ public function check_dispatcher_only_fires_projectable_listeners()
$dispatcher->dispatch('test', [], true);

$this->assertEquals(1, $projectionListener->runCount);
$this->assertEquals(0, $noneProjectionListener->runCount);

$this->assertEquals(1, $noneProjectionListener->runCount);

}

Expand Down

0 comments on commit c902c32

Please sign in to comment.