Giter Club home page Giter Club logo

chain-of-responsibility-bundle's Introduction

Chain of Responsibility Bundle

A simple bundle that helps to integrate a chain of responsibility pattern through Symfony (3.3 and onwards supported). PHP 7.1 is required.

To install it through composer, you just need to require the taluu/chain-of-responsibility-bundle package. Other methods (zip, ... and so on) are supported but you're on your own. :P

Howto

To declare a chain of responsibility, each items must implement the ChainOfResponsibility\LinkInterface interface, declaring a successor (if there is one). How the object is executed is your concern. :}

An AbstractLink is given if you want to just implement a simple Chain of Responsibility pattern. Just extend it, and just implement the doHandle method.

Once you have your chained services, all you have to do is specify them in the bundle's configuration :

chain_of_responsibility:
    my_first_chain:
        - foo_service
        - Bar\Baz
        # - ...

    my_second_chain:
        - Bar\Baz
        - baz_service
        # - ...

    # ... and so on

The items are services identifiers, so these should be declared.

Injecting Chains

In the case you would want to inject the chains, the tip of each chain is aliased to a chain_of_responsibility.chains.{{ name }} (e.g chain_of_responsibility.chains.my_first_chain). So use that identifier to inject the correct chain.

Tests

Tested through PHPUnit 6. So just run the tests and it should be all green. :}

Looking for more ?

Checks out more information on this design pattern ;

chain-of-responsibility-bundle's People

Contributors

taluu avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

chain-of-responsibility-bundle's Issues

Add a use-case

Because some fail to see the use-case of the CoR pattern

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.