Skip to content

Instantly share code, notes, and snippets.

@g-alonso
Forked from rosstuck/EventGenerator.php
Created December 31, 2015 22:43
Show Gist options
  • Save g-alonso/87a19ff4039b95cdb1c4 to your computer and use it in GitHub Desktop.
Save g-alonso/87a19ff4039b95cdb1c4 to your computer and use it in GitHub Desktop.
Simple EventGenerator trait that you might use with domain events
<?php
trait EventGenerator
{
protected $pendingEvents = array();
protected function raise($event)
{
$this->pendingEvents[] = $event;
}
public function releaseEvents()
{
$events = $this->pendingEvents;
$this->pendingEvents = array();
return $events;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment