-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from matthiasnoback/improvements
Improvements
- Loading branch information
Showing
9 changed files
with
195 additions
and
82 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
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace TalisOrm; | ||
|
||
use TalisOrm\DomainEvents\EventRecordingCapabilities; | ||
use Webmozart\Assert\Assert; | ||
|
||
trait AggregateBehavior | ||
{ | ||
use EventRecordingCapabilities; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $deletedChildEntities = []; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
private $isNew = true; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $aggregateVersion = 0; | ||
|
||
public function deletedChildEntities(): array | ||
{ | ||
$deletedChildEntities = $this->deletedChildEntities; | ||
|
||
$this->deletedChildEntities = []; | ||
|
||
return $deletedChildEntities; | ||
} | ||
|
||
private function deleteChildEntity(ChildEntity $childEntity) | ||
{ | ||
$this->deletedChildEntities[] = $childEntity; | ||
} | ||
|
||
public function isNew(): bool | ||
{ | ||
return $this->isNew; | ||
} | ||
|
||
public function markAsPersisted(): void | ||
{ | ||
$this->isNew = false; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function aggregateVersion() | ||
{ | ||
return $this->aggregateVersion; | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace TalisOrm; | ||
|
||
trait ChildEntityBehavior | ||
{ | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
private $isNew = true; | ||
|
||
public function isNew(): bool | ||
{ | ||
return $this->isNew; | ||
} | ||
|
||
public function markAsPersisted(): void | ||
{ | ||
$this->isNew = false; | ||
} | ||
} |
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
Oops, something went wrong.