File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,24 @@ It is also a callable and a countable::
122122
123123 return $handler->handle($command);
124124
125+ Because the service locator implements the
126+ :class: `Symfony\\ Contracts\\ Service\\ ServiceCollectionInterface `, it is also
127+ a ``\Traversable ``. This allows to iterate through all registered services to
128+ apply some operations on them::
129+
130+ foreach ($this->locator as $serviceId => $service) {
131+ // access to the service directly
132+ $service->someMethod();
133+
134+ // or via the `get()` method
135+ $this->locator->get($serviceId)->someMethod();
136+ }
137+
138+ .. versionadded :: 7.1
139+
140+ The :class: `Symfony\\ Contracts\\ Service\\ ServiceCollectionInterface `
141+ was introduced in Symfony 7.1.
142+
125143Including Services
126144------------------
127145
You can’t perform that action at this time.
0 commit comments