Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Symfony helper for implementing "Strategy" pattern

Notifications You must be signed in to change notification settings

4xxi/strategy-injector-bundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

StrategyInjectorBundle

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

About

Symfony helper for implementing "Strategy" pattern

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages