Drupal investigation

ScopeWideningInjectionException.php 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\DependencyInjection\Exception;
  11. /**
  12. * Thrown when a scope widening injection is detected.
  13. *
  14. * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  15. */
  16. class ScopeWideningInjectionException extends RuntimeException
  17. {
  18. private $sourceServiceId;
  19. private $sourceScope;
  20. private $destServiceId;
  21. private $destScope;
  22. public function __construct($sourceServiceId, $sourceScope, $destServiceId, $destScope, \Exception $previous = null)
  23. {
  24. parent::__construct(sprintf(
  25. 'Scope Widening Injection detected: The definition "%s" references the service "%s" which belongs to a narrower scope. '
  26. .'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. '
  27. .'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.',
  28. $sourceServiceId,
  29. $destServiceId,
  30. $sourceServiceId,
  31. $destScope,
  32. $destServiceId
  33. ), 0, $previous);
  34. $this->sourceServiceId = $sourceServiceId;
  35. $this->sourceScope = $sourceScope;
  36. $this->destServiceId = $destServiceId;
  37. $this->destScope = $destScope;
  38. }
  39. public function getSourceServiceId()
  40. {
  41. return $this->sourceServiceId;
  42. }
  43. public function getSourceScope()
  44. {
  45. return $this->sourceScope;
  46. }
  47. public function getDestServiceId()
  48. {
  49. return $this->destServiceId;
  50. }
  51. public function getDestScope()
  52. {
  53. return $this->destScope;
  54. }
  55. }