Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/http-kernel/Debug/FileLinkFormatter.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 |
---|---|
11 | 11 |
12 namespace Symfony\Component\HttpKernel\Debug; | 12 namespace Symfony\Component\HttpKernel\Debug; |
13 | 13 |
14 use Symfony\Component\HttpFoundation\Request; | 14 use Symfony\Component\HttpFoundation\Request; |
15 use Symfony\Component\HttpFoundation\RequestStack; | 15 use Symfony\Component\HttpFoundation\RequestStack; |
16 use Symfony\Component\Routing\Exception\ExceptionInterface; | |
17 use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | |
16 | 18 |
17 /** | 19 /** |
18 * Formats debug file links. | 20 * Formats debug file links. |
19 * | 21 * |
20 * @author Jérémy Romey <jeremy@free-agent.fr> | 22 * @author Jérémy Romey <jeremy@free-agent.fr> |
24 private $fileLinkFormat; | 26 private $fileLinkFormat; |
25 private $requestStack; | 27 private $requestStack; |
26 private $baseDir; | 28 private $baseDir; |
27 private $urlFormat; | 29 private $urlFormat; |
28 | 30 |
31 /** | |
32 * @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand | |
33 */ | |
29 public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $urlFormat = null) | 34 public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $urlFormat = null) |
30 { | 35 { |
31 $fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); | 36 $fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); |
32 if ($fileLinkFormat && !is_array($fileLinkFormat)) { | 37 if ($fileLinkFormat && !is_array($fileLinkFormat)) { |
33 $i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: strlen($f); | 38 $i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: strlen($f); |
61 return serialize($this->getFileLinkFormat()); | 66 return serialize($this->getFileLinkFormat()); |
62 } | 67 } |
63 | 68 |
64 public function unserialize($serialized) | 69 public function unserialize($serialized) |
65 { | 70 { |
66 $this->fileLinkFormat = unserialize($serialized); | 71 if (\PHP_VERSION_ID >= 70000) { |
72 $this->fileLinkFormat = unserialize($serialized, array('allowed_classes' => false)); | |
73 } else { | |
74 $this->fileLinkFormat = unserialize($serialized); | |
75 } | |
76 } | |
77 | |
78 /** | |
79 * @internal | |
80 */ | |
81 public static function generateUrlFormat(UrlGeneratorInterface $router, $routeName, $queryString) | |
82 { | |
83 try { | |
84 return $router->generate($routeName).$queryString; | |
85 } catch (ExceptionInterface $e) { | |
86 return null; | |
87 } | |
67 } | 88 } |
68 | 89 |
69 private function getFileLinkFormat() | 90 private function getFileLinkFormat() |
70 { | 91 { |
71 if ($this->fileLinkFormat) { | 92 if ($this->fileLinkFormat) { |
72 return $this->fileLinkFormat; | 93 return $this->fileLinkFormat; |
73 } | 94 } |
74 if ($this->requestStack && $this->baseDir && $this->urlFormat) { | 95 if ($this->requestStack && $this->baseDir && $this->urlFormat) { |
75 $request = $this->requestStack->getMasterRequest(); | 96 $request = $this->requestStack->getMasterRequest(); |
76 if ($request instanceof Request) { | 97 if ($request instanceof Request) { |
98 if ($this->urlFormat instanceof \Closure && !$this->urlFormat = \call_user_func($this->urlFormat)) { | |
99 return; | |
100 } | |
101 | |
77 return array( | 102 return array( |
78 $request->getSchemeAndHttpHost().$request->getBaseUrl().$this->urlFormat, | 103 $request->getSchemeAndHttpHost().$request->getBaseUrl().$this->urlFormat, |
79 $this->baseDir.DIRECTORY_SEPARATOR, '', | 104 $this->baseDir.DIRECTORY_SEPARATOR, '', |
80 ); | 105 ); |
81 } | 106 } |