beberlei/litecqrs-php — pull request #40 by mbadolato (2013-07-12 22:25:05+00:00)
Title: Raise event from aggregate root

Entity objects must either extend AggregateRoot or DomainEventProvider.
Since the usage of Doctrine and/or CRUD plugins requires the use of
AggregateRoot, there is no ability to call raise() to execute a
DomainObjectChanged notice. which means that we cannot have event
handlers listening for onEventOccured.

Using apply() does not allow us to send DomainObjectChanged objects
since it would subsequently then require an applyDomainObjectChanged
method, which is unneeded.

apply() and raise() do the exact same thing other than the apply()
method calling $this->executeEvent($event), thus it's a simple matter
to add raise() to AggregateRoot, which then enables us to do

$this->raise(new DomainObjectChanged("ChangeEmail", array("email" => $email, "oldEmail" => $this->email)));

from our Entity objects which extend AggregateRoot so that they can
use the Doctrine and CRUD plugins.