Commit ce375489 authored by Tino Goratsch's avatar Tino Goratsch

fixed the absolute design path and covered it with unit tests

parent 6839dc50
......@@ -81,21 +81,21 @@ class Bootstrap extends AbstractBootstrap
*/
public function outputPage()
{
$this->systemSettings = $this->container->get('core.config')->getSettings(Schema::MODULE_NAME);
$this->setThemePaths();
$this->container->get('core.authentication')->authenticate();
/** @var \ACP3\Core\Http\Request $request */
$request = $this->container->get('core.http.request');
if ($this->isMaintenanceModeEnabled($request)) {
return $this->handleMaintenanceMode();
}
/** @var \ACP3\Core\Http\RedirectResponse $redirect */
$redirect = $this->container->get('core.http.redirect_response');
try {
$this->systemSettings = $this->container->get('core.config')->getSettings(Schema::MODULE_NAME);
$this->setThemePaths();
$this->container->get('core.authentication')->authenticate();
if ($this->isMaintenanceModeEnabled($request)) {
return $this->handleMaintenanceMode();
}
$response = $this->container->get('core.application.controller_action_dispatcher')->dispatch();
} catch (\ACP3\Core\Controller\Exception\ResultNotExistsException $e) {
$response = $redirect->temporary('errors/index/not_found');
......@@ -124,7 +124,7 @@ class Bootstrap extends AbstractBootstrap
->setDesignPathWeb($this->appPath->getWebRoot() . $path)
->setDesignPathInternal($this->systemSettings['design'] . '/')
->setDesignPathAbsolute(
$this->container->get('core.http.request')->getScheme()
$this->container->get('core.http.request')->getScheme() . '://'
. $this->container->get('core.http.request')->getHttpHost()
. $this->appPath->getDesignPathWeb()
);
......
......@@ -274,6 +274,10 @@ class ApplicationPath
*/
public function setDesignPathAbsolute($designPathAbsolute)
{
if (!preg_match('=^(http(s?))://=', $designPathAbsolute)) {
throw new \InvalidArgumentException('The given absolute design path (' . $designPathAbsolute . ') doesn\'t start with a valid protocol.');
}
$this->designPathAbsolute = $designPathAbsolute;
return $this;
}
......
<?php
/**
* Copyright (c) 2016 by the ACP3 Developers.
* See the LICENCE file at the top-level module directory for licencing details.
*/
namespace ACP3\Core\Test\Environment;
use ACP3\Core\Environment\ApplicationMode;
use ACP3\Core\Environment\ApplicationPath;
class ApplicationPathTest extends \PHPUnit_Framework_TestCase
{
/**
* @var ApplicationPath
*/
private $appPath;
protected function setUp()
{
$this->appPath = new ApplicationPath(ApplicationMode::DEVELOPMENT);
}
public function testSetDesignPathAbsolute()
{
$designPathAbsolute = 'http://example.com/test';
$this->appPath->setDesignPathAbsolute($designPathAbsolute);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testInvalidSetDesignPathAbsolute()
{
$invalidDesignPathAbsolute = 'http//example.com/test';
$this->appPath->setDesignPathAbsolute($invalidDesignPathAbsolute);
}
}
......@@ -69,10 +69,11 @@ class Bootstrap extends Core\Application\AbstractBootstrap
*/
public function outputPage()
{
$this->applyThemePaths();
$redirect = $this->container->get('core.http.redirect_response');
try {
$this->applyThemePaths();
$response = $this->container->get('core.application.controller_action_dispatcher')->dispatch();
} catch (Core\Controller\Exception\ControllerActionNotFoundException $e) {
$response = $redirect->temporary('errors/index/not_found');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment