Skip to content

Instantly share code, notes, and snippets.

@mlebkowski
Created April 1, 2016 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlebkowski/1a89eb522e83775d340b3d96a8e01f23 to your computer and use it in GitHub Desktop.
Save mlebkowski/1a89eb522e83775d340b3d96a8e01f23 to your computer and use it in GitHub Desktop.
Implementing strategy backend using nassau/registry-compiler
#
# Convert this configuration value to a container parameter: %foobar.api_strategy%
#
foobar:
api_strategy: readonly
services:
foobar.api.strategy:
class: 'FoobarBundle\Service\Api\StrategyApiService'
public: false
arguments:
- '@foobar.api.strategy.collection'
calls:
- [ 'setStrategy', [ '%foobar.api_strategy%' ] ]
#
# See: https://github.com/mlebkowski/registry-compiler - automatically collect services using tags
#
foobar.api.strategy.collection:
class: 'Doctrine\Common\Collections\ArrayCollection'
public: false
tags:
- name: nassau.registry # magic!
tag: foobar.service.strategy_api_service
order: indexed
alias_field: strategy
class: 'FoobarBundle\Service\Api\ApiServiceInterface'
foobar.service.api_service.strategy.logger:
class: 'FoobarBundle\Service\Api\LoggingApiService'
public: false
arguments: [ "@foobar.service.api_service.backend", "@logger" ]
tags:
- name: foobar.service.strategy_api_service
strategy: default
fobar.service.api_service.strategy.readonly:
public: false
class: 'FoobarBundle\Service\Api\ReadOnlyApiService'
arguments: [ "@foobar.service.api_service.strategy.logger" ]
tags:
- name: foobar.service.strategy_api_service
strategy: readonly
foobar.service.api_service.backend:
class: 'FoobarBundle\Service\Api\BackendApiService'
public: false
arguments: [ "@foobar.api.sdk" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment