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;
* Bootstraps the application
* @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
*/
protected $systemSettings = [];
/**
* Führt alle nötigen Schritte aus, um die Seite anzuzeigen
* @inheritdoc
*/
public function run()
{
......@@ -48,22 +40,18 @@ class Application
}
/**
* Überprüft, ob die config.php existiert
* @inheritdoc
*/
public function startupChecks()
{
// Standardzeitzone festlegen
date_default_timezone_set('UTC');
// DB-Config des ACP3 laden
$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.');
}
$this->checkForDbConfig();
}
/**
* Einige Pfadkonstanten definieren
* @inheritdoc
*/
public function defineDirConstants()
{
......@@ -110,14 +98,14 @@ class Application
}
/**
* Überprüfen, ob der Wartungsmodus aktiv ist
* Checks, whether the maintenance mode is active
*/
private function _checkForMaintenanceMode()
{
$request = $this->container->get('core.request');
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');
......@@ -130,7 +118,7 @@ class Application
}
/**
* Initialisieren der anderen Klassen
* @inheritdoc
*/
public function initializeClasses()
{
......@@ -196,7 +184,7 @@ class Application
}
/**
* Gibt die Seite aus
* @inheritdoc
*/
public function outputPage()
{
......@@ -245,14 +233,6 @@ class Application
$this->container = $container;
}
/**
* @return \Symfony\Component\DependencyInjection\ContainerInterface
*/
public function getContainer()
{
return $this->container;
}
/**
* Renders an exception
*
......@@ -268,9 +248,9 @@ class Application
}
/**
* @param \Exception $exception
* @param \ACP3\Core\Redirect $redirect
* @param string $path
* @param \Exception $exception
* @param \ACP3\Core\Redirect $redirect
* @param string $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;
* Class Application
* @package ACP3\Installer
*/
class Application
class Application extends Core\AbstractApplication
{
/**
* @var ContainerBuilder
*/
private $container;
/**
* run() method of the installer
* @inheritdoc
*/
public function run()
{
......@@ -34,7 +29,7 @@ class Application
}
/**
* Define some path constants
* @inheritdoc
*/
public function defineDirConstants()
{
......@@ -60,7 +55,7 @@ class Application
}
/**
* Initializes the classes
* @inheritdoc
*/
public function initializeClasses()
{
......@@ -106,7 +101,7 @@ class Application
}
/**
* Outputs the requested page
* @inheritdoc
*/
public function outputPage()
{
......@@ -127,7 +122,7 @@ class Application
}
/**
* Checks, whether the config.yml exists
* @inheritdoc
*/
public function startupChecks()
{
......@@ -137,19 +132,8 @@ class Application
error_reporting(E_ALL);
if (defined('IN_UPDATER') === true) {
// DB-Config des ACP3 laden
$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.');
}
$this->checkForDbConfig();
}
}
/**
* @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