début d'écriture de la classe principale Thelia
Elle hérite de Symfony\Component\HttpKernel\Kernel (/!\ aux interfaces) mise en place d'un conteneur d'injection de dépendance à modifier/compléter (voir comment gérer le chargement)
This commit is contained in:
@@ -17,5 +17,7 @@ use Symfony\Component\DependencyInjection\Reference;
|
|||||||
|
|
||||||
$loader = require __DIR__ . '/autoload.php';
|
$loader = require __DIR__ . '/autoload.php';
|
||||||
|
|
||||||
|
define('THELIA_ROOT', __DIR__ .'/../');
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -2,11 +2,69 @@
|
|||||||
|
|
||||||
namespace Thelia\Core;
|
namespace Thelia\Core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Root class of Thelia
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\HttpKernel\Kernel;
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
|
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||||
|
|
||||||
|
class Thelia extends Kernel {
|
||||||
class Thelia extends Kernel{
|
|
||||||
|
|
||||||
|
const version = '0.0.1';
|
||||||
|
|
||||||
|
|
||||||
|
protected function initializeContainer(){
|
||||||
|
if(false === $container = require THELIA_ROOT . '/local/config/container.php'){
|
||||||
|
/**
|
||||||
|
* @todo redirect to installation process
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->container = $container;
|
||||||
|
$this->container->set('kernel', $this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return \Symfony\Component\DependencyInjection\ContainerBuilder
|
||||||
|
*/
|
||||||
|
public function getContainer(){
|
||||||
|
return $this->container;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return available bundle
|
||||||
|
*
|
||||||
|
* Part of Symfony\Component\HttpKernel\KernelInterface
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function registerBundles() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the container configuration
|
||||||
|
*
|
||||||
|
* part of Symfony\Component\HttpKernel\KernelInterface
|
||||||
|
*
|
||||||
|
* @param LoaderInterface $loader A LoaderInterface instance
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
public function registerContainerConfiguration(LoaderInterface $loader){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
require __DIR__ . '/core/bootstrap.php';
|
require __DIR__ . '/core/bootstrap.php';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Thelia\Core\Thelia;
|
use Thelia\Core\Thelia;
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection;
|
||||||
|
|
||||||
$env = 'debug';
|
$env = 'debug';
|
||||||
require __DIR__ . '/core/bootstrap.php';
|
require __DIR__ . '/core/bootstrap.php';
|
||||||
|
|
||||||
@@ -18,14 +20,13 @@ if( false === in_array($request->getClientIp(), $trustIp)){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//$thelia = new Thelia('dev');
|
$thelia = new Thelia('dev', true);
|
||||||
////
|
|
||||||
|
var_dump($thelia->getContainer());
|
||||||
|
|
||||||
//$response = $thelia->handle($request)->prepare($request)->send();
|
//$response = $thelia->handle($request)->prepare($request)->send();
|
||||||
////
|
//
|
||||||
//$thelia->terminate($request, $reponse);
|
//$thelia->terminate($request, $reponse);
|
||||||
|
|
||||||
Thelia::run()->send();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
25
local/config/container.php
Normal file
25
local/config/container.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
if(is_file(__DIR__ . '/config_db.php')){
|
||||||
|
require __DIR__ . '/config_db.php';
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
|
||||||
|
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
|
||||||
|
|
||||||
|
$container->register('database','Thelia\\Database\\Connection');
|
||||||
|
|
||||||
|
$container->register('http_kernel','Symfony\\Component\\HttpKernel\\HttpKernel');
|
||||||
|
|
||||||
|
$container->register('session','Symfony\\Component\\HttpFoundation\\Session\\Session');
|
||||||
|
|
||||||
|
|
||||||
|
return $container;
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user