4xxi/strategy-injector

This package is abandoned and no longer maintained. No replacement package was suggested.

Symfony helper for implementing "Strategy" pattern

Installs: 742

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 4

Forks: 0

Open Issues: 0

Type:symfony-bundle

1.0.1 2020-01-31 10:24 UTC

This package is auto-updated.

Last update: 2023-07-29 02:05:59 UTC


README

Installation

  1. Install component via composer
composer require 4xxi/strategy-injector
  1. Add configuration yaml into config/packages/strategy_injector.yaml with following content:
strategy_injector:
    # For using strategy injector via constructor:
    # App\Interface: App\CompositeClass

    # For using strategy injector via method call:
    # App\Interface:
    #    method: 'addStrategy'
    #    class: App\CompositeClass
    #

Usage

  1. Inject via constructor configuration example (that's injects all classes which implements interface on left side of declaration into composite class)
strategy_injector:
    App\Strategy\FooStrategyInterface: App\Strategy\CompositeFooStrategy
  1. Inject via method
strategy_injector:
    App\Strategy\FooStrategyInterface:
        method: 'addStrategy'
        class: App\Strategy\CompositeFooStrategy