comparison vendor/symfony/http-kernel/DataCollector/ConfigDataCollector.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children 129ea1e6d783
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
13 13
14 use Symfony\Component\HttpKernel\KernelInterface; 14 use Symfony\Component\HttpKernel\KernelInterface;
15 use Symfony\Component\HttpKernel\Kernel; 15 use Symfony\Component\HttpKernel\Kernel;
16 use Symfony\Component\HttpFoundation\Request; 16 use Symfony\Component\HttpFoundation\Request;
17 use Symfony\Component\HttpFoundation\Response; 17 use Symfony\Component\HttpFoundation\Response;
18 use Symfony\Component\VarDumper\Caster\LinkStub;
18 19
19 /** 20 /**
20 * ConfigDataCollector.
21 *
22 * @author Fabien Potencier <fabien@symfony.com> 21 * @author Fabien Potencier <fabien@symfony.com>
23 */ 22 */
24 class ConfigDataCollector extends DataCollector 23 class ConfigDataCollector extends DataCollector implements LateDataCollectorInterface
25 { 24 {
26 /** 25 /**
27 * @var KernelInterface 26 * @var KernelInterface
28 */ 27 */
29 private $kernel; 28 private $kernel;
30 private $name; 29 private $name;
31 private $version; 30 private $version;
32 31 private $hasVarDumper;
33 /** 32
34 * Constructor. 33 /**
35 *
36 * @param string $name The name of the application using the web profiler 34 * @param string $name The name of the application using the web profiler
37 * @param string $version The version of the application using the web profiler 35 * @param string $version The version of the application using the web profiler
38 */ 36 */
39 public function __construct($name = null, $version = null) 37 public function __construct($name = null, $version = null)
40 { 38 {
41 $this->name = $name; 39 $this->name = $name;
42 $this->version = $version; 40 $this->version = $version;
41 $this->hasVarDumper = class_exists(LinkStub::class);
43 } 42 }
44 43
45 /** 44 /**
46 * Sets the Kernel associated with this Request. 45 * Sets the Kernel associated with this Request.
47 *
48 * @param KernelInterface $kernel A KernelInterface instance
49 */ 46 */
50 public function setKernel(KernelInterface $kernel = null) 47 public function setKernel(KernelInterface $kernel = null)
51 { 48 {
52 $this->kernel = $kernel; 49 $this->kernel = $kernel;
53 } 50 }
65 'symfony_state' => 'unknown', 62 'symfony_state' => 'unknown',
66 'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a', 63 'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a',
67 'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a', 64 'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a',
68 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', 65 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a',
69 'php_version' => PHP_VERSION, 66 'php_version' => PHP_VERSION,
67 'php_architecture' => PHP_INT_SIZE * 8,
68 'php_intl_locale' => class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a',
69 'php_timezone' => date_default_timezone_get(),
70 'xdebug_enabled' => extension_loaded('xdebug'), 70 'xdebug_enabled' => extension_loaded('xdebug'),
71 'eaccel_enabled' => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'), 71 'apcu_enabled' => extension_loaded('apcu') && ini_get('apc.enabled'),
72 'apc_enabled' => extension_loaded('apc') && ini_get('apc.enabled'),
73 'xcache_enabled' => extension_loaded('xcache') && ini_get('xcache.cacher'),
74 'wincache_enabled' => extension_loaded('wincache') && ini_get('wincache.ocenabled'),
75 'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'), 72 'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'),
76 'bundles' => array(), 73 'bundles' => array(),
77 'sapi_name' => PHP_SAPI, 74 'sapi_name' => PHP_SAPI,
78 ); 75 );
79 76
80 if (isset($this->kernel)) { 77 if (isset($this->kernel)) {
81 foreach ($this->kernel->getBundles() as $name => $bundle) { 78 foreach ($this->kernel->getBundles() as $name => $bundle) {
82 $this->data['bundles'][$name] = $bundle->getPath(); 79 $this->data['bundles'][$name] = $this->hasVarDumper ? new LinkStub($bundle->getPath()) : $bundle->getPath();
83 } 80 }
84 81
85 $this->data['symfony_state'] = $this->determineSymfonyState(); 82 $this->data['symfony_state'] = $this->determineSymfonyState();
83 $this->data['symfony_minor_version'] = sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION);
84 $eom = \DateTime::createFromFormat('m/Y', Kernel::END_OF_MAINTENANCE);
85 $eol = \DateTime::createFromFormat('m/Y', Kernel::END_OF_LIFE);
86 $this->data['symfony_eom'] = $eom->format('F Y');
87 $this->data['symfony_eol'] = $eol->format('F Y');
86 } 88 }
89
90 if (preg_match('~^(\d+(?:\.\d+)*)(.+)?$~', $this->data['php_version'], $matches) && isset($matches[2])) {
91 $this->data['php_version'] = $matches[1];
92 $this->data['php_version_extra'] = $matches[2];
93 }
94 }
95
96 /**
97 * {@inheritdoc}
98 */
99 public function reset()
100 {
101 $this->data = array();
102 }
103
104 public function lateCollect()
105 {
106 $this->data = $this->cloneVar($this->data);
87 } 107 }
88 108
89 public function getApplicationName() 109 public function getApplicationName()
90 { 110 {
91 return $this->data['app_name']; 111 return $this->data['app_name'];
125 { 145 {
126 return $this->data['symfony_state']; 146 return $this->data['symfony_state'];
127 } 147 }
128 148
129 /** 149 /**
150 * Returns the minor Symfony version used (without patch numbers of extra
151 * suffix like "RC", "beta", etc.).
152 *
153 * @return string
154 */
155 public function getSymfonyMinorVersion()
156 {
157 return $this->data['symfony_minor_version'];
158 }
159
160 /**
161 * Returns the human redable date when this Symfony version ends its
162 * maintenance period.
163 *
164 * @return string
165 */
166 public function getSymfonyEom()
167 {
168 return $this->data['symfony_eom'];
169 }
170
171 /**
172 * Returns the human redable date when this Symfony version reaches its
173 * "end of life" and won't receive bugs or security fixes.
174 *
175 * @return string
176 */
177 public function getSymfonyEol()
178 {
179 return $this->data['symfony_eol'];
180 }
181
182 /**
130 * Gets the PHP version. 183 * Gets the PHP version.
131 * 184 *
132 * @return string The PHP version 185 * @return string The PHP version
133 */ 186 */
134 public function getPhpVersion() 187 public function getPhpVersion()
135 { 188 {
136 return $this->data['php_version']; 189 return $this->data['php_version'];
137 } 190 }
138 191
139 /** 192 /**
193 * Gets the PHP version extra part.
194 *
195 * @return string|null The extra part
196 */
197 public function getPhpVersionExtra()
198 {
199 return isset($this->data['php_version_extra']) ? $this->data['php_version_extra'] : null;
200 }
201
202 /**
203 * @return int The PHP architecture as number of bits (e.g. 32 or 64)
204 */
205 public function getPhpArchitecture()
206 {
207 return $this->data['php_architecture'];
208 }
209
210 /**
211 * @return string
212 */
213 public function getPhpIntlLocale()
214 {
215 return $this->data['php_intl_locale'];
216 }
217
218 /**
219 * @return string
220 */
221 public function getPhpTimezone()
222 {
223 return $this->data['php_timezone'];
224 }
225
226 /**
140 * Gets the application name. 227 * Gets the application name.
141 * 228 *
142 * @return string The application name 229 * @return string The application name
143 */ 230 */
144 public function getAppName() 231 public function getAppName()
175 { 262 {
176 return $this->data['xdebug_enabled']; 263 return $this->data['xdebug_enabled'];
177 } 264 }
178 265
179 /** 266 /**
180 * Returns true if EAccelerator is enabled. 267 * Returns true if APCu is enabled.
181 * 268 *
182 * @return bool true if EAccelerator is enabled, false otherwise 269 * @return bool true if APCu is enabled, false otherwise
183 */ 270 */
184 public function hasEAccelerator() 271 public function hasApcu()
185 { 272 {
186 return $this->data['eaccel_enabled']; 273 return $this->data['apcu_enabled'];
187 }
188
189 /**
190 * Returns true if APC is enabled.
191 *
192 * @return bool true if APC is enabled, false otherwise
193 */
194 public function hasApc()
195 {
196 return $this->data['apc_enabled'];
197 } 274 }
198 275
199 /** 276 /**
200 * Returns true if Zend OPcache is enabled. 277 * Returns true if Zend OPcache is enabled.
201 * 278 *
202 * @return bool true if Zend OPcache is enabled, false otherwise 279 * @return bool true if Zend OPcache is enabled, false otherwise
203 */ 280 */
204 public function hasZendOpcache() 281 public function hasZendOpcache()
205 { 282 {
206 return $this->data['zend_opcache_enabled']; 283 return $this->data['zend_opcache_enabled'];
207 }
208
209 /**
210 * Returns true if XCache is enabled.
211 *
212 * @return bool true if XCache is enabled, false otherwise
213 */
214 public function hasXCache()
215 {
216 return $this->data['xcache_enabled'];
217 }
218
219 /**
220 * Returns true if WinCache is enabled.
221 *
222 * @return bool true if WinCache is enabled, false otherwise
223 */
224 public function hasWinCache()
225 {
226 return $this->data['wincache_enabled'];
227 }
228
229 /**
230 * Returns true if any accelerator is enabled.
231 *
232 * @return bool true if any accelerator is enabled, false otherwise
233 */
234 public function hasAccelerator()
235 {
236 return $this->hasApc() || $this->hasZendOpcache() || $this->hasEAccelerator() || $this->hasXCache() || $this->hasWinCache();
237 } 284 }
238 285
239 public function getBundles() 286 public function getBundles()
240 { 287 {
241 return $this->data['bundles']; 288 return $this->data['bundles'];