Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
FileLoaderLoadException.php
001 <?php
002
003 /*
004 * This file is part of the Symfony package.
005 *
006 * (c) Fabien Potencier <fabien@symfony.com>
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Symfony\Component\Config\Exception;
013
014 /**
015 * Exception class for when a resource cannot be loaded or imported.
016 *
017 * @author Ryan Weaver <ryan@thatsquality.com>
018 */
019 class FileLoaderLoadException extends \Exception
020 {
021 /**
022 * @param string $resource The resource that could not be imported
023 * @param string $sourceResource The original resource importing the new resource
024 * @param int $code The error code
025 * @param \Exception $previous A previous exception
026 * @param string $type The type of resource
027 */
028 public function __construct($resource, $sourceResource = null, $code = null, $previous = null, $type = null)
029 {
030 $message = '';
031 if ($previous) {
032 // Include the previous exception, to help the user see what might be the underlying cause
033
034 // Trim the trailing period of the previous message. We only want 1 period remove so no rtrim...
035 if ('.' === substr($previous->getMessage(), -1)) {
036 $trimmedMessage = substr($previous->getMessage(), 0, -1);
037 $message .= sprintf('%s', $trimmedMessage).' in ';
038 } else {
039 $message .= sprintf('%s', $previous->getMessage()).' in ';
040 }
041 $message .= $resource.' ';
042
043 // show tweaked trace to complete the human readable sentence
044 if (null === $sourceResource) {
045 $message .= sprintf('(which is loaded in resource "%s")', $this->varToString($resource));
046 } else {
047 $message .= sprintf('(which is being imported from "%s")', $this->varToString($sourceResource));
048 }
049 $message .= '.';
050
051 // if there's no previous message, present it the default way
052 } elseif (null === $sourceResource) {
053 $message .= sprintf('Cannot load resource "%s".', $this->varToString($resource));
054 } else {
055 $message .= sprintf('Cannot import resource "%s" from "%s".', $this->varToString($resource), $this->varToString($sourceResource));
056 }
057
058 // Is the resource located inside a bundle?
059 if ('@' === $resource[0]) {
060 $parts = explode(\DIRECTORY_SEPARATOR, $resource);
061 $bundle = substr($parts[0], 1);
062 $message .= sprintf(' Make sure the "%s" bundle is correctly registered and loaded in the application kernel class.', $bundle);
063 $message .= sprintf(' If the bundle is registered, make sure the bundle path "%s" is not empty.', $resource);
064 } elseif (null !== $type) {
065 // maybe there is no loader for this specific type
066 if ('annotation' === $type) {
067 $message .= ' Make sure annotations are installed and enabled.';
068 } else {
069 $message .= sprintf(' Make sure there is a loader supporting the "%s" type.', $type);
070 }
071 }
072
073 parent::__construct($message, $code, $previous);
074 }
075
076 protected function varToString($var)
077 {
078 if (\is_object($var)) {
079 return sprintf('Object(%s)', \get_class($var));
080 }
081
082 if (\is_array($var)) {
083 $a = [];
084 foreach ($var as $k => $v) {
085 $a[] = sprintf('%s => %s', $k, $this->varToString($v));
086 }
087
088 return sprintf('Array(%s)', implode(', ', $a));
089 }
090
091 if (\is_resource($var)) {
092 return sprintf('Resource(%s)', get_resource_type($var));
093 }
094
095 if (null === $var) {
096 return 'null';
097 }
098
099 if (false === $var) {
100 return 'false';
101 }
102
103 if (true === $var) {
104 return 'true';
105 }
106
107 return (string) $var;
108 }
109 }
110