File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 1313
1414namespace Streak \Domain \Command ;
1515
16+ use Streak \Domain \AggregateRoot ;
1617use Streak \Domain \Command ;
1718use Streak \Domain \Exception \CommandNotSupported ;
1819
@@ -25,6 +26,12 @@ trait Handling
2526{
2627 public function handleCommand (Command $ command ): void
2728 {
29+ if ($ command instanceof AggregateRootCommand && $ this instanceof AggregateRoot) {
30+ if (false === $ this ->aggregateRootId ()->equals ($ command ->aggregateRootId ())) {
31+ throw new CommandNotSupported ($ command );
32+ }
33+ }
34+
2835 $ reflection = new \ReflectionObject ($ this );
2936
3037 foreach ($ reflection ->getMethods () as $ method ) {
Original file line number Diff line number Diff line change 1313
1414namespace Streak \Domain \Query ;
1515
16+ use Streak \Domain \Event ;
1617use Streak \Domain \Exception \QueryNotSupported ;
1718use Streak \Domain \Query ;
1819
@@ -25,6 +26,12 @@ trait Handling
2526{
2627 public function handleQuery (Query $ query )
2728 {
29+ if ($ query instanceof EventListenerQuery && $ this instanceof Event \Listener) {
30+ if (false === $ this ->listenerId ()->equals ($ query ->listenerId ())) {
31+ throw new QueryNotSupported ($ query );
32+ }
33+ }
34+
2835 $ reflection = new \ReflectionObject ($ this );
2936
3037 foreach ($ reflection ->getMethods () as $ method ) {
You can’t perform that action at this time.
0 commit comments