annotate vendor/symfony/dependency-injection/Exception/ServiceNotFoundException.php @ 0:4c8ae668cc8c
Initial import (non-working)
author |
Chris Cannam |
date |
Wed, 29 Nov 2017 16:09:58 +0000 |
parents |
|
children |
1fec387a4317 |
rev |
line source |
Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 * This file is part of the Symfony package.
|
Chris@0
|
5 *
|
Chris@0
|
6 * (c) Fabien Potencier <fabien@symfony.com>
|
Chris@0
|
7 *
|
Chris@0
|
8 * For the full copyright and license information, please view the LICENSE
|
Chris@0
|
9 * file that was distributed with this source code.
|
Chris@0
|
10 */
|
Chris@0
|
11
|
Chris@0
|
12 namespace Symfony\Component\DependencyInjection\Exception;
|
Chris@0
|
13
|
Chris@0
|
14 /**
|
Chris@0
|
15 * This exception is thrown when a non-existent service is requested.
|
Chris@0
|
16 *
|
Chris@0
|
17 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
Chris@0
|
18 */
|
Chris@0
|
19 class ServiceNotFoundException extends InvalidArgumentException
|
Chris@0
|
20 {
|
Chris@0
|
21 private $id;
|
Chris@0
|
22 private $sourceId;
|
Chris@0
|
23
|
Chris@0
|
24 public function __construct($id, $sourceId = null, \Exception $previous = null, array $alternatives = array())
|
Chris@0
|
25 {
|
Chris@0
|
26 if (null === $sourceId) {
|
Chris@0
|
27 $msg = sprintf('You have requested a non-existent service "%s".', $id);
|
Chris@0
|
28 } else {
|
Chris@0
|
29 $msg = sprintf('The service "%s" has a dependency on a non-existent service "%s".', $sourceId, $id);
|
Chris@0
|
30 }
|
Chris@0
|
31
|
Chris@0
|
32 if ($alternatives) {
|
Chris@0
|
33 if (1 == count($alternatives)) {
|
Chris@0
|
34 $msg .= ' Did you mean this: "';
|
Chris@0
|
35 } else {
|
Chris@0
|
36 $msg .= ' Did you mean one of these: "';
|
Chris@0
|
37 }
|
Chris@0
|
38 $msg .= implode('", "', $alternatives).'"?';
|
Chris@0
|
39 }
|
Chris@0
|
40
|
Chris@0
|
41 parent::__construct($msg, 0, $previous);
|
Chris@0
|
42
|
Chris@0
|
43 $this->id = $id;
|
Chris@0
|
44 $this->sourceId = $sourceId;
|
Chris@0
|
45 }
|
Chris@0
|
46
|
Chris@0
|
47 public function getId()
|
Chris@0
|
48 {
|
Chris@0
|
49 return $this->id;
|
Chris@0
|
50 }
|
Chris@0
|
51
|
Chris@0
|
52 public function getSourceId()
|
Chris@0
|
53 {
|
Chris@0
|
54 return $this->sourceId;
|
Chris@0
|
55 }
|
Chris@0
|
56 }
|