Giter Club home page Giter Club logo

admiral's People

Contributors

keithmifsud avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

keithmifsud

admiral's Issues

Ability to resolve Command Handlers and dependencies

Resolver

The Resolver is a contract to be implemented by concrete resolvers providing the ability to resolve the CommandHandler class and their dependencies. Initially, one ArrayResolver will exist which takes an array of Commands and their CommandHandlers with an additional array of instantiated (or instantiatable) CommandHandler dependencies. In the future, other concrete resolvers may exist to allow for dependency injection using a framework's container so that it can also resolve interface bindings.

Dev Tasks:

  • Checkout a new feature branch named GH-3 (same as the issue key).
  • Break down the issue into units of work.
    • The resolver (it) can retrieve and instantiate a command handler for a given command.
    • It throws an exception if the handler class does not exist.
    • It throws an exception of the handler is not an instance of Handler.
    • It can inject the initialised command handler's dependencies.
    • It throws an exception if the handler's dependency cannot be injected.
  • Configure PhpUnit, including testing namespace and an extensible TestCase.
  • Configure the directory settings in PhpStorm
  • Work on the units and commit successful refactored changes.
  • Add any required usage documentation if applicable. #GH-5
  • Review and deploy to "origin"
  • Pull request and merge to "upstream".

Project Setup

Initials Setup Tasks:

  • Create new milestone and assign this issue to it.
  • Create issue labels for future categorisation.
  • Install and launch VM on local workstation.
  • Fork the repository.
  • Setup Git locally for origin and upstream.
  • Setup protected branches on GitHub.
  • Checkout new issue branch.
  • Setup up IDE.
  • Type initial Readme.
  • Initialise a Composer project.
  • Add initial dependencies to composer.json.
  • Setup package on Packagist with automated updates.
  • Document install and contribution notes in Readme. Contribution notes moved to #GH-2
  • Merge code and deploy to Packagist.
  • Review and close issue.

Ability to dispatch a Command to its Handler

The Command Bus:

Given an instance of a CommandHandlerResolver, it should be able to dispatch the command to the Handler.

Like so:

// An array of commands with handlers.
$commandsWithHandlers = [
    Domain\Command\DoSometing::class =>
        Domain\Hanlder\DoSomething::class,

    Domain\Command\DoSomethingElse::class =>
        Domain\Handler\DoSomethingElse::class,
];


$commandBus = new \SwellPhp\Admiral\CommandBus(
    new \SwellPhp\Admiral\ArrayResolver($commandsWithHandlers)
);

// Instantiates the command.
$command = new \Domain\Command\DoSometing(
    'some',
    'parameters'
);

// Dispath a command and it will be handled in the backgound.
$commandBus->dispatch($command)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.