Skip to content

Commit

Permalink
Add private service doc section in expression language
Browse files Browse the repository at this point in the history
  • Loading branch information
mcg-web committed Dec 19, 2018
1 parent 8defd3d commit 7a119fc
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/definitions/expression-language.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<?php

$vendorPrivateServiceDef = $container->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
--------------------------
Expand Down

0 comments on commit 7a119fc

Please sign in to comment.