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 |
IniFileLoader.php
01 <?php
02
03 /*
04 * This file is part of the Symfony package.
05 *
06 * (c) Fabien Potencier <fabien@symfony.com>
07 *
08 * For the full copyright and license information, please view the LICENSE
09 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\DependencyInjection\Loader;
13
14 use Symfony\Component\Config\Util\XmlUtils;
15 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
16
17 /**
18 * IniFileLoader loads parameters from INI files.
19 *
20 * @author Fabien Potencier <fabien@symfony.com>
21 */
22 class IniFileLoader extends FileLoader
23 {
24 /**
25 * {@inheritdoc}
26 */
27 public function load($resource, $type = null)
28 {
29 $path = $this->locator->locate($resource);
30
31 $this->container->fileExists($path);
32
33 // first pass to catch parsing errors
34 $result = parse_ini_file($path, true);
35 if (false === $result || [] === $result) {
36 throw new InvalidArgumentException(sprintf('The "%s" file is not valid.', $resource));
37 }
38
39 // real raw parsing
40 $result = parse_ini_file($path, true, \INI_SCANNER_RAW);
41
42 if (isset($result['parameters']) && \is_array($result['parameters'])) {
43 foreach ($result['parameters'] as $key => $value) {
44 $this->container->setParameter($key, $this->phpize($value));
45 }
46 }
47 }
48
49 /**
50 * {@inheritdoc}
51 */
52 public function supports($resource, $type = null)
53 {
54 if (!\is_string($resource)) {
55 return false;
56 }
57
58 if (null === $type && 'ini' === pathinfo($resource, \PATHINFO_EXTENSION)) {
59 return true;
60 }
61
62 return 'ini' === $type;
63 }
64
65 /**
66 * Note that the following features are not supported:
67 * * strings with escaped quotes are not supported "foo\"bar";
68 * * string concatenation ("foo" "bar").
69 */
70 private function phpize($value)
71 {
72 // trim on the right as comments removal keep whitespaces
73 if ($value !== $v = rtrim($value)) {
74 $value = '""' === substr_replace($v, '', 1, -1) ? substr($v, 1, -1) : $v;
75 }
76 $lowercaseValue = strtolower($value);
77
78 switch (true) {
79 case \defined($value):
80 return \constant($value);
81 case 'yes' === $lowercaseValue || 'on' === $lowercaseValue:
82 return true;
83 case 'no' === $lowercaseValue || 'off' === $lowercaseValue || 'none' === $lowercaseValue:
84 return false;
85 case isset($value[1]) && (
86 ("'" === $value[0] && "'" === $value[\strlen($value) - 1]) ||
87 ('"' === $value[0] && '"' === $value[\strlen($value) - 1])
88 ):
89 // quoted string
90 return substr($value, 1, -1);
91 default:
92 return XmlUtils::phpize($value);
93 }
94 }
95 }
96