remove notORM bundle

This commit is contained in:
Manuel Raynaud
2013-01-15 10:56:48 +01:00
parent 8279cc37b4
commit 813acbf26c
6 changed files with 164 additions and 373 deletions

View File

@@ -1,81 +0,0 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Bundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/**
* First Bundle use in Thelia
* It initialize dependency injection container.
*
* @TODO load configuration from thelia plugin
* @TODO register database configuration.
*
*
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class LoggerBundle extends Bundle
{
/**
*
* Construct the depency injection builder
*
* Reference all Model in the Container here
*
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
public function build(ContainerBuilder $container)
{
$container->setParameter("logger.class", "\Thelia\Log\Tlog");
$container->register("logger","%logger.class%")
->addArgument(new Reference('service_container'));
$kernel = $container->get('kernel');
if ($kernel->isDebug()) {
// $debug = function ($query, $parameters)
// {
//
// $pattern = '(^' . preg_quote(dirname(__FILE__)) . '(\\.php$|[/\\\\]))'; // can be static
// foreach (debug_backtrace() as $backtrace) {
// if (isset($backtrace["file"]) && !preg_match($pattern, $backtrace["file"])) { // stop on first file outside NotORM source codes
// break;
// }
// }
// file_put_contents(THELIA_ROOT . 'log/request_debug.log', "$backtrace[file]:$backtrace[line]:$query", FILE_APPEND);
// file_put_contents(THELIA_ROOT . 'log/request_debug.log', is_scalar($parameters) ? $parameters : print_r($parameters, true), FILE_APPEND);
//
// };
//
// $container->getDefinition('database')
// ->addMethodCall('setDebug', array($debug));
$container->get('database')
->setLogger($container->get('logger'));
}
}
}

View File

@@ -1,60 +0,0 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Bundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Thelia\Tools\DIGenerator;
/**
* First Bundle use in Thelia
* It initialize dependency injection container.
*
* @TODO load configuration from thelia plugin
* @TODO register database configuration.
*
*
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class ModelBundle extends Bundle
{
/**
*
* Construct the depency injection builder
*
* Reference all Model in the Container here
*
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
public function build(ContainerBuilder $container)
{
foreach (DIGenerator::genDiModel(realpath(THELIA_ROOT . "core/lib/Thelia/Model"), array('Base')) as $name => $class) {
$container->register('model.'.$name, $class)
->addArgument(new Reference("database"))
->addArgument(new Reference('service_container'));
}
}
}

View File

@@ -1,98 +0,0 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Bundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/**
* First Bundle use in Thelia
* It initialize dependency injection container.
*
* @TODO load configuration from thelia plugin
* @TODO register database configuration.
*
*
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class NotORMBundle extends Bundle
{
/**
*
* Construct the depency injection builder
*
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
public function build(ContainerBuilder $container)
{
$config = array(
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION
);
$kernel = $container->get('kernel');
$pdo = new \PDO(THELIA_DB_DSN,THELIA_DB_USER, THELIA_DB_PASSWORD, $config);
$pdo->exec("SET NAMES UTF8");
$container->register('database','\Thelia\Database\NotORM')
->addArgument($pdo);
if (defined('THELIA_DB_CACHE') && !$kernel->isDebug()) {
switch (THELIA_DB_CACHE) {
case 'file':
$container->register('database_cache','\NotORM_Cache_File')
->addArgument($kernel->getCacheDir().'/database.php');
break;
case 'include':
$container->register('database_cache','\NotORM_Cache_Include')
->addArgument($kernel->getCacheDir().'/database_include.php');
break;
case 'apc':
if (extension_loaded('apc')) {
$container->register('database_cache','\NotORM_Cache_APC');
}
break;
case 'session':
$container->register('database_cache','\NotORM_Cache_Session');
break;
case 'memcache':
if (class_exists('Memcache')) {
$container->register('database_cache','\NotORM_Cache_Memcache')
->addArgument(new \Memcache());
}
break;
}
if ($container->hasDefinition('database_cache')) {
$container->getDefinition('database')
->addMethodCall('setCache', array(new Reference('database_cache')));
}
}
}
}

View File

@@ -116,9 +116,6 @@ class Thelia extends Kernel
$bundles = array(
/* TheliaBundle contain all the dependency injection description */
new Bundle\TheliaBundle(),
new Bundle\NotORMBundle(),
new Bundle\ModelBundle(),
new Bundle\LoggerBundle()
);
/**