* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Debug; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Routing\Exception\ExceptionInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** * Formats debug file links. * * @author Jérémy Romey */ class FileLinkFormatter implements \Serializable { private $fileLinkFormat; private $requestStack; private $baseDir; private $urlFormat; /** * @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand */ public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $urlFormat = null) { $fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); if ($fileLinkFormat && !is_array($fileLinkFormat)) { $i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: strlen($f); $fileLinkFormat = array(substr($f, 0, $i)) + preg_split('/&([^>]++)>/', substr($f, $i), -1, PREG_SPLIT_DELIM_CAPTURE); } $this->fileLinkFormat = $fileLinkFormat; $this->requestStack = $requestStack; $this->baseDir = $baseDir; $this->urlFormat = $urlFormat; } public function format($file, $line) { if ($fmt = $this->getFileLinkFormat()) { for ($i = 1; isset($fmt[$i]); ++$i) { if (0 === strpos($file, $k = $fmt[$i++])) { $file = substr_replace($file, $fmt[$i], 0, strlen($k)); break; } } return strtr($fmt[0], array('%f' => $file, '%l' => $line)); } return false; } public function serialize() { return serialize($this->getFileLinkFormat()); } public function unserialize($serialized) { if (\PHP_VERSION_ID >= 70000) { $this->fileLinkFormat = unserialize($serialized, array('allowed_classes' => false)); } else { $this->fileLinkFormat = unserialize($serialized); } } /** * @internal */ public static function generateUrlFormat(UrlGeneratorInterface $router, $routeName, $queryString) { try { return $router->generate($routeName).$queryString; } catch (ExceptionInterface $e) { return null; } } private function getFileLinkFormat() { if ($this->fileLinkFormat) { return $this->fileLinkFormat; } if ($this->requestStack && $this->baseDir && $this->urlFormat) { $request = $this->requestStack->getMasterRequest(); if ($request instanceof Request) { if ($this->urlFormat instanceof \Closure && !$this->urlFormat = \call_user_func($this->urlFormat)) { return; } return array( $request->getSchemeAndHttpHost().$request->getBaseUrl().$this->urlFormat, $this->baseDir.DIRECTORY_SEPARATOR, '', ); } } } } __halt_compiler();----SIGNATURE:----iXI/3R3Fyo5coX1d4zgPNaeUCv96hnQ9G8tZchZ3Opc/5+5NutFdB4isQ8MGX+431CskECiPKARdD+M8oa3EjsLlMQXHuSeYdcam9Dc1qOtQnkC52o7tcwAuiUknnJSSRAFvY01xyt4IneGvlf5zM1M+hHdhRKffoZFnJu7GPf9ki+kWDcFHeLNdyKVV7rfqiEjKXtwysN6UcCbwVqA+6J47z5U0tf4R4x3xAuE2p00kl6naGVZCbk/HkHCZciVC9SpSUbW+zAUSNe0KPVxzF00Psho1cbGLXqCIQD43oQfzeLaqB9MDG0Mf6ZEm1PGqeRz1N1vC7Yi5lLHqVGZA5Wk/jTfZva3wKb8iGJEJ1giLnS4ejUrh3Ftb1P7/EERynvWvP3EuZVYCuNunOvPyXvfrBjwKhMXDxZU84BRn9UrzG0PK1d7XfQ81/NDak3/YJG7tQcnIZI24C9+d7HajOj0cjBHi2Fej71e9eD8kBKGxUSyYn+K78KK3ZlsqOL7TL/vVTRGwwh1m0msQaYBrox02r7NaiswQnKkW1ByQPtQ07FDG0DnmTa9n5fZHRkDjMEDnST+78vEMG/ZL7mR2gzvP3kxe3vpL3mPvg9HcnjqYV4Qo0f+4RR4VqwBLbGan8ITJ3VmE8GRG0u8ub+tI5RXkgyXIkwVp0fTRvndctFg=----ATTACHMENT:----OTg0MDk3Nzg5Mzc2NjQ4NyAxODk0NzUyODk5NzgwNzU4IDMyNDYyNDk0NzcwNDg2OTc=