lilinen / decor-bundle
Symfony bundle for LiLinen/Decor library
Installs: 15
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- lilinen/decor: dev-master
- symfony/cache: ^4.1
- symfony/config: ^4.1
- symfony/dependency-injection: ^4.1
- symfony/http-kernel: ^4.1
- symfony/yaml: ^4.1
Requires (Dev)
- phpstan/phpstan: ^0.10.5
- phpunit/phpunit: ^7.4
- squizlabs/php_codesniffer: ^3.3
This package is auto-updated.
Last update: 2024-04-29 00:08:09 UTC
README
Symfony bundle for LiLinen/Decor library
Installation
composer require lilinen/decor-bundle
Register the bundle:
<?php // config/bundles.php return [ // ... LiLinen\DecorBundle\LiLinenDecorBundle::class => ['all' => true], ];
Usage
Decorating a service
<?php // src/Service/MyService.php namespace App\Service; use App\My\Annotions\MyCustomAnnotation; class MyService { /** * @MyCustomAnnotation */ public function foo() { // ... } }
To automatically decorate the service with the decorated
tag:
# config/services.yml services: App\Service\MyService: tags: - { name: decorated }
Alternatively, the factory can be registered manually:
# config/services.yml services: App\Service\MyService: factory: 'app.decor.factory.my_service:create' app.decor.factory.my_service: parent: 'lilinen_decor.factory' autowire: true autoconfigure: false public: false arguments: $class: 'App\Service\MyService'
Registering a decorator service
Services with the lilinen_decor.decorator
tag are automatically registered. See DecoratorPass for implementation details.
For example, if you have a custom Decorator:
<?php // src/Decorator/MyCustomDecorator.php namespace App\Decorator; use LiLinen\Decor\Decorator\DecoratorInterface class MyCustomDecorator implements DecoratorInterface { //... }
# config/services.yml services: App\My\Decorator\MyCustomDecorator: tags: - { name: lilinen_decor.decorator }