You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #19190 [DependencyInjection] Add support for short services configurators syntax (voronkovich)
This PR was squashed before being merged into the 3.2-dev branch (closes #19190).
Discussion
----------
[DependencyInjection] Add support for short services configurators syntax
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| License | MIT
This PR adds support for short services configurators syntax in YAML files:
```yaml
services:
app.some_service:
class: ...
# Common syntax
configurator: [ '@app.configurator', 'configure' ]
# Short syntax
configurator: 'app.configurator:configure'
Commits
-------
da2757f [DependencyInjection] Add support for short services configurators syntax
thrownewInvalidArgumentException(sprintf('The value of the "%s" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s").', $parameter, $id, $callable, substr($callable, 1)));
thrownewInvalidArgumentException(sprintf('Parameter "%s" must contain an array with two elements for service "%s" in %s. Check your YAML syntax.', $parameter, $id, $file));
363
+
}
364
+
365
+
thrownewInvalidArgumentException(sprintf('Parameter "%s" must be a string or an array for service "%s" in %s. Check your YAML syntax.', $parameter, $id, $file));
Copy file name to clipboardExpand all lines: Tests/Loader/YamlFileLoaderTest.php
+11Lines changed: 11 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -165,6 +165,17 @@ public function testLoadFactoryShortSyntax()
165
165
$this->assertEquals(array('FooBacFactory', 'createFooBar'), $services['factory_with_static_call']->getFactory(), '->load() parses the factory tag with Class::method');
$this->assertEquals(array(newReference('foo_bar_configurator'), 'configure'), $services['foo_bar']->getConfigurator(), '->load() parses the configurator tag with service:method');
176
+
$this->assertEquals(array('FooBarConfigurator', 'configureFooBar'), $services['foo_bar_with_static_call']->getConfigurator(), '->load() parses the configurator tag with Class::method');
0 commit comments