CLI/Webserver Setup: Prefix URL paths with '/' if missing

refs #6120
This commit is contained in:
Eric Lippmann 2014-11-13 13:47:08 +01:00
parent 36d3c3e3d5
commit 0e64a8d573
2 changed files with 12 additions and 8 deletions

View File

@ -110,8 +110,9 @@ class ConfigCommand extends Command
'The argument --root/--document-root expects a directory from which the webserver will serve files' 'The argument --root/--document-root expects a directory from which the webserver will serve files'
)); ));
} }
$webserver->setWebPath($path); $webserver
$webserver->setDocumentRoot($documentRoot); ->setDocumentRoot($documentRoot)
->setWebPath($path);
$config = $webserver->generate() . "\n"; $config = $webserver->generate() . "\n";
if (($file = $this->params->get('file')) !== null) { if (($file = $this->params->get('file')) !== null) {
if (file_exists($file) === true) { if (file_exists($file) === true) {

View File

@ -75,17 +75,20 @@ abstract class Webserver
abstract protected function getTemplate(); abstract protected function getTemplate();
/** /**
* Setter for web path * Set the URL path of Icinga Web 2
* *
* @param string $webPath * @param string $urlPath
*
* @return $this
*/ */
public function setWebPath($webPath) public function setWebPath($urlPath)
{ {
$this->webPath = $webPath; $this->webPath = '/' . ltrim(trim((string) $urlPath), '/');
return $this;
} }
/** /**
* Getter for web path * Get the URL path of Icinga Web 2
* *
* @return string * @return string
*/ */
@ -103,7 +106,7 @@ abstract class Webserver
*/ */
public function setDocumentRoot($documentRoot) public function setDocumentRoot($documentRoot)
{ {
$this->documentRoot = (string) $documentRoot; $this->documentRoot = trim((string) $documentRoot);
return $this; return $this;
} }