4xxi / strategy-injector
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
Requires
- php: ^7.1.3
- symfony/config: ^4.0
- symfony/dependency-injection: ^4.0
- symfony/http-kernel: ^4.0
This package is auto-updated.
Last update: 2023-07-29 02:05:59 UTC
README
Installation
- Install component via composer
composer require 4xxi/strategy-injector
- 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
- 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
- Inject via method
strategy_injector: App\Strategy\FooStrategyInterface: method: 'addStrategy' class: App\Strategy\CompositeFooStrategy