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 * This exception is thrown when the a scope crossing injection is detected.
17 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
19 class ScopeCrossingInjectionException 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 Crossing Injection detected: The definition "%s" references the service "%s" which belongs to another scope hierarchy. '
30 .'This service might not be available consistently. Generally, it is safer to either move the definition "%s" to scope "%s", or '
31 .'declare "%s" as a child scope of "%s". If you can be sure that the other scope is always active, you can set the reference to strict=false to get rid of this error.',
40 $this->sourceServiceId = $sourceServiceId;
41 $this->sourceScope = $sourceScope;
42 $this->destServiceId = $destServiceId;
43 $this->destScope = $destScope;
46 public function getSourceServiceId()
48 return $this->sourceServiceId;
51 public function getSourceScope()
53 return $this->sourceScope;
56 public function getDestServiceId()
58 return $this->destServiceId;
61 public function getDestScope()
63 return $this->destScope;