This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/DependencyInjection
Fabien Potencier 50fe6a3c76 feature #23915 [DI] Allow get available services from service locator (Koc)
This PR was merged into the 3.4 branch.

Discussion
----------

[DI] Allow get available services from service locator

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

<!--
- Bug fixes must be submitted against the lowest branch where they apply
  (lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against the 3.4,
  legacy code removals go to the master branch.
- Please fill in this template according to the PR you're about to submit.
- Replace this comment by a description of what your PR is solving.
-->

Sometimes we are using service locators and throw context specific exceptions if service not found inside it. Would be nice inform user about available services in our custom exception, like:

```php
try {
    return $this->transports->get($transport);
} catch (NotFoundExceptionInterface $e) {
    $availableTransports = method_exists($e, 'getAlternatives') ? $e->getAlternatives() : [];

    throw TransportNotFoundException::create($transport, $availableTransports, $e);
}
```

Commits
-------

4993b1c14c Allow to get alternatives when ServiceNotFoundException occurs.
2017-08-18 14:05:45 +02:00
..
Argument [DependencyInjection] Support local binding 2017-08-09 11:26:25 +02:00
Compiler Merge branch '3.3' into 3.4 2017-08-17 15:38:59 +02:00
Config Merge branch '3.2' into 3.3 2017-06-02 11:51:43 +02:00
Dumper [DI] Rererence parameter arrays when possible 2017-08-17 11:23:46 +02:00
Exception Allow to get alternatives when ServiceNotFoundException occurs. 2017-08-17 15:22:42 +03:00
Extension [DI] Don't instantiate unexisting reflection class 2017-02-16 15:59:55 +01:00
LazyProxy [DI][ProxyManager] Pass the factory code to execute to DumperInterface::getProxyFactoryCode() 2017-07-27 19:12:50 +02:00
Loader feature #22187 [DependencyInjection] Support local binding (GuilhemN) 2017-08-09 11:26:28 +02:00
ParameterBag [DI] Fix reading env vars from fastcgi params 2017-08-16 16:07:29 +02:00
Tests feature #23915 [DI] Allow get available services from service locator (Koc) 2017-08-18 14:05:45 +02:00
.gitignore
Alias.php [DI] Enhance DX by throwing instead of triggering a deprecation notice 2017-03-28 08:18:44 +02:00
CHANGELOG.md feature #23712 [DependencyInjection] Deprecate autowiring service auto-registration (GuilhemN) 2017-08-03 11:15:05 +02:00
ChildDefinition.php Merge branch '3.3' into 3.4 2017-08-10 09:07:17 +02:00
composer.json minor #22913 [Yaml] Deprecate tags using colon (GuilhemN) 2017-08-04 15:29:48 +02:00
Container.php Merge branch '3.3' into 3.4 2017-08-17 15:38:59 +02:00
ContainerAwareInterface.php [DI] Clean a phpdoc 2015-11-04 19:12:53 +01:00
ContainerAwareTrait.php Merge branch '2.3' into 2.7 2015-11-04 19:50:51 +01:00
ContainerBuilder.php Merge branch '3.3' into 3.4 2017-08-17 15:38:59 +02:00
ContainerInterface.php Implement PSR-11 2017-02-02 08:42:59 +01:00
Definition.php Merge branch '3.3' into 3.4 2017-08-15 15:32:22 +02:00
DefinitionDecorator.php [DI] Fix Cannot declare class ...\DefinitionDecorator, because the name is already in use 2017-05-07 11:42:51 +02:00
ExpressionLanguage.php [DI] Fix using private services in expressions 2017-07-25 13:50:49 +02:00
ExpressionLanguageProvider.php [DI] Fix using private services in expressions 2017-07-25 13:50:49 +02:00
LICENSE updated LICENSE year 2017-01-02 12:30:00 -08:00
Parameter.php [DependencyInjection] fix phpDoc 2016-04-11 16:45:49 +02:00
phpunit.xml.dist fail when detecting risky tests 2017-04-12 09:39:27 +02:00
README.md Updated all the README files 2016-03-04 08:12:06 +01:00
Reference.php [DI] Enhance DX by throwing instead of triggering a deprecation notice 2017-03-28 08:18:44 +02:00
ResettableContainerInterface.php Implement resettable containers 2015-07-22 10:09:28 +02:00
ServiceLocator.php [DI] Remove useless state from ServiceLocator 2017-03-16 19:18:58 +01:00
ServiceSubscriberInterface.php [DI] Add and wire ServiceSubscriberInterface 2017-03-22 20:26:09 +01:00
TaggedContainerInterface.php remove api tags from code 2015-09-28 19:11:22 +02:00
TypedReference.php [DI] Restrict autowired registration to "same-vendor" namespaces 2017-04-06 11:28:30 +02:00
Variable.php [DependencyInjection] fix phpDoc 2016-04-11 16:45:49 +02:00

DependencyInjection Component

The DependencyInjection component allows you to standardize and centralize the way objects are constructed in your application.

Resources