Skip to content

Add support to allow a single handler for multiple commands #3

@acairns

Description

@acairns

I always looked at the relationship of a handler to a command as 1:1.

In practice, this can add up to a lot of thin handlers, so I like the idea of having a handler with multiple methods responsible for handling a command. For example:

class AddTaskCommand {...}

class CompleteTaskCommand {...}

class TaskCommandHandler
{
    public function addTaskCommand(AddTaskCommand $command) {...}

    public function completeTaskCommand(CompleteTaskCommand $command) {...}
}

Because of this, the shared command handler can have dependencies used to complete both commands:

class TaskCommandHandler
{
    public function __construct(TaskRepository $repository) {...}
}

At the very least, Sergeant should support something along these lines.

Started thinking about this after watching: http://www.youtube.com/watch?v=3uV3ngl1Z8g&t=32m58s

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions