From 7a119fc523eb9b1fcc9ffee87dd045216f79929b Mon Sep 17 00:00:00 2001 From: Jeremiah VALERIE Date: Wed, 19 Dec 2018 08:17:34 +0100 Subject: [PATCH] Add private service doc section in expression language --- docs/definitions/expression-language.md | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/docs/definitions/expression-language.md b/docs/definitions/expression-language.md index f1c918779..0eb3397ee 100644 --- a/docs/definitions/expression-language.md +++ b/docs/definitions/expression-language.md @@ -40,6 +40,42 @@ Expression | Description | Scope [For more details on expression syntax](http://symfony.com/doc/current/components/expression_language/syntax.html) +Private services +---------------- + +It is not possible to use private services with `service` or `serv` functions since this is equivalent to call +`get` method on the container. Private services must be tag as global variable to be accessible. + +Yaml example: + +```yaml +App\MyPrivateService: + public: false + tags: + - { name: overblog_graphql.global_variable, alias: my_private_service } +``` + +To use a vendor private services: + +```php +findDefinition(\Vendor\PrivateService::class); +$vendorPrivateServiceDef->addTag('overblog_graphql.global_variable', ['alias' => 'vendor_private_service']); +``` + +Usage: + +```yaml +MyType: + type: object + config: + fields: + name: + type: String! + resolve: '@=my_private_service.formatName(value)' +``` + Custom expression function --------------------------