661fbab3697f867391a0aa3e0d86edd058722325
[yaffs-website] / vendor / symfony / dependency-injection / Exception / ScopeCrossingInjectionException.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\DependencyInjection\Exception;
13
14 /**
15  * This exception is thrown when the a scope crossing injection is detected.
16  *
17  * @author Johannes M. Schmitt <schmittjoh@gmail.com>
18  */
19 class ScopeCrossingInjectionException extends RuntimeException
20 {
21     private $sourceServiceId;
22     private $sourceScope;
23     private $destServiceId;
24     private $destScope;
25
26     public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope, \Exception $previous = null)
27     {
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.',
32            $sourceServiceId,
33            $destServiceId,
34            $sourceServiceId,
35            $destScope,
36            $sourceScope,
37            $destScope
38         ), 0, $previous);
39
40         $this->sourceServiceId = $sourceServiceId;
41         $this->sourceScope = $sourceScope;
42         $this->destServiceId = $destServiceId;
43         $this->destScope = $destScope;
44     }
45
46     public function getSourceServiceId()
47     {
48         return $this->sourceServiceId;
49     }
50
51     public function getSourceScope()
52     {
53         return $this->sourceScope;
54     }
55
56     public function getDestServiceId()
57     {
58         return $this->destServiceId;
59     }
60
61     public function getDestScope()
62     {
63         return $this->destScope;
64     }
65 }