clean code with php-cs-fixer
This commit is contained in:
@@ -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/TheliaApcUniversalClassLoader.php';
|
||||
|
||||
|
||||
use Thelia\Autoload\TheliaUniversalClassLoader;
|
||||
use Thelia\Autoload\TheliaApcUniversalClassLoader;
|
||||
|
||||
|
||||
if(extension_loaded('apc') && $env == 'prod'){
|
||||
if (extension_loaded('apc') && $env == 'prod') {
|
||||
$loader = new TheliaApcUniversalClassLoader('Thelia');
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$loader = new TheliaUniversalClassLoader();
|
||||
}
|
||||
|
||||
@@ -24,8 +21,4 @@ foreach ($namespaces as $namespace => $directory) {
|
||||
|
||||
$loader->registerNamespace('Thelia', __DIR__ . '/lib/');
|
||||
|
||||
|
||||
$loader->register();
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,23 +1,18 @@
|
||||
<?php
|
||||
|
||||
if(!isset($env)){
|
||||
if (!isset($env)) {
|
||||
$env = 'prod';
|
||||
}
|
||||
//
|
||||
//use Symfony\Component\DependencyInjection;
|
||||
//use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @file
|
||||
* Functions needed for Thelia bootstrap
|
||||
*/
|
||||
|
||||
|
||||
$loader = require __DIR__ . '/autoload.php';
|
||||
|
||||
define('THELIA_ROOT', __DIR__ .'/../');
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -7,8 +7,8 @@ namespace Thelia\Autoload;
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
|
||||
class TheliaApcUniversalClassLoader extends TheliaUniversalClassLoader {
|
||||
|
||||
class TheliaApcUniversalClassLoader extends TheliaUniversalClassLoader
|
||||
{
|
||||
private $prefix;
|
||||
|
||||
/**
|
||||
@@ -16,10 +16,11 @@ class TheliaApcUniversalClassLoader extends TheliaUniversalClassLoader {
|
||||
*
|
||||
* Come from Symfony\Component\ClassLoader\ApcUniversalClassLoader
|
||||
*
|
||||
* @param string $prefix
|
||||
* @param string $prefix
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function __construct($prefix) {
|
||||
public function __construct($prefix)
|
||||
{
|
||||
if (!extension_loaded('apc')) {
|
||||
throw new \RuntimeException('Unable to use ApcUniversalClassLoader as APC is not enabled.');
|
||||
}
|
||||
@@ -27,7 +28,6 @@ class TheliaApcUniversalClassLoader extends TheliaUniversalClassLoader {
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function findFile($class) {
|
||||
public function findFile($class)
|
||||
{
|
||||
if (false === $file = apc_fetch($this->prefix.$class)) {
|
||||
apc_store($this->prefix.$class, $file = parent::findFile($class));
|
||||
}
|
||||
@@ -45,4 +46,3 @@ class TheliaApcUniversalClassLoader extends TheliaUniversalClassLoader {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -15,8 +15,8 @@ use Symfony\Component\ClassLoader\UniversalClassLoader;
|
||||
*
|
||||
*/
|
||||
|
||||
class TheliaUniversalClassLoader extends UniversalClassLoader{
|
||||
|
||||
class TheliaUniversalClassLoader extends UniversalClassLoader
|
||||
{
|
||||
private $directories = array();
|
||||
|
||||
/**
|
||||
@@ -25,19 +25,20 @@ class TheliaUniversalClassLoader extends UniversalClassLoader{
|
||||
*
|
||||
* @param string $directory
|
||||
*/
|
||||
public function addDirectory($directory){
|
||||
public function addDirectory($directory)
|
||||
{
|
||||
$this->directories[] = $directory;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* add multiple path directory in an array where autoload can search files
|
||||
*
|
||||
* @param array $directories
|
||||
*/
|
||||
public function addDirectories(array $directories){
|
||||
foreach($directories as $directory){
|
||||
public function addDirectories(array $directories)
|
||||
{
|
||||
foreach ($directories as $directory) {
|
||||
$this->addDirectory($directory);
|
||||
}
|
||||
}
|
||||
@@ -48,7 +49,8 @@ class TheliaUniversalClassLoader extends UniversalClassLoader{
|
||||
*
|
||||
* @return array an Array of directories
|
||||
*/
|
||||
public function getDirectories(){
|
||||
public function getDirectories()
|
||||
{
|
||||
return $this->directories;
|
||||
}
|
||||
|
||||
@@ -56,18 +58,18 @@ class TheliaUniversalClassLoader extends UniversalClassLoader{
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
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";
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
@@ -77,6 +79,3 @@ class TheliaUniversalClassLoader extends UniversalClassLoader{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -12,7 +12,8 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
* @author Manuel Raynaud <mraynadu@openstudio.fr>
|
||||
*/
|
||||
|
||||
class DefaultController implements NullControllerInterface{
|
||||
class DefaultController implements NullControllerInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* set the default value for thelia
|
||||
@@ -21,14 +22,14 @@ class DefaultController implements NullControllerInterface{
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
*/
|
||||
public function noAction(Request $request) {
|
||||
if($request->query->has('view') === false){
|
||||
public function noAction(Request $request)
|
||||
{
|
||||
if ($request->query->has('view') === false) {
|
||||
$fond = "index";
|
||||
if($request->request->has('view')){
|
||||
if ($request->request->has('view')) {
|
||||
$fond = $request->request->get('view');
|
||||
}
|
||||
$request->query->set('view', $fond);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -9,12 +9,11 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
|
||||
interface NullControllerInterface {
|
||||
|
||||
interface NullControllerInterface
|
||||
{
|
||||
/**
|
||||
* Nothing to do
|
||||
*/
|
||||
public function noAction(Request $request);
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -7,24 +7,23 @@ use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
class RequestListener implements EventSubscriberInterface {
|
||||
|
||||
class RequestListener implements EventSubscriberInterface
|
||||
{
|
||||
protected $container;
|
||||
|
||||
public function __construct(ContainerInterface $container) {
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function onKernelRequest(GetResponseEvent $event){
|
||||
|
||||
public function onKernelRequest(GetResponseEvent $event)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public static function getSubscribedEvents(){
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
KernelEvents::REQUEST => array('onKernelRequest', 30)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -5,11 +5,9 @@ namespace Thelia\Core\EventListener;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Thelia\Core\Template\ParserInterface;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* ViewSubscriber Main class subscribing to view http response.
|
||||
@@ -19,15 +17,16 @@ use Thelia\Core\Template\ParserInterface;
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
|
||||
class ViewListener implements EventSubscriberInterface{
|
||||
|
||||
class ViewListener implements EventSubscriberInterface
|
||||
{
|
||||
private $parser;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \Thelia\Core\Template\ParserInterface $parser
|
||||
*/
|
||||
public function __construct(ParserInterface $parser) {
|
||||
public function __construct(ParserInterface $parser)
|
||||
{
|
||||
$this->parser = $parser;
|
||||
}
|
||||
|
||||
@@ -39,14 +38,13 @@ class ViewListener implements EventSubscriberInterface{
|
||||
*
|
||||
* @param \Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event
|
||||
*/
|
||||
public function onKernelView(GetResponseForControllerResultEvent $event){
|
||||
|
||||
public function onKernelView(GetResponseForControllerResultEvent $event)
|
||||
{
|
||||
$content = $this->parser->getContent();
|
||||
|
||||
if($content instanceof Response){
|
||||
if ($content instanceof Response) {
|
||||
$event->setResponse($content);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$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
|
||||
*/
|
||||
public static function getSubscribedEvents(){
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
KernelEvents::VIEW => array('onKernelView'),
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
|
||||
namespace Thelia\Core\Template;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Thelia\Core\Template\ParserInterface;
|
||||
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 SHOW_TIME = true;
|
||||
@@ -32,7 +30,8 @@ class Parser implements ParserInterface {
|
||||
protected $content;
|
||||
protected $status = 200;
|
||||
|
||||
public function __construct(ContainerBuilder $container) {
|
||||
public function __construct(ContainerBuilder $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
|
||||
*
|
||||
*/
|
||||
public function getContent() {
|
||||
public function getContent()
|
||||
{
|
||||
$this->loadParser();
|
||||
$this->content = "toto";
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
@@ -53,7 +54,8 @@ class Parser implements ParserInterface {
|
||||
*
|
||||
* @param string|Symfony\Component\HttpFoundation\Response $content
|
||||
*/
|
||||
public function setContent($content) {
|
||||
public function setContent($content)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
@@ -61,7 +63,8 @@ class Parser implements ParserInterface {
|
||||
*
|
||||
* @return type the status of the response
|
||||
*/
|
||||
public function getStatus() {
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
@@ -71,13 +74,13 @@ class Parser implements ParserInterface {
|
||||
*
|
||||
* @param int $status
|
||||
*/
|
||||
public function setStatus($status) {
|
||||
public function setStatus($status)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function loadParser(){
|
||||
|
||||
public function loadParser()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace Thelia\Core\Template;
|
||||
*
|
||||
*/
|
||||
|
||||
interface ParserInterface {
|
||||
|
||||
interface ParserInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -23,5 +23,3 @@ interface ParserInterface {
|
||||
|
||||
public function setStatus($status);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -11,12 +11,12 @@ namespace Thelia\Core;
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
|
||||
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Thelia\Core\TheliaBundle;
|
||||
|
||||
class Thelia extends Kernel {
|
||||
class Thelia extends Kernel
|
||||
{
|
||||
/**
|
||||
* 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
|
||||
* container is built.
|
||||
*/
|
||||
protected function initializeContainer(){
|
||||
protected function initializeContainer()
|
||||
{
|
||||
$this->container = $this->buildContainer();
|
||||
$this->container->set('kernel', $this);
|
||||
|
||||
@@ -36,19 +37,17 @@ class Thelia extends Kernel {
|
||||
*
|
||||
* @return ContainerBuilder The compiled service container
|
||||
*/
|
||||
protected function buildContainer(){
|
||||
|
||||
protected function buildContainer()
|
||||
{
|
||||
$container = $this->getContainerBuilder();
|
||||
|
||||
foreach($this->bundles as $bundle){
|
||||
foreach ($this->bundles as $bundle) {
|
||||
$bundle->build($container);
|
||||
}
|
||||
|
||||
return $container;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* return available bundle
|
||||
*
|
||||
@@ -57,8 +56,8 @@ class Thelia extends Kernel {
|
||||
* @return array An array of bundle instances.
|
||||
*
|
||||
*/
|
||||
public function registerBundles() {
|
||||
|
||||
public function registerBundles()
|
||||
{
|
||||
$bundles = array(
|
||||
/* TheliaBundle contain all the dependency injection description */
|
||||
new TheliaBundle()
|
||||
@@ -83,11 +82,10 @@ class Thelia extends Kernel {
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function registerContainerConfiguration(LoaderInterface $loader){
|
||||
public function registerContainerConfiguration(LoaderInterface $loader)
|
||||
{
|
||||
//Nothing is load here but it's possible to load container configuration here.
|
||||
//exemple in sf2 : $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -18,8 +18,8 @@ use Symfony\Component\DependencyInjection\Scope;
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
|
||||
class TheliaBundle extends Bundle {
|
||||
|
||||
class TheliaBundle extends Bundle
|
||||
{
|
||||
/**
|
||||
*
|
||||
* Construct the depency injection builder
|
||||
@@ -27,8 +27,8 @@ class TheliaBundle extends Bundle {
|
||||
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
|
||||
*/
|
||||
|
||||
public function build(ContainerBuilder $container) {
|
||||
|
||||
public function build(ContainerBuilder $container)
|
||||
{
|
||||
$container->addScope( new Scope('request'));
|
||||
|
||||
$container->register('request', 'Symfony\Component\HttpFoundation\Request')
|
||||
@@ -84,12 +84,9 @@ class TheliaBundle extends Bundle {
|
||||
|
||||
// DEFINE DEFAULT PARAMETER LIKE
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @TODO learn about container compilation
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -11,17 +11,17 @@ use Thelia\Controller\NullControllerInterface;
|
||||
*
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class DefaultMatcher implements RequestMatcherInterface{
|
||||
|
||||
class DefaultMatcher implements RequestMatcherInterface
|
||||
{
|
||||
protected $controller;
|
||||
|
||||
public function __construct(NullControllerInterface $controller) {
|
||||
public function __construct(NullControllerInterface $controller)
|
||||
{
|
||||
$this->controller = $controller;
|
||||
}
|
||||
|
||||
public function matchRequest(Request $request) {
|
||||
|
||||
|
||||
public function matchRequest(Request $request)
|
||||
{
|
||||
$objectInformation = new \ReflectionObject($this->controller);
|
||||
|
||||
$parameter = array(
|
||||
@@ -31,6 +31,3 @@ class DefaultMatcher implements RequestMatcherInterface{
|
||||
return $parameter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -19,9 +19,8 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
|
||||
|
||||
class TheliaMatcherCollection implements RequestMatcherInterface, RequestContextAwareInterface {
|
||||
|
||||
class TheliaMatcherCollection implements RequestMatcherInterface, RequestContextAwareInterface
|
||||
{
|
||||
protected $context;
|
||||
protected $matchers = array();
|
||||
protected $defaultMatcher;
|
||||
@@ -33,11 +32,11 @@ class TheliaMatcherCollection implements RequestMatcherInterface, RequestContext
|
||||
*
|
||||
* Check if this constructor is needed (is RequestContext needed ? )
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->context = new RequestContext();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* allow to add a matcher routing class to the matchers collection
|
||||
* matcher must implement RequestMatcherInterface
|
||||
@@ -45,15 +44,16 @@ class TheliaMatcherCollection implements RequestMatcherInterface, RequestContext
|
||||
* priority can be fixed with $priority parameter
|
||||
*
|
||||
* @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){
|
||||
if(!is_object($matcher)){
|
||||
public function add(RequestMatcherInterface $matcher, $priority = 0)
|
||||
{
|
||||
if (!is_object($matcher)) {
|
||||
$matcher = new $matcher();
|
||||
}
|
||||
|
||||
if(!isset($this->matchers[$priority])){
|
||||
if (!isset($this->matchers[$priority])) {
|
||||
$this->matchers[$priority] = array();
|
||||
}
|
||||
|
||||
@@ -61,40 +61,39 @@ class TheliaMatcherCollection implements RequestMatcherInterface, RequestContext
|
||||
$this->sortedMatchers = array();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Sort Matchers by priority
|
||||
*
|
||||
* @return array Array of matchers sorted by priority.
|
||||
*/
|
||||
public function getSortedMatchers(){
|
||||
if(empty($this->sortedMatchers)){
|
||||
public function getSortedMatchers()
|
||||
{
|
||||
if (empty($this->sortedMatchers)) {
|
||||
$this->sortedMatchers = $this->sortMatchers();
|
||||
}
|
||||
|
||||
return $this->sortedMatchers;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Sort the matcher by priority
|
||||
*
|
||||
* @return array Array of matchers sorted by priority.
|
||||
*/
|
||||
public function sortMatchers(){
|
||||
public function sortMatchers()
|
||||
{
|
||||
$sortedMatchers = array();
|
||||
krsort($this->matchers);
|
||||
|
||||
foreach($this->matchers as $matcher){
|
||||
foreach ($this->matchers as $matcher) {
|
||||
$sortedMatchers = array_merge($sortedMatchers,$matcher);
|
||||
}
|
||||
|
||||
return $sortedMatchers;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 MethodNotAllowedException If a matching resource was found but the request method is not allowed
|
||||
*/
|
||||
public function matchRequest(Request $request) {
|
||||
if(empty($this->matchers)){
|
||||
public function matchRequest(Request $request)
|
||||
{
|
||||
if (empty($this->matchers)) {
|
||||
throw new \InvalidArgumentException('there is no matcher added to the TheliaMatcherCollection');
|
||||
}
|
||||
|
||||
foreach($this->getSortedMatchers() as $matcher){
|
||||
try{
|
||||
foreach ($this->getSortedMatchers() as $matcher) {
|
||||
try {
|
||||
return $matcher->matchRequest($request);
|
||||
}
|
||||
catch (ResourceNotFoundException $e){
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
//no action, wait for next matcher
|
||||
}
|
||||
catch(MethodNotAllowedException $e){
|
||||
} catch (MethodNotAllowedException $e) {
|
||||
/**
|
||||
* @todo what todo with a MethodNotAllowedException ?
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
*
|
||||
*/
|
||||
public function setContext(RequestContext $context){
|
||||
public function setContext(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
|
||||
}
|
||||
@@ -148,8 +146,8 @@ class TheliaMatcherCollection implements RequestMatcherInterface, RequestContext
|
||||
* @return RequestContext The context
|
||||
*
|
||||
*/
|
||||
public function getContext(){
|
||||
public function getContext()
|
||||
{
|
||||
return $this->context;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -15,16 +15,12 @@ $trustIp = array(
|
||||
|
||||
$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
|
||||
}
|
||||
|
||||
|
||||
$thelia = new Thelia('dev', true);
|
||||
|
||||
$response = $thelia->handle($request)->prepare($request)->send();
|
||||
|
||||
$thelia->terminate($request, $response);
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
//database type : mysql, sqlite, pgsql, etc
|
||||
define('THELIA_DB_TYPE','mysql');
|
||||
|
||||
|
||||
// database login
|
||||
define('THELIA_BD_LOGIN', '__DB_LOGIN__');
|
||||
|
||||
@@ -15,6 +14,3 @@ define('THELIA_BD_PASSWORD', '__DB_PASSWORD__');
|
||||
|
||||
//database DSN
|
||||
define('THELIA_DB_DSN','mysql:dbname=__DB_NAME__;host:__DB_HOST__');
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -12,8 +12,4 @@ define('THELIA_BD_LOGIN', '__DB_LOGIN__');
|
||||
// database password
|
||||
define('THELIA_BD_PASSWORD', '__DB_PASSWORD__');
|
||||
|
||||
|
||||
define('THELIA_DB_DSN','pgsql:dbname=__DB_NAME__;host:__DB_HOST__');
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -12,8 +12,4 @@ define('THELIA_BD_LOGIN', '__DB_LOGIN__');
|
||||
// database password
|
||||
define('THELIA_BD_PASSWORD', '__DB_PASSWORD__');
|
||||
|
||||
|
||||
define('THELIA_DB_DSN','sqlite:__DB_FILE__');
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,25 +1,18 @@
|
||||
<?php
|
||||
if(is_file(__DIR__ . '/config_db.php')){
|
||||
if (is_file(__DIR__ . '/config_db.php')) {
|
||||
require __DIR__ . '/config_db.php';
|
||||
}
|
||||
else{
|
||||
} 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