4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection\Exception;
15 * Thrown when a scope widening injection is detected.
17 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
19 class ScopeWideningInjectionException extends RuntimeException
21 private $sourceServiceId;
23 private $destServiceId;
26 public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope, \Exception $previous = null)
28 parent::__construct(sprintf(
29 'Scope Widening Injection detected: The definition "%s" references the service "%s" which belongs to a narrower scope. '
30 .'Generally, it is safer to either move "%s" to scope "%s" or alternatively rely on the provider pattern by injecting the container itself, and requesting the service "%s" each time it is needed. '
31 .'In rare, special cases however that might not be necessary, then you can set the reference to strict=false to get rid of this error.',
39 $this->sourceServiceId = $sourceServiceId;
40 $this->sourceScope = $sourceScope;
41 $this->destServiceId = $destServiceId;
42 $this->destScope = $destScope;
45 public function getSourceServiceId()
47 return $this->sourceServiceId;
50 public function getSourceScope()
52 return $this->sourceScope;
55 public function getDestServiceId()
57 return $this->destServiceId;
60 public function getDestScope()
62 return $this->destScope;