Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Support wildcard dependency checks #27

Open
marc-mabe opened this issue May 12, 2022 · 0 comments
Open

Support wildcard dependency checks #27

marc-mabe opened this issue May 12, 2022 · 0 comments

Comments

@marc-mabe
Copy link

Hi,

This is a feature request to be able to support dependency checks via wildcards.

Something like this:

$phpArch->validate(new ForbiddenDependency('App\\Bus\\*\\Command', 'App\\Bus\\*\\Command'));
$phpArch->validate(new ForbiddenDependency('App\\Bus\\*\\Query', 'App\\Bus\\*\\Command'));

##Background:
I have a command/event/query bus implementation for business logic separated by business domain.
I would like to forbid commands to trigger other commands es this should be done via events.

##Example:
Wrong:

class XCommandHandler implements CommandHandler {
    public function handle(XCommand $command); void
    {
        // do whatever needs to be done

        $this->commandBus->dispatch(new OtherCommand());
    }
}

class OtherCommandHandler implements CommandHandler {
    public function handle(OtherCommand $command); void
    {
        // do whatever needs to be done
    }
}

Correct:

class XCommandHandler implements CommandHandler {
    public function handle(XCommand $command); void
    {
        // do whatever needs to be done

        $this->eventBus->dispatch(new XSucceededEvent());
    }
}

class OnXSucceededTriggerOther implements EventHandler {
    public function handle(XSucceededEvent $event); void
    {
        // do whatever needs to be done

        $this->commandBus->dispatch(new OtherCommand());
    }
}

class OtherCommandHandler implements CommandHandler {
    public function handle(OtherCommand $command); void
    {
        // do whatever needs to be done
    }
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant