From e3f42c7c510217e030d8a067cedb37a2a1156ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Bi=C4=8Di=C5=A1t=C4=9B?= Date: Fri, 27 Dec 2019 18:01:23 +0100 Subject: [PATCH] Tracy error in diagnostics panel fix --- .gitignore | 1 + WebLoader/Filter/CssUrlsFilter.php | 12 +++++++++--- WebLoader/Nette/Extension.php | 24 +++++++++++++++++++----- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 45bdece..4ac6e9b 100755 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ vendor composer.lock +composer.phar .idea .editorconfig diff --git a/WebLoader/Filter/CssUrlsFilter.php b/WebLoader/Filter/CssUrlsFilter.php index b985200..9f79328 100755 --- a/WebLoader/Filter/CssUrlsFilter.php +++ b/WebLoader/Filter/CssUrlsFilter.php @@ -24,7 +24,13 @@ class CssUrlsFilter private $docRoot; - public function __construct(string $docRoot, string $basePath = '/') + /** + * CssUrlsFilter constructor. + * @param string $docRoot + * @param string $basePath + * @throws InvalidArgumentException + */ + public function __construct(string $docRoot, string $basePath = '/') { $this->docRoot = Path::normalize($docRoot); @@ -51,11 +57,11 @@ public function absolutizeUrl(string $url, string $quote, string $cssFile): stri $cssFile = Path::normalize($cssFile); - $pathInfo = pathinfo($_SERVER['PHP_SELF']); + $pathInfo = pathinfo($_SERVER['PHP_SELF']); // inside document root if (strncmp($cssFile, $this->docRoot, strlen($this->docRoot)) === 0) { - $path = $this->basePath . substr(dirname($cssFile), strlen($this->docRoot)) . DIRECTORY_SEPARATOR . $url; + $path = $pathInfo['dirname'] ."/". $this->basePath . substr(dirname($cssFile), strlen($this->docRoot)) . DIRECTORY_SEPARATOR . $url; } else { // outside document root we don't know $path = $pathInfo['dirname'] ."/". $this->basePath . dirname($cssFile). DIRECTORY_SEPARATOR . $url; diff --git a/WebLoader/Nette/Extension.php b/WebLoader/Nette/Extension.php index 20ce4d4..044cb4e 100755 --- a/WebLoader/Nette/Extension.php +++ b/WebLoader/Nette/Extension.php @@ -33,7 +33,7 @@ public function getConfigSchema(): Schema 'jsDefaults' => Expect::structure([ 'checkLastModified' => Expect::bool(true), 'debug' => Expect::bool(false), - 'sourceDir' => Expect::string('%wwwDir%/js'), + 'sourceDir' => Expect::string('%wwwDir%'), 'tempDir' => Expect::string('%wwwDir%/' . self::DEFAULT_TEMP_PATH), 'tempPath' => Expect::string(self::DEFAULT_TEMP_PATH), 'files' => Expect::array(), @@ -51,7 +51,7 @@ public function getConfigSchema(): Schema 'cssDefaults' => Expect::structure([ 'checkLastModified' => Expect::bool(true), 'debug' => Expect::bool(false), - 'sourceDir' => Expect::string('%wwwDir%/css')->dynamic(), + 'sourceDir' => Expect::string('%wwwDir%')->dynamic(), 'tempDir' => Expect::string('%wwwDir%/' . self::DEFAULT_TEMP_PATH), 'tempPath' => Expect::string(self::DEFAULT_TEMP_PATH), 'files' => Expect::array(), @@ -73,7 +73,10 @@ public function getConfigSchema(): Schema } - public function loadConfiguration(): void + /** + * @throws CompilationException + */ + public function loadConfiguration(): void { $builder = $this->getContainerBuilder(); @@ -205,7 +208,13 @@ public function install(Configurator $configurator): void } - private function findFiles(array $filesConfig, string $sourceDir): array + /** + * @param array $filesConfig + * @param string $sourceDir + * @return array + * @throws FileNotFoundException + */ + private function findFiles(array $filesConfig, string $sourceDir): array { $normalizedFiles = []; @@ -250,7 +259,12 @@ private function findFiles(array $filesConfig, string $sourceDir): array } - protected function checkFileExists(string $file, string $sourceDir): void + /** + * @param string $file + * @param string $sourceDir + * @throws FileNotFoundException + */ + protected function checkFileExists(string $file, string $sourceDir): void { if (!$this->fileExists($file)) { $tmp = rtrim($sourceDir, '/\\') . DIRECTORY_SEPARATOR . $file;