Commit 4bb5153
committed
minor #12318 Add a warning to imports order (tristanbes)
This PR was submitted for the master branch but it was squashed and merged into the 4.3 branch instead (closes #12318).
Discussion
----------
Add a warning to imports order
After spending few hours narrowing this down, I've added a note in the documentation that potentially will save time for developper;
Here's what happened to me: I got a service that didn't worked, it's because the `imports` actually imports the file *before*, so the service definition got overriden with no warning by the Glob rule (`App\:`)
This behaviour is not mentionned on the documentation;
```yaml
// services.yaml
imports:
- { resource: actions_services.yaml }
services:
# default configuration for services in *this* file
_defaults:
autowire: true
autoconfigure: true
App\:
resource: '../src/*'
exclude:
- '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
```
```yaml
// actions_services.yaml
services:
App\Actions\Company\CreateCompany:
autowire: true
autoconfigure: false
parent: 'App\Handler\AbstractHandler'
calls:
- [setClient, ['@app\GraphQL\Client']]
- [setEndpointUrlResolver, ['@app\Resolver\EndpointResolver']]
- [setSuccessor, ['@app\Actions\User\CreateUser']]
```
<img width="549" alt="tbessoussa_MacBook-Pro-dex-Tristan____workspace_importer-function" src="https://user-images.githubusercontent.com/346010/64860934-eaf0cc80-d62e-11e9-94e9-a0da67d1b366.png">
**Note that the `Calls` section is missing**
Working version:
```yaml
// services.yaml
services:
# default configuration for services in *this* file
_defaults:
autowire: true
autoconfigure: true
App\:
resource: '../src/*'
exclude:
- '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
App\Actions\Company\CreateCompany:
autowire: true
autoconfigure: false
parent: 'App\Handler\AbstractHandler'
calls:
- [setClient, ['@app\GraphQL\Client']]
- [setEndpointUrlResolver, ['@app\Resolver\EndpointResolver']]
- [setSuccessor, ['@app\Actions\User\CreateUser']]
```
<img width="712" alt="tbessoussa_MacBook-Pro-de-Tristan____workspace_importer-function" src="https://user-images.githubusercontent.com/346010/64860840-a9602180-d62e-11e9-9b3a-40e344f18e9f.png">
`Calls` is here, so the service is good to go.
Commits
-------
175b05a Add a warning to imports order1 file changed
+6
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
105 | 111 | | |
106 | 112 | | |
107 | 113 | | |
| |||
0 commit comments