summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2017-08-31 17:30:54 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2017-08-31 17:30:54 +0200
commit8c81adc8e83969e90b4c54daf4a396b1094134ff (patch)
treeae5b7e5bd826a9287d8fa34627d5b67c58e6fb22 /includes
parent0a20883aa862779b48fd2a297456c2db04cffb95 (diff)
Implemented container
Diffstat (limited to 'includes')
-rw-r--r--includes/engelsystem_provider.php20
-rw-r--r--includes/helper/internationalization_helper.php4
-rw-r--r--includes/pages/user_atom.php3
3 files changed, 19 insertions, 8 deletions
diff --git a/includes/engelsystem_provider.php b/includes/engelsystem_provider.php
index aed331d4..f3c161a6 100644
--- a/includes/engelsystem_provider.php
+++ b/includes/engelsystem_provider.php
@@ -1,11 +1,13 @@
<?php
use Engelsystem\Config\Config;
+use Engelsystem\Container\Container;
use Engelsystem\Database\Db;
use Engelsystem\Exceptions\Handler as ExceptionHandler;
use Engelsystem\Http\Request;
use Engelsystem\Renderer\HtmlEngine;
use Engelsystem\Renderer\Renderer;
+use Psr\Container\ContainerInterface;
use Symfony\Component\HttpFoundation\Session\Session;
/**
@@ -14,11 +16,20 @@ use Symfony\Component\HttpFoundation\Session\Session;
require_once __DIR__ . '/autoload.php';
+
+/**
+ * Initialize the container
+ */
+$container = Container::getInstance();
+$container->instance('container', $container);
+$container->instance(ContainerInterface::class, $container);
+
+
/**
* Load configuration
*/
$config = new Config();
-Config::setInstance($config);
+$container->instance('config', $config);
$config->set(require __DIR__ . '/../config/config.default.php');
if (file_exists(__DIR__ . '/../config/config.php')) {
@@ -37,7 +48,8 @@ date_default_timezone_set($config->get('timezone'));
* @var Request $request
*/
$request = Request::createFromGlobals();
-$request::setInstance($request);
+$container->instance('request', $request);
+
/**
* Check for maintenance
@@ -52,14 +64,15 @@ if ($config->get('maintenance')) {
* Initialize renderer
*/
$renderer = new Renderer();
+$container->instance('renderer', $renderer);
$renderer->addRenderer(new HtmlEngine());
-Renderer::setInstance($renderer);
/**
* Register error handler
*/
$errorHandler = new ExceptionHandler();
+$container->instance('error.handler', $errorHandler);
if (config('environment') == 'development') {
$errorHandler->setEnvironment(ExceptionHandler::ENV_DEVELOPMENT);
ini_set('display_errors', true);
@@ -171,6 +184,7 @@ foreach ($includeFiles as $file) {
* Init application
*/
$session = new Session();
+$container->instance('session', $session);
$session->start();
$request->setSession($session);
diff --git a/includes/helper/internationalization_helper.php b/includes/helper/internationalization_helper.php
index 131941e9..efbe5db5 100644
--- a/includes/helper/internationalization_helper.php
+++ b/includes/helper/internationalization_helper.php
@@ -1,7 +1,5 @@
<?php
-use Engelsystem\Http\Request;
-
/**
* Return currently active locale
*
@@ -65,7 +63,7 @@ function gettext_locale($locale = null)
*/
function make_langselect()
{
- $request = Request::getInstance();
+ $request = app('request');
$items = [];
foreach (config('locales') as $locale => $name) {
diff --git a/includes/pages/user_atom.php b/includes/pages/user_atom.php
index 2991bdbf..c9d9398e 100644
--- a/includes/pages/user_atom.php
+++ b/includes/pages/user_atom.php
@@ -1,7 +1,6 @@
<?php
use Engelsystem\Database\DB;
-use Engelsystem\Http\Request;
/**
* Publically available page to feed the news to feed readers
@@ -45,7 +44,7 @@ function user_atom()
*/
function make_atom_entries_from_news($news_entries)
{
- $request = Request::getInstance();
+ $request = app('request');
$html = '<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Engelsystem</title>