clean code with php-cs-fixer

This commit is contained in:
Manuel Raynaud
2012-11-03 09:39:40 +01:00
parent 67fa4f6706
commit 43ec85bb1e
20 changed files with 273 additions and 322 deletions

View File

@@ -4,15 +4,12 @@ require __DIR__ . '/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Un
require __DIR__ . '/lib/Thelia/Autoload/TheliaUniversalClassLoader.php'; require __DIR__ . '/lib/Thelia/Autoload/TheliaUniversalClassLoader.php';
require __DIR__ . '/lib/Thelia/Autoload/TheliaApcUniversalClassLoader.php'; require __DIR__ . '/lib/Thelia/Autoload/TheliaApcUniversalClassLoader.php';
use Thelia\Autoload\TheliaUniversalClassLoader; use Thelia\Autoload\TheliaUniversalClassLoader;
use Thelia\Autoload\TheliaApcUniversalClassLoader; use Thelia\Autoload\TheliaApcUniversalClassLoader;
if (extension_loaded('apc') && $env == 'prod') {
if(extension_loaded('apc') && $env == 'prod'){
$loader = new TheliaApcUniversalClassLoader('Thelia'); $loader = new TheliaApcUniversalClassLoader('Thelia');
} } else {
else{
$loader = new TheliaUniversalClassLoader(); $loader = new TheliaUniversalClassLoader();
} }
@@ -24,8 +21,4 @@ foreach ($namespaces as $namespace => $directory) {
$loader->registerNamespace('Thelia', __DIR__ . '/lib/'); $loader->registerNamespace('Thelia', __DIR__ . '/lib/');
$loader->register(); $loader->register();
?>

View File

@@ -1,23 +1,18 @@
<?php <?php
if(!isset($env)){ if (!isset($env)) {
$env = 'prod'; $env = 'prod';
} }
// //
//use Symfony\Component\DependencyInjection; //use Symfony\Component\DependencyInjection;
//use Symfony\Component\DependencyInjection\Reference; //use Symfony\Component\DependencyInjection\Reference;
/** /**
* *
* @file * @file
* Functions needed for Thelia bootstrap * Functions needed for Thelia bootstrap
*/ */
$loader = require __DIR__ . '/autoload.php'; $loader = require __DIR__ . '/autoload.php';
define('THELIA_ROOT', __DIR__ .'/../'); define('THELIA_ROOT', __DIR__ .'/../');
?>

View File

@@ -7,8 +7,8 @@ namespace Thelia\Autoload;
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class TheliaApcUniversalClassLoader extends TheliaUniversalClassLoader { class TheliaApcUniversalClassLoader extends TheliaUniversalClassLoader
{
private $prefix; private $prefix;
/** /**
@@ -16,10 +16,11 @@ class TheliaApcUniversalClassLoader extends TheliaUniversalClassLoader {
* *
* Come from Symfony\Component\ClassLoader\ApcUniversalClassLoader * Come from Symfony\Component\ClassLoader\ApcUniversalClassLoader
* *
* @param string $prefix * @param string $prefix
* @throws \RuntimeException * @throws \RuntimeException
*/ */
public function __construct($prefix) { public function __construct($prefix)
{
if (!extension_loaded('apc')) { if (!extension_loaded('apc')) {
throw new \RuntimeException('Unable to use ApcUniversalClassLoader as APC is not enabled.'); throw new \RuntimeException('Unable to use ApcUniversalClassLoader as APC is not enabled.');
} }
@@ -27,7 +28,6 @@ class TheliaApcUniversalClassLoader extends TheliaUniversalClassLoader {
$this->prefix = $prefix; $this->prefix = $prefix;
} }
/** /**
* Finds a file by class name while caching lookups to APC. * Finds a file by class name while caching lookups to APC.
* *
@@ -37,7 +37,8 @@ class TheliaApcUniversalClassLoader extends TheliaUniversalClassLoader {
* *
* @return string|null The path, if found * @return string|null The path, if found
*/ */
public function findFile($class) { public function findFile($class)
{
if (false === $file = apc_fetch($this->prefix.$class)) { if (false === $file = apc_fetch($this->prefix.$class)) {
apc_store($this->prefix.$class, $file = parent::findFile($class)); apc_store($this->prefix.$class, $file = parent::findFile($class));
} }
@@ -45,4 +46,3 @@ class TheliaApcUniversalClassLoader extends TheliaUniversalClassLoader {
return $file; return $file;
} }
} }
?>

View File

@@ -15,8 +15,8 @@ use Symfony\Component\ClassLoader\UniversalClassLoader;
* *
*/ */
class TheliaUniversalClassLoader extends UniversalClassLoader{ class TheliaUniversalClassLoader extends UniversalClassLoader
{
private $directories = array(); private $directories = array();
/** /**
@@ -25,19 +25,20 @@ class TheliaUniversalClassLoader extends UniversalClassLoader{
* *
* @param string $directory * @param string $directory
*/ */
public function addDirectory($directory){ public function addDirectory($directory)
{
$this->directories[] = $directory; $this->directories[] = $directory;
} }
/** /**
* *
* add multiple path directory in an array where autoload can search files * add multiple path directory in an array where autoload can search files
* *
* @param array $directories * @param array $directories
*/ */
public function addDirectories(array $directories){ public function addDirectories(array $directories)
foreach($directories as $directory){ {
foreach ($directories as $directory) {
$this->addDirectory($directory); $this->addDirectory($directory);
} }
} }
@@ -48,7 +49,8 @@ class TheliaUniversalClassLoader extends UniversalClassLoader{
* *
* @return array an Array of directories * @return array an Array of directories
*/ */
public function getDirectories(){ public function getDirectories()
{
return $this->directories; return $this->directories;
} }
@@ -56,18 +58,18 @@ class TheliaUniversalClassLoader extends UniversalClassLoader{
* *
* Finds the path to the file where the class is defined. * Finds the path to the file where the class is defined.
* *
* @param string $class The name of the class * @param string $class The name of the class
* @return string|null The path, if found * @return string|null The path, if found
*/ */
public function findFile($class) { public function findFile($class)
{
foreach ($this->directories as $directory) {
foreach($this->directories as $directory){ if (is_file($directory.DIRECTORY_SEPARATOR.$class.".class.php")) {
if(is_file($directory.DIRECTORY_SEPARATOR.$class.".class.php")){
return $directory.DIRECTORY_SEPARATOR.$class.".class.php"; return $directory.DIRECTORY_SEPARATOR.$class.".class.php";
} }
if(is_file($directory.DIRECTORY_SEPARATOR.$class.".interface.php")){ if (is_file($directory.DIRECTORY_SEPARATOR.$class.".interface.php")) {
return $directory.DIRECTORY_SEPARATOR.$class.".interface.php"; return $directory.DIRECTORY_SEPARATOR.$class.".interface.php";
} }
@@ -77,6 +79,3 @@ class TheliaUniversalClassLoader extends UniversalClassLoader{
} }
} }
?>

View File

@@ -12,7 +12,8 @@ use Symfony\Component\HttpFoundation\Request;
* @author Manuel Raynaud <mraynadu@openstudio.fr> * @author Manuel Raynaud <mraynadu@openstudio.fr>
*/ */
class DefaultController implements NullControllerInterface{ class DefaultController implements NullControllerInterface
{
/** /**
* *
* set the default value for thelia * set the default value for thelia
@@ -21,14 +22,14 @@ class DefaultController implements NullControllerInterface{
* *
* @param \Symfony\Component\HttpFoundation\Request $request * @param \Symfony\Component\HttpFoundation\Request $request
*/ */
public function noAction(Request $request) { public function noAction(Request $request)
if($request->query->has('view') === false){ {
if ($request->query->has('view') === false) {
$fond = "index"; $fond = "index";
if($request->request->has('view')){ if ($request->request->has('view')) {
$fond = $request->request->get('view'); $fond = $request->request->get('view');
} }
$request->query->set('view', $fond); $request->query->set('view', $fond);
} }
} }
} }
?>

View File

@@ -9,12 +9,11 @@ use Symfony\Component\HttpFoundation\Request;
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
interface NullControllerInterface { interface NullControllerInterface
{
/** /**
* Nothing to do * Nothing to do
*/ */
public function noAction(Request $request); public function noAction(Request $request);
} }
?>

View File

@@ -7,24 +7,23 @@ use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
class RequestListener implements EventSubscriberInterface { class RequestListener implements EventSubscriberInterface
{
protected $container; protected $container;
public function __construct(ContainerInterface $container) { public function __construct(ContainerInterface $container)
{
$this->container = $container; $this->container = $container;
} }
public function onKernelRequest(GetResponseEvent $event){ public function onKernelRequest(GetResponseEvent $event)
{
} }
public static function getSubscribedEvents()
public static function getSubscribedEvents(){ {
return array( return array(
KernelEvents::REQUEST => array('onKernelRequest', 30) KernelEvents::REQUEST => array('onKernelRequest', 30)
); );
} }
} }
?>

View File

@@ -5,11 +5,9 @@ namespace Thelia\Core\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Thelia\Core\Template\ParserInterface; use Thelia\Core\Template\ParserInterface;
/** /**
* *
* ViewSubscriber Main class subscribing to view http response. * ViewSubscriber Main class subscribing to view http response.
@@ -19,15 +17,16 @@ use Thelia\Core\Template\ParserInterface;
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class ViewListener implements EventSubscriberInterface{ class ViewListener implements EventSubscriberInterface
{
private $parser; private $parser;
/** /**
* *
* @param \Thelia\Core\Template\ParserInterface $parser * @param \Thelia\Core\Template\ParserInterface $parser
*/ */
public function __construct(ParserInterface $parser) { public function __construct(ParserInterface $parser)
{
$this->parser = $parser; $this->parser = $parser;
} }
@@ -39,14 +38,13 @@ class ViewListener implements EventSubscriberInterface{
* *
* @param \Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event * @param \Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event
*/ */
public function onKernelView(GetResponseForControllerResultEvent $event){ public function onKernelView(GetResponseForControllerResultEvent $event)
{
$content = $this->parser->getContent(); $content = $this->parser->getContent();
if($content instanceof Response){ if ($content instanceof Response) {
$event->setResponse($content); $event->setResponse($content);
} } else {
else{
$event->setResponse(new Response($content, $this->parser->getStatus() ?: 200)); $event->setResponse(new Response($content, $this->parser->getStatus() ?: 200));
} }
} }
@@ -58,10 +56,10 @@ class ViewListener implements EventSubscriberInterface{
* *
* @return array The event names to listen to * @return array The event names to listen to
*/ */
public static function getSubscribedEvents(){ public static function getSubscribedEvents()
{
return array( return array(
KernelEvents::VIEW => array('onKernelView'), KernelEvents::VIEW => array('onKernelView'),
); );
} }
} }
?>

View File

@@ -2,11 +2,9 @@
namespace Thelia\Core\Template; namespace Thelia\Core\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Thelia\Core\Template\ParserInterface; use Thelia\Core\Template\ParserInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\EventDispatcher\EventDispatcher;
/** /**
* *
@@ -19,8 +17,8 @@ use Symfony\Component\EventDispatcher\EventDispatcher;
*/ */
class Parser implements ParserInterface { class Parser implements ParserInterface
{
const PREFIXE = 'prx'; const PREFIXE = 'prx';
const SHOW_TIME = true; const SHOW_TIME = true;
@@ -32,7 +30,8 @@ class Parser implements ParserInterface {
protected $content; protected $content;
protected $status = 200; protected $status = 200;
public function __construct(ContainerBuilder $container) { public function __construct(ContainerBuilder $container)
{
$this->container = $container; $this->container = $container;
} }
@@ -41,9 +40,11 @@ class Parser implements ParserInterface {
* This method must return a Symfony\Component\HttpFoudation\Response instance or the content of the response * This method must return a Symfony\Component\HttpFoudation\Response instance or the content of the response
* *
*/ */
public function getContent() { public function getContent()
{
$this->loadParser(); $this->loadParser();
$this->content = "toto"; $this->content = "toto";
return $this->content; return $this->content;
} }
@@ -53,7 +54,8 @@ class Parser implements ParserInterface {
* *
* @param string|Symfony\Component\HttpFoundation\Response $content * @param string|Symfony\Component\HttpFoundation\Response $content
*/ */
public function setContent($content) { public function setContent($content)
{
$this->content = $content; $this->content = $content;
} }
@@ -61,7 +63,8 @@ class Parser implements ParserInterface {
* *
* @return type the status of the response * @return type the status of the response
*/ */
public function getStatus() { public function getStatus()
{
return $this->status; return $this->status;
} }
@@ -71,13 +74,13 @@ class Parser implements ParserInterface {
* *
* @param int $status * @param int $status
*/ */
public function setStatus($status) { public function setStatus($status)
{
$this->status = $status; $this->status = $status;
} }
public function loadParser(){ public function loadParser()
{
} }
} }
?>

View File

@@ -10,8 +10,8 @@ namespace Thelia\Core\Template;
* *
*/ */
interface ParserInterface { interface ParserInterface
{
/** /**
* *
*/ */
@@ -23,5 +23,3 @@ interface ParserInterface {
public function setStatus($status); public function setStatus($status);
} }
?>

View File

@@ -11,12 +11,12 @@ namespace Thelia\Core;
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Config\Loader\LoaderInterface;
use Thelia\Core\TheliaBundle; use Thelia\Core\TheliaBundle;
class Thelia extends Kernel { class Thelia extends Kernel
{
/** /**
* Initializes the service container. * Initializes the service container.
* *
@@ -25,7 +25,8 @@ class Thelia extends Kernel {
* The cached version of the service container is used when fresh, otherwise the * The cached version of the service container is used when fresh, otherwise the
* container is built. * container is built.
*/ */
protected function initializeContainer(){ protected function initializeContainer()
{
$this->container = $this->buildContainer(); $this->container = $this->buildContainer();
$this->container->set('kernel', $this); $this->container->set('kernel', $this);
@@ -36,19 +37,17 @@ class Thelia extends Kernel {
* *
* @return ContainerBuilder The compiled service container * @return ContainerBuilder The compiled service container
*/ */
protected function buildContainer(){ protected function buildContainer()
{
$container = $this->getContainerBuilder(); $container = $this->getContainerBuilder();
foreach($this->bundles as $bundle){ foreach ($this->bundles as $bundle) {
$bundle->build($container); $bundle->build($container);
} }
return $container; return $container;
} }
/** /**
* return available bundle * return available bundle
* *
@@ -57,8 +56,8 @@ class Thelia extends Kernel {
* @return array An array of bundle instances. * @return array An array of bundle instances.
* *
*/ */
public function registerBundles() { public function registerBundles()
{
$bundles = array( $bundles = array(
/* TheliaBundle contain all the dependency injection description */ /* TheliaBundle contain all the dependency injection description */
new TheliaBundle() new TheliaBundle()
@@ -83,11 +82,10 @@ class Thelia extends Kernel {
* *
* @api * @api
*/ */
public function registerContainerConfiguration(LoaderInterface $loader){ public function registerContainerConfiguration(LoaderInterface $loader)
{
//Nothing is load here but it's possible to load container configuration here. //Nothing is load here but it's possible to load container configuration here.
//exemple in sf2 : $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); //exemple in sf2 : $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
} }
} }
?>

View File

@@ -18,8 +18,8 @@ use Symfony\Component\DependencyInjection\Scope;
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class TheliaBundle extends Bundle { class TheliaBundle extends Bundle
{
/** /**
* *
* Construct the depency injection builder * Construct the depency injection builder
@@ -27,8 +27,8 @@ class TheliaBundle extends Bundle {
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/ */
public function build(ContainerBuilder $container) { public function build(ContainerBuilder $container)
{
$container->addScope( new Scope('request')); $container->addScope( new Scope('request'));
$container->register('request', 'Symfony\Component\HttpFoundation\Request') $container->register('request', 'Symfony\Component\HttpFoundation\Request')
@@ -84,12 +84,9 @@ class TheliaBundle extends Bundle {
// DEFINE DEFAULT PARAMETER LIKE // DEFINE DEFAULT PARAMETER LIKE
/** /**
* @TODO learn about container compilation * @TODO learn about container compilation
*/ */
} }
} }
?>

View File

@@ -11,17 +11,17 @@ use Thelia\Controller\NullControllerInterface;
* *
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class DefaultMatcher implements RequestMatcherInterface{ class DefaultMatcher implements RequestMatcherInterface
{
protected $controller; protected $controller;
public function __construct(NullControllerInterface $controller) { public function __construct(NullControllerInterface $controller)
{
$this->controller = $controller; $this->controller = $controller;
} }
public function matchRequest(Request $request) { public function matchRequest(Request $request)
{
$objectInformation = new \ReflectionObject($this->controller); $objectInformation = new \ReflectionObject($this->controller);
$parameter = array( $parameter = array(
@@ -31,6 +31,3 @@ class DefaultMatcher implements RequestMatcherInterface{
return $parameter; return $parameter;
} }
} }
?>

View File

@@ -19,9 +19,8 @@ use Symfony\Component\HttpFoundation\Request;
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class TheliaMatcherCollection implements RequestMatcherInterface, RequestContextAwareInterface
class TheliaMatcherCollection implements RequestMatcherInterface, RequestContextAwareInterface { {
protected $context; protected $context;
protected $matchers = array(); protected $matchers = array();
protected $defaultMatcher; protected $defaultMatcher;
@@ -33,11 +32,11 @@ class TheliaMatcherCollection implements RequestMatcherInterface, RequestContext
* *
* Check if this constructor is needed (is RequestContext needed ? ) * Check if this constructor is needed (is RequestContext needed ? )
*/ */
public function __construct() { public function __construct()
{
$this->context = new RequestContext(); $this->context = new RequestContext();
} }
/** /**
* allow to add a matcher routing class to the matchers collection * allow to add a matcher routing class to the matchers collection
* matcher must implement RequestMatcherInterface * matcher must implement RequestMatcherInterface
@@ -45,15 +44,16 @@ class TheliaMatcherCollection implements RequestMatcherInterface, RequestContext
* priority can be fixed with $priority parameter * priority can be fixed with $priority parameter
* *
* @param RequestMatcherInterface $matcher * @param RequestMatcherInterface $matcher
* @param int $priority set the priority of the added matcher * @param int $priority set the priority of the added matcher
* *
*/ */
public function add(RequestMatcherInterface $matcher, $priority = 0){ public function add(RequestMatcherInterface $matcher, $priority = 0)
if(!is_object($matcher)){ {
if (!is_object($matcher)) {
$matcher = new $matcher(); $matcher = new $matcher();
} }
if(!isset($this->matchers[$priority])){ if (!isset($this->matchers[$priority])) {
$this->matchers[$priority] = array(); $this->matchers[$priority] = array();
} }
@@ -61,40 +61,39 @@ class TheliaMatcherCollection implements RequestMatcherInterface, RequestContext
$this->sortedMatchers = array(); $this->sortedMatchers = array();
} }
/** /**
* *
* Sort Matchers by priority * Sort Matchers by priority
* *
* @return array Array of matchers sorted by priority. * @return array Array of matchers sorted by priority.
*/ */
public function getSortedMatchers(){ public function getSortedMatchers()
if(empty($this->sortedMatchers)){ {
if (empty($this->sortedMatchers)) {
$this->sortedMatchers = $this->sortMatchers(); $this->sortedMatchers = $this->sortMatchers();
} }
return $this->sortedMatchers; return $this->sortedMatchers;
} }
/** /**
* *
* Sort the matcher by priority * Sort the matcher by priority
* *
* @return array Array of matchers sorted by priority. * @return array Array of matchers sorted by priority.
*/ */
public function sortMatchers(){ public function sortMatchers()
{
$sortedMatchers = array(); $sortedMatchers = array();
krsort($this->matchers); krsort($this->matchers);
foreach($this->matchers as $matcher){ foreach ($this->matchers as $matcher) {
$sortedMatchers = array_merge($sortedMatchers,$matcher); $sortedMatchers = array_merge($sortedMatchers,$matcher);
} }
return $sortedMatchers; return $sortedMatchers;
} }
/** /**
* Tries to match a request with a set of routes. * Tries to match a request with a set of routes.
* *
@@ -108,26 +107,24 @@ class TheliaMatcherCollection implements RequestMatcherInterface, RequestContext
* @throws ResourceNotFoundException If no matching resource could be found * @throws ResourceNotFoundException If no matching resource could be found
* @throws MethodNotAllowedException If a matching resource was found but the request method is not allowed * @throws MethodNotAllowedException If a matching resource was found but the request method is not allowed
*/ */
public function matchRequest(Request $request) { public function matchRequest(Request $request)
if(empty($this->matchers)){ {
if (empty($this->matchers)) {
throw new \InvalidArgumentException('there is no matcher added to the TheliaMatcherCollection'); throw new \InvalidArgumentException('there is no matcher added to the TheliaMatcherCollection');
} }
foreach($this->getSortedMatchers() as $matcher){ foreach ($this->getSortedMatchers() as $matcher) {
try{ try {
return $matcher->matchRequest($request); return $matcher->matchRequest($request);
} } catch (ResourceNotFoundException $e) {
catch (ResourceNotFoundException $e){
//no action, wait for next matcher //no action, wait for next matcher
} } catch (MethodNotAllowedException $e) {
catch(MethodNotAllowedException $e){
/** /**
* @todo what todo with a MethodNotAllowedException ? * @todo what todo with a MethodNotAllowedException ?
*/ */
} }
} }
throw new ResourceNotFoundException('No one matcher in this collection matched the current request'); throw new ResourceNotFoundException('No one matcher in this collection matched the current request');
} }
@@ -137,7 +134,8 @@ class TheliaMatcherCollection implements RequestMatcherInterface, RequestContext
* @param RequestContext $context The context * @param RequestContext $context The context
* *
*/ */
public function setContext(RequestContext $context){ public function setContext(RequestContext $context)
{
$this->context = $context; $this->context = $context;
} }
@@ -148,8 +146,8 @@ class TheliaMatcherCollection implements RequestMatcherInterface, RequestContext
* @return RequestContext The context * @return RequestContext The context
* *
*/ */
public function getContext(){ public function getContext()
{
return $this->context; return $this->context;
} }
} }
?>

View File

@@ -1,4 +1,3 @@
<?php <?php
require __DIR__ . '/core/bootstrap.php'; require __DIR__ . '/core/bootstrap.php';
?>

View File

@@ -15,16 +15,12 @@ $trustIp = array(
$request = Request::createFromGlobals(); $request = Request::createFromGlobals();
if( false === in_array($request->getClientIp(), $trustIp)){ if ( false === in_array($request->getClientIp(), $trustIp)) {
//change request to send to a 404 error page //change request to send to a 404 error page
} }
$thelia = new Thelia('dev', true); $thelia = new Thelia('dev', true);
$response = $thelia->handle($request)->prepare($request)->send(); $response = $thelia->handle($request)->prepare($request)->send();
$thelia->terminate($request, $response); $thelia->terminate($request, $response);
?>

View File

@@ -6,7 +6,6 @@
//database type : mysql, sqlite, pgsql, etc //database type : mysql, sqlite, pgsql, etc
define('THELIA_DB_TYPE','mysql'); define('THELIA_DB_TYPE','mysql');
// database login // database login
define('THELIA_BD_LOGIN', '__DB_LOGIN__'); define('THELIA_BD_LOGIN', '__DB_LOGIN__');
@@ -15,6 +14,3 @@ define('THELIA_BD_PASSWORD', '__DB_PASSWORD__');
//database DSN //database DSN
define('THELIA_DB_DSN','mysql:dbname=__DB_NAME__;host:__DB_HOST__'); define('THELIA_DB_DSN','mysql:dbname=__DB_NAME__;host:__DB_HOST__');
?>

View File

@@ -12,8 +12,4 @@ define('THELIA_BD_LOGIN', '__DB_LOGIN__');
// database password // database password
define('THELIA_BD_PASSWORD', '__DB_PASSWORD__'); define('THELIA_BD_PASSWORD', '__DB_PASSWORD__');
define('THELIA_DB_DSN','pgsql:dbname=__DB_NAME__;host:__DB_HOST__'); define('THELIA_DB_DSN','pgsql:dbname=__DB_NAME__;host:__DB_HOST__');
?>

View File

@@ -12,8 +12,4 @@ define('THELIA_BD_LOGIN', '__DB_LOGIN__');
// database password // database password
define('THELIA_BD_PASSWORD', '__DB_PASSWORD__'); define('THELIA_BD_PASSWORD', '__DB_PASSWORD__');
define('THELIA_DB_DSN','sqlite:__DB_FILE__'); define('THELIA_DB_DSN','sqlite:__DB_FILE__');
?>

View File

@@ -1,25 +1,18 @@
<?php <?php
if(is_file(__DIR__ . '/config_db.php')){ if (is_file(__DIR__ . '/config_db.php')) {
require __DIR__ . '/config_db.php'; require __DIR__ . '/config_db.php';
} } else {
else{
return false; return false;
} }
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->register('database','Thelia\\Database\\Connection'); $container->register('database','Thelia\\Database\\Connection');
$container->register('http_kernel','Symfony\\Component\\HttpKernel\\HttpKernel'); $container->register('http_kernel','Symfony\\Component\\HttpKernel\\HttpKernel');
$container->register('session','Symfony\\Component\\HttpFoundation\\Session\\Session'); $container->register('session','Symfony\\Component\\HttpFoundation\\Session\\Session');
return $container; return $container;
?>