1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace Symfony\Component\Config\Exception;
13:
14: 15: 16: 17: 18:
19: class FileLoaderLoadException extends \Exception
20: {
21: 22: 23: 24: 25: 26:
27: public function __construct($resource, $sourceResource = null, $code = null, $previous = null)
28: {
29: if (null === $sourceResource) {
30: $message = sprintf('Cannot load resource "%s".', $this->varToString($resource));
31: } else {
32: $message = sprintf('Cannot import resource "%s" from "%s".', $this->varToString($resource), $this->varToString($sourceResource));
33: }
34:
35:
36: if ('@' === $resource[0]) {
37: $parts = explode(DIRECTORY_SEPARATOR, $resource);
38: $bundle = substr($parts[0], 1);
39: $message .= ' '.sprintf('Make sure the "%s" bundle is correctly registered and loaded in the application kernel class.', $bundle);
40: }
41:
42: parent::__construct($message, $code, $previous);
43: }
44:
45: protected function varToString($var)
46: {
47: if (is_object($var)) {
48: return sprintf('Object(%s)', get_class($var));
49: }
50:
51: if (is_array($var)) {
52: $a = array();
53: foreach ($var as $k => $v) {
54: $a[] = sprintf('%s => %s', $k, $this->varToString($v));
55: }
56:
57: return sprintf("Array(%s)", implode(', ', $a));
58: }
59:
60: if (is_resource($var)) {
61: return sprintf('Resource(%s)', get_resource_type($var));
62: }
63:
64: if (null === $var) {
65: return 'null';
66: }
67:
68: if (false === $var) {
69: return 'false';
70: }
71:
72: if (true === $var) {
73: return 'true';
74: }
75:
76: return (string) $var;
77: }
78: }
79: