Commit 839be037 authored by Fabien Potencier's avatar Fabien Potencier

feature #953 Improve exception messages for mount() (Damien Walsh, themainframe)

This PR was squashed before being merged into the 2.0.x-dev branch (closes #953).

Discussion
----------

Improve exception messages for mount()

Improve the exception message if the `connect` method of a `ControllerProviderInterface` returns an invalid type.

Previously a misleading message about the arguments to `mount()` was emitted if your `connect` method did not return a `ControllerCollection`.

Commits
-------

7d6298d8 Improve exception messages for mount()
parents 1b33bd2b 7d6298d8
...@@ -466,11 +466,17 @@ class Application extends Container implements HttpKernelInterface, TerminableIn ...@@ -466,11 +466,17 @@ class Application extends Container implements HttpKernelInterface, TerminableIn
* @param ControllerCollection|ControllerProviderInterface $controllers A ControllerCollection or a ControllerProviderInterface instance * @param ControllerCollection|ControllerProviderInterface $controllers A ControllerCollection or a ControllerProviderInterface instance
* *
* @return Application * @return Application
*
* @throws \LogicException
*/ */
public function mount($prefix, $controllers) public function mount($prefix, $controllers)
{ {
if ($controllers instanceof ControllerProviderInterface) { if ($controllers instanceof ControllerProviderInterface) {
$controllers = $controllers->connect($this); $controllers = $controllers->connect($this);
if (!$controllers instanceof ControllerCollection) {
throw new \LogicException('The "connect" method of the ControllerProviderInterface must return a ControllerCollection.');
}
} }
if (!$controllers instanceof ControllerCollection) { if (!$controllers instanceof ControllerCollection) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment