nigelgreenway/demander-container-plugin

A mediator for nigelgreenway/demander using league/container

v0.2.1 2016-02-19 11:36 UTC

This package is auto-updated.

Last update: 2024-11-27 15:58:18 UTC


README

Latest Version Software License Build Status

This is a plugin for NigelGreenway/Demander, a Command/Query mediator.

This implements the Mediator interfaces and allows League/Container to load a Query or Command handler.

Install

Via Composer

$ composer require nigelgreenway/demander-container-plugin

Usage

Below is a very basic example on how to use the package. More docs will be released as I get time.

$container = new Container(null, null, null);

$container->add(
    RegisteredQueryHandler::class,
    RegisteredQueryHandler::class
)->withArgument('query.test');

$container->add(
    RegisteredCommandHandler::class,
    RegisteredCommandHandler::class
)->withArgument('command.test');

$mediator = new ContainerMediator(
    $container,
    [
        RegisteredQuery::class => RegisteredQueryHandler::class,
    ],
    [
        RegisteredCommand::class => RegisteredCommandHandler::class,
    ]
);

$viewModel = $mediator->request(new RegisteredQuery());
echo $viewModel->test; // test.query

$command = $mediator->execute(new RegisteredCommand());
echo $command; // test.command

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email github+demander.security@futurepixels.co.uk instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.