Mercurial > hg > cmmr2012-drupal-site
comparison vendor/symfony/var-dumper/Caster/SymfonyCaster.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children | a9cd425dd02b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of the Symfony package. | |
5 * | |
6 * (c) Fabien Potencier <fabien@symfony.com> | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Symfony\Component\VarDumper\Caster; | |
13 | |
14 use Symfony\Component\HttpFoundation\Request; | |
15 use Symfony\Component\VarDumper\Cloner\Stub; | |
16 | |
17 class SymfonyCaster | |
18 { | |
19 private static $requestGetters = array( | |
20 'pathInfo' => 'getPathInfo', | |
21 'requestUri' => 'getRequestUri', | |
22 'baseUrl' => 'getBaseUrl', | |
23 'basePath' => 'getBasePath', | |
24 'method' => 'getMethod', | |
25 'format' => 'getRequestFormat', | |
26 ); | |
27 | |
28 public static function castRequest(Request $request, array $a, Stub $stub, $isNested) | |
29 { | |
30 $clone = null; | |
31 | |
32 foreach (self::$requestGetters as $prop => $getter) { | |
33 if (null === $a[Caster::PREFIX_PROTECTED.$prop]) { | |
34 if (null === $clone) { | |
35 $clone = clone $request; | |
36 } | |
37 $a[Caster::PREFIX_VIRTUAL.$prop] = $clone->{$getter}(); | |
38 } | |
39 } | |
40 | |
41 return $a; | |
42 } | |
43 } |