Commit 1dea3545 authored by Tino Goratsch's avatar Tino Goratsch

refactored the Application classes a little bit

parent 0a55b5dc
<?php
namespace ACP3\Core;
/**
* Class AbstractApplication
* @package ACP3\Core
*/
abstract class AbstractApplication implements ApplicationInterface
{
/**
* @var \Symfony\Component\DependencyInjection\ContainerInterface
*/
protected $container;
/**
* @inheritdoc
*/
public function getContainer()
{
return $this->container;
}
/**
* Checks, whether the database configuration file exists
*/
protected function checkForDbConfig()
{
$path = ACP3_DIR . 'config.yml';
if (is_file($path) === false || filesize($path) === 0) {
exit('The ACP3 is not correctly installed. Please navigate to the <a href="' . ROOT_DIR . 'installation/">installation wizard</a> and follow its instructions.');
}
}
}
\ No newline at end of file
...@@ -20,23 +20,15 @@ use Symfony\Component\Config\FileLocator; ...@@ -20,23 +20,15 @@ use Symfony\Component\Config\FileLocator;
* Bootstraps the application * Bootstraps the application
* @package ACP3 * @package ACP3
*/ */
class Application class Application extends AbstractApplication
{ {
/**
* Contains the current ACP3 version string
*/
const VERSION = '4.0-dev';
/**
* @var ContainerInterface
*/
protected $container;
/** /**
* @var array * @var array
*/ */
protected $systemSettings = []; protected $systemSettings = [];
/** /**
* Führt alle nötigen Schritte aus, um die Seite anzuzeigen * @inheritdoc
*/ */
public function run() public function run()
{ {
...@@ -48,22 +40,18 @@ class Application ...@@ -48,22 +40,18 @@ class Application
} }
/** /**
* Überprüft, ob die config.php existiert * @inheritdoc
*/ */
public function startupChecks() public function startupChecks()
{ {
// Standardzeitzone festlegen // Standardzeitzone festlegen
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
// DB-Config des ACP3 laden $this->checkForDbConfig();
$path = ACP3_DIR . 'config.yml';
if (is_file($path) === false || filesize($path) === 0) {
exit('The ACP3 is not correctly installed. Please navigate to the <a href="' . ROOT_DIR . 'installation/">installation wizard</a> and follow its instructions.');
}
} }
/** /**
* Einige Pfadkonstanten definieren * @inheritdoc
*/ */
public function defineDirConstants() public function defineDirConstants()
{ {
...@@ -110,14 +98,14 @@ class Application ...@@ -110,14 +98,14 @@ class Application
} }
/** /**
* Überprüfen, ob der Wartungsmodus aktiv ist * Checks, whether the maintenance mode is active
*/ */
private function _checkForMaintenanceMode() private function _checkForMaintenanceMode()
{ {
$request = $this->container->get('core.request'); $request = $this->container->get('core.request');
if ((bool)$this->systemSettings['maintenance_mode'] === true && if ((bool)$this->systemSettings['maintenance_mode'] === true &&
($request->area !== 'admin' && strpos($request->query, 'users/login/') !== 0) ($request->area !== 'admin' && strpos($request->query, 'users/index/login/') !== 0)
) { ) {
header('HTTP/1.0 503 Service Unavailable'); header('HTTP/1.0 503 Service Unavailable');
...@@ -130,7 +118,7 @@ class Application ...@@ -130,7 +118,7 @@ class Application
} }
/** /**
* Initialisieren der anderen Klassen * @inheritdoc
*/ */
public function initializeClasses() public function initializeClasses()
{ {
...@@ -196,7 +184,7 @@ class Application ...@@ -196,7 +184,7 @@ class Application
} }
/** /**
* Gibt die Seite aus * @inheritdoc
*/ */
public function outputPage() public function outputPage()
{ {
...@@ -245,14 +233,6 @@ class Application ...@@ -245,14 +233,6 @@ class Application
$this->container = $container; $this->container = $container;
} }
/**
* @return \Symfony\Component\DependencyInjection\ContainerInterface
*/
public function getContainer()
{
return $this->container;
}
/** /**
* Renders an exception * Renders an exception
* *
...@@ -268,9 +248,9 @@ class Application ...@@ -268,9 +248,9 @@ class Application
} }
/** /**
* @param \Exception $exception * @param \Exception $exception
* @param \ACP3\Core\Redirect $redirect * @param \ACP3\Core\Redirect $redirect
* @param string $path * @param string $path
*/ */
protected function handleException(\Exception $exception, Redirect $redirect, $path) protected function handleException(\Exception $exception, Redirect $redirect, $path)
{ {
......
<?php
namespace ACP3\Core;
/**
* Interface ApplicationInterface
* @package ACP3\Core
*/
interface ApplicationInterface
{
/**
* Contains the current ACP3 version string
*/
const VERSION = '4.0-dev';
/**
* Executes the application bootstrapping process and outputs the requested page
*/
function run();
/**
* Performs some startup checks
*/
function startUpChecks();
/**
* Sets up the current environment
*/
function defineDirConstants();
/**
* Initializes the dependency injection container
*/
function initializeClasses();
/**
* Handle the request and output the page
*/
function outputPage();
/**
* @return \Symfony\Component\DependencyInjection\ContainerInterface
*/
function getContainer();
}
\ No newline at end of file
...@@ -11,15 +11,10 @@ use Symfony\Component\Config\FileLocator; ...@@ -11,15 +11,10 @@ use Symfony\Component\Config\FileLocator;
* Class Application * Class Application
* @package ACP3\Installer * @package ACP3\Installer
*/ */
class Application class Application extends Core\AbstractApplication
{ {
/** /**
* @var ContainerBuilder * @inheritdoc
*/
private $container;
/**
* run() method of the installer
*/ */
public function run() public function run()
{ {
...@@ -34,7 +29,7 @@ class Application ...@@ -34,7 +29,7 @@ class Application
} }
/** /**
* Define some path constants * @inheritdoc
*/ */
public function defineDirConstants() public function defineDirConstants()
{ {
...@@ -60,7 +55,7 @@ class Application ...@@ -60,7 +55,7 @@ class Application
} }
/** /**
* Initializes the classes * @inheritdoc
*/ */
public function initializeClasses() public function initializeClasses()
{ {
...@@ -106,7 +101,7 @@ class Application ...@@ -106,7 +101,7 @@ class Application
} }
/** /**
* Outputs the requested page * @inheritdoc
*/ */
public function outputPage() public function outputPage()
{ {
...@@ -127,7 +122,7 @@ class Application ...@@ -127,7 +122,7 @@ class Application
} }
/** /**
* Checks, whether the config.yml exists * @inheritdoc
*/ */
public function startupChecks() public function startupChecks()
{ {
...@@ -137,19 +132,8 @@ class Application ...@@ -137,19 +132,8 @@ class Application
error_reporting(E_ALL); error_reporting(E_ALL);
if (defined('IN_UPDATER') === true) { if (defined('IN_UPDATER') === true) {
// DB-Config des ACP3 laden $this->checkForDbConfig();
$path = ACP3_DIR . 'config.yml';
if (is_file($path) === false || filesize($path) === 0) {
exit('The ACP3 is not correctly installed. Please navigate to the <a href="' . ROOT_DIR . 'installation/">installation wizard</a> and follow its instructions.');
}
} }
} }
/**
* @return ContainerBuilder
*/
public function getServiceContainer()
{
return $this->container;
}
} }
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