Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Managed to put everything into a more PEAR-like format, adding docblo…
…cks where necessary, all *without* replacing my name for Sean's.
- Loading branch information
1 parent
f1ae1ba
commit 058c19f
Showing
22 changed files
with
1,657 additions
and
980 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,64 @@ | ||
<?php | ||
/** | ||
* Example Domain Entity | ||
* Example 1 | ||
* | ||
* PHP Version 5.3 | ||
* | ||
* @author Sean Crystal <sean.crystal@gmail.com> | ||
* @copyright 2011 Sean Crystal | ||
* @license http://www.opensource.org/licenses/BSD-3-Clause | ||
* @link https://github.com/spiralout/Tracks | ||
* @category Tracks | ||
* @package Examples | ||
* @subpackage Example1 | ||
* @author Sean Crystal <sean.crystal@gmail.com> | ||
* @copyright 2011 Sean Crystal | ||
* @license http://www.opensource.org/licenses/BSD-3-Clause BSD 3-Clause | ||
* @link https://github.com/spiralout/Tracks | ||
*/ | ||
|
||
class Employee extends \Tracks\Model\Entity { | ||
/** | ||
* Example Domain Entity | ||
* | ||
* @category Tracks | ||
* @package Examples | ||
* @subpackage Example1 | ||
* @author Sean Crystal <sean.crystal@gmail.com> | ||
* @copyright 2011 Sean Crystal | ||
* @license http://www.opensource.org/licenses/BSD-3-Clause BSD 3-Clause | ||
* @link https://github.com/spiralout/Tracks | ||
*/ | ||
class Employee extends \Tracks\Model\Entity | ||
{ | ||
public function __construct($guid, $name) | ||
{ | ||
$this->guid = $guid; | ||
$this->name = $name; | ||
$this->registerEvents(); | ||
} | ||
|
||
public function __construct($guid, $name) { | ||
$this->guid = $guid; | ||
$this->name = $name; | ||
$this->registerEvents(); | ||
} | ||
public function changeTitle($title) | ||
{ | ||
$this->applyEvent(new EventEmployeeChangeTitle($this->getGuid(), $title)); | ||
} | ||
|
||
public function changeTitle($title) { | ||
$this->applyEvent(new EventEmployeeChangeTitle($this->getGuid(), $title)); | ||
} | ||
public function onChangeTitle(EventEmployeeChangeTitle $event) | ||
{ | ||
$this->position = new Position($event->title); | ||
} | ||
|
||
public function onChangeTitle(EventEmployeeChangeTitle $event) { | ||
$this->position = new Position($event->title); | ||
} | ||
|
||
private function registerEvents() { | ||
$this->registerEvent('EventEmployeeChangeTitle', 'onChangeTitle'); | ||
} | ||
private function registerEvents() | ||
{ | ||
$this->registerEvent('EventEmployeeChangeTitle', 'onChangeTitle'); | ||
} | ||
|
||
public $name; | ||
public $position; | ||
public $name; | ||
public $position; | ||
} | ||
|
||
class EventEmployeeChangeTitle extends \Tracks\Event\Base { | ||
|
||
public function __construct($guid, $title) { | ||
parent::__construct($guid); | ||
$this->title = $title; | ||
} | ||
class EventEmployeeChangeTitle extends \Tracks\Event\Base | ||
{ | ||
public function __construct($guid, $title) | ||
{ | ||
parent::__construct($guid); | ||
$this->title = $title; | ||
} | ||
|
||
public $title; | ||
public $title; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,102 @@ | ||
<?php | ||
/** | ||
* Example Domain Aggregate Root | ||
* Example 1 | ||
* | ||
* PHP Version 5.3 | ||
* | ||
* @author Sean Crystal <sean.crystal@gmail.com> | ||
* @copyright 2011 Sean Crystal | ||
* @license http://www.opensource.org/licenses/BSD-3-Clause | ||
* @link https://github.com/spiralout/Tracks | ||
* @category Tracks | ||
* @package Examples | ||
* @subpackage Example1 | ||
* @author Sean Crystal <sean.crystal@gmail.com> | ||
* @copyright 2011 Sean Crystal | ||
* @license http://www.opensource.org/licenses/BSD-3-Clause BSD 3-Clause | ||
* @link https://github.com/spiralout/Tracks | ||
*/ | ||
|
||
class Employer extends \Tracks\Model\AggregateRoot { | ||
|
||
public function __construct() { | ||
$this->employees = new \Tracks\Model\EntityList; | ||
$this->registerEvents(); | ||
} | ||
|
||
public function create($name) { | ||
$guid = \Tracks\Model\Guid::create(); | ||
$this->applyEvent(new EventEmployerCreated($guid, $name)); | ||
return $guid; | ||
} | ||
|
||
public function addNewEmployee($name, $title) { | ||
$employeeGuid = \Tracks\Model\Guid::create(); | ||
$this->applyEvent(new EventEmployeeAdded($this->getGuid(), $employeeGuid, $name)); | ||
$this->employees->find($employeeGuid)->changeTitle($title); | ||
return $employeeGuid; | ||
} | ||
|
||
public function changeEmployeeTitle(\Tracks\Model\Guid $employeeGuid, $title) { | ||
if ($employee = $this->employees->find($employeeGuid)) { | ||
$employee->changeTitle($title); | ||
} | ||
} | ||
|
||
protected function onEmployerCreated(EventEmployerCreated $event) { | ||
$this->guid = $event->guid; | ||
$this->name = $event->name; | ||
} | ||
|
||
protected function onEmployeeAdded(EventEmployeeAdded $event) { | ||
$this->employees->add(new Employee($event->employeeGuid, $event->name)); | ||
} | ||
|
||
private function registerEvents() { | ||
$this->registerEvent('EventEmployerCreated', 'onEmployerCreated'); | ||
$this->registerEvent('EventEmployeeAdded', 'onEmployeeAdded'); | ||
} | ||
|
||
public $name; | ||
public $employees; | ||
/** | ||
* Example Domain Aggregate Root | ||
* | ||
* @category Tracks | ||
* @package Examples | ||
* @subpackage Example1 | ||
* @author Sean Crystal <sean.crystal@gmail.com> | ||
* @copyright 2011 Sean Crystal | ||
* @license http://www.opensource.org/licenses/BSD-3-Clause BSD 3-Clause | ||
* @link https://github.com/spiralout/Tracks | ||
*/ | ||
class Employer extends \Tracks\Model\AggregateRoot | ||
{ | ||
public function __construct() | ||
{ | ||
$this->employees = new \Tracks\Model\EntityList; | ||
$this->registerEvents(); | ||
} | ||
|
||
public function create($name) | ||
{ | ||
$guid = \Tracks\Model\Guid::create(); | ||
$this->applyEvent(new EventEmployerCreated($guid, $name)); | ||
return $guid; | ||
} | ||
|
||
public function addNewEmployee($name, $title) | ||
{ | ||
$employeeGuid = \Tracks\Model\Guid::create(); | ||
$this->applyEvent(new EventEmployeeAdded($this->getGuid(), $employeeGuid, $name)); | ||
$this->employees->find($employeeGuid)->changeTitle($title); | ||
return $employeeGuid; | ||
} | ||
|
||
public function changeEmployeeTitle(\Tracks\Model\Guid $employeeGuid, $title) | ||
{ | ||
if ($employee = $this->employees->find($employeeGuid)) { | ||
$employee->changeTitle($title); | ||
} | ||
} | ||
|
||
protected function onEmployerCreated(EventEmployerCreated $event) | ||
{ | ||
$this->guid = $event->guid; | ||
$this->name = $event->name; | ||
} | ||
|
||
protected function onEmployeeAdded(EventEmployeeAdded $event) | ||
{ | ||
$this->employees->add(new Employee($event->employeeGuid, $event->name)); | ||
} | ||
|
||
private function registerEvents() | ||
{ | ||
$this->registerEvent('EventEmployerCreated', 'onEmployerCreated'); | ||
$this->registerEvent('EventEmployeeAdded', 'onEmployeeAdded'); | ||
} | ||
|
||
public $name; | ||
public $employees; | ||
} | ||
|
||
class EventEmployerCreated extends \Tracks\Event\Base { | ||
|
||
public function __construct($guid, $name) { | ||
parent::__construct($guid); | ||
$this->name = $name; | ||
} | ||
class EventEmployerCreated extends \Tracks\Event\Base | ||
{ | ||
public function __construct($guid, $name) | ||
{ | ||
parent::__construct($guid); | ||
$this->name = $name; | ||
} | ||
|
||
public $name; | ||
public $name; | ||
} | ||
|
||
class EventEmployeeAdded extends \Tracks\Event\Base { | ||
|
||
public function __construct(\Tracks\Model\Guid $guid, $employeeGuid, $name) { | ||
parent::__construct($guid); | ||
$this->employeeGuid = $employeeGuid; | ||
$this->name = $name; | ||
} | ||
|
||
public $employeeGuid; | ||
public $name; | ||
class EventEmployeeAdded extends \Tracks\Event\Base | ||
{ | ||
public function __construct(\Tracks\Model\Guid $guid, $employeeGuid, $name) | ||
{ | ||
parent::__construct($guid); | ||
$this->employeeGuid = $employeeGuid; | ||
$this->name = $name; | ||
} | ||
|
||
public $employeeGuid; | ||
public $name; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
<?php | ||
/** | ||
* Example Domain Value Object | ||
* Example 1 | ||
* | ||
* PHP Version 5.3 | ||
* | ||
* @author Sean Crystal <sean.crystal@gmail.com> | ||
* @copyright 2011 Sean Crystal | ||
* @license http://www.opensource.org/licenses/BSD-3-Clause | ||
* @link https://github.com/spiralout/Tracks | ||
* @category Tracks | ||
* @package Examples | ||
* @subpackage Example1 | ||
* @author Sean Crystal <sean.crystal@gmail.com> | ||
* @copyright 2011 Sean Crystal | ||
* @license http://www.opensource.org/licenses/BSD-3-Clause BSD 3-Clause | ||
* @link https://github.com/spiralout/Tracks | ||
*/ | ||
|
||
class Position { | ||
|
||
public function __construct($title) { | ||
$this->title = $title; | ||
} | ||
/** | ||
* Example Domain Value Object | ||
* | ||
* @category Tracks | ||
* @package Examples | ||
* @subpackage Example1 | ||
* @author Sean Crystal <sean.crystal@gmail.com> | ||
* @copyright 2011 Sean Crystal | ||
* @license http://www.opensource.org/licenses/BSD-3-Clause BSD 3-Clause | ||
* @link https://github.com/spiralout/Tracks | ||
*/ | ||
class Position | ||
{ | ||
public function __construct($title) | ||
{ | ||
$this->title = $title; | ||
} | ||
|
||
public $title; | ||
public $title; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,34 @@ | ||
<?php | ||
/** | ||
* Example Event Handler | ||
* Example 1 | ||
* | ||
* PHP Version 5.3 | ||
* | ||
* @author Sean Crystal <sean.crystal@gmail.com> | ||
* @copyright 2011 Sean Crystal | ||
* @license http://www.opensource.org/licenses/BSD-3-Clause | ||
* @link https://github.com/spiralout/Tracks | ||
* @category Tracks | ||
* @package Examples | ||
* @subpackage Example1 | ||
* @author Sean Crystal <sean.crystal@gmail.com> | ||
* @copyright 2011 Sean Crystal | ||
* @license http://www.opensource.org/licenses/BSD-3-Clause BSD 3-Clause | ||
* @link https://github.com/spiralout/Tracks | ||
*/ | ||
|
||
class Welcomer implements \Tracks\EventHandler\IEventHandler { | ||
/** | ||
* Example Event Handler | ||
* | ||
* @category Tracks | ||
* @package Examples | ||
* @subpackage Example1 | ||
* @author Sean Crystal <sean.crystal@gmail.com> | ||
* @copyright 2011 Sean Crystal | ||
* @license http://www.opensource.org/licenses/BSD-3-Clause BSD 3-Clause | ||
* @link https://github.com/spiralout/Tracks | ||
*/ | ||
class Welcomer implements \Tracks\EventHandler\IEventHandler | ||
{ | ||
|
||
public function execute(\Tracks\Event\Base $event) { | ||
echo "Welcome aboard, {$event->name}!\n"; | ||
} | ||
public function execute(\Tracks\Event\Base $event) | ||
{ | ||
echo "Welcome aboard, {$event->name}!\n"; | ||
} | ||
} |
Oops, something went wrong.