2017 © Pedro Peláez
 

library chain-of-responsibility-bundle

Bundle allowing to easily implement a chain of responsibility pattern

image

taluu/chain-of-responsibility-bundle

Bundle allowing to easily implement a chain of responsibility pattern

  • Sunday, October 29, 2017
  • by Talus
  • Repository
  • 0 Watchers
  • 2 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

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., (*1)

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, (*2)

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. :}, (*3)

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., (*4)

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

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., (*6)

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., (*7)

Tests

Tested through PHPUnit 6. So just run the tests and it should be all green. :}, (*8)

Looking for more ?

Checks out more information on this design pattern ; - https://en.wikipedia.org/wiki/Chain-of-responsibility_pattern - https://github.com/domnikl/DesignPatternsPHP/tree/master/Behavioral/ChainOfResponsibilities, (*9)

The Versions

29/10 2017

dev-master

9999999-dev

Bundle allowing to easily implement a chain of responsibility pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

pattern design pattern chain of responsibility