diff --git a/core/composer.json b/core/composer.json index 6f0c40cb0..20a214a28 100644 --- a/core/composer.json +++ b/core/composer.json @@ -10,7 +10,8 @@ "symfony/console" : "2.1.*", "symfony/event-dispatcher" : "2.1.*", "symfony-cmf/routing" : "1.0.*@dev", - "propel/propel1" : "1.6.*" + "propel/propel1" : "1.6.*", + "psr/log" : "dev-master" }, "minimum-stability": "stable" } diff --git a/core/composer.lock b/core/composer.lock index 1d66ea0e0..3697463f3 100644 --- a/core/composer.lock +++ b/core/composer.lock @@ -1,5 +1,5 @@ { - "hash": "2be3cc68d014718aa32d78effb38b917", + "hash": "8a668b67ef3c3dd2fe8f426c37b2db5d", "packages": [ { "name": "phing/phing", @@ -113,6 +113,44 @@ "mapping" ] }, + { + "name": "psr/log", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log", + "reference": "1.0.0" + }, + "dist": { + "type": "zip", + "url": "https://github.com/php-fig/log/archive/1.0.0.zip", + "reference": "1.0.0", + "shasum": "" + }, + "time": "2012-12-21 11:40:51", + "type": "library", + "autoload": { + "psr-0": { + "Psr\\Log\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "keywords": [ + "log", + "psr", + "psr-3" + ] + }, { "name": "symfony-cmf/routing", "version": "dev-master", @@ -120,12 +158,12 @@ "source": { "type": "git", "url": "https://github.com/symfony-cmf/Routing", - "reference": "1.0.0-alpha3" + "reference": "817b65edad2a4318cffd5017ff7eaabb9f2b65f8" }, "dist": { "type": "zip", - "url": "https://github.com/symfony-cmf/Routing/archive/1.0.0-alpha3.zip", - "reference": "1.0.0-alpha3", + "url": "https://github.com/symfony-cmf/Routing/archive/817b65edad2a4318cffd5017ff7eaabb9f2b65f8.zip", + "reference": "817b65edad2a4318cffd5017ff7eaabb9f2b65f8", "shasum": "" }, "require": { @@ -133,7 +171,7 @@ "symfony/routing": ">=2.1,<2.3-dev", "symfony/http-kernel": ">=2.1,<2.3-dev" }, - "time": "2012-12-16 17:52:57", + "time": "2013-01-20 20:39:41", "type": "library", "extra": { "branch-alias": { @@ -145,6 +183,7 @@ "Symfony\\Cmf\\Component\\Routing": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -554,6 +593,7 @@ ], "minimum-stability": "stable", "stability-flags": { - "symfony-cmf/routing": 20 + "symfony-cmf/routing": 20, + "psr/log": 20 } } diff --git a/core/lib/Thelia/Core/Bundle/PropelBundle.php b/core/lib/Thelia/Core/Bundle/PropelBundle.php deleted file mode 100644 index 10ab64aaa..000000000 --- a/core/lib/Thelia/Core/Bundle/PropelBundle.php +++ /dev/null @@ -1,44 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ -namespace Thelia\Core\Bundle; - -use Symfony\Component\HttpKernel\Bundle\Bundle; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; - -use \Propel; - -class PropelBundle extends Bundle -{ - /** - * - * Construct the depency injection builder - * - * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container - */ - - public function build(ContainerBuilder $container) - { - Propel::init(THELIA_CONF_DIR . "/config_thelia.php"); - } -} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index fddc2e332..12892f666 100644 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -34,10 +34,25 @@ namespace Thelia\Core; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\Config\ConfigCache; +use Symfony\Component\DependencyInjection\Dumper\PhpDumper; use Thelia\Core\Bundle; +use Propel; class Thelia extends Kernel { + + public function init() + { + parent::init(); + + $this->initPropel(); + } + + protected function initPropel() + { + Propel::init(THELIA_CONF_DIR . "/config_thelia.php"); + } /** * Initializes the service container. * @@ -46,12 +61,27 @@ class Thelia extends Kernel * The cached version of the service container is used when fresh, otherwise the * container is built. */ - protected function initializeContainer() - { - $this->container = $this->buildContainer(); - //$this->container->set('kernel', $this); - - } +// protected function initializeContainer() +// { +// $class = $this->getContainerClass(); +// $cache = new ConfigCache($this->getCacheDir().'/'.$class.'.php', $this->debug); +// $fresh = true; +// if (!$cache->isFresh()) { +// $container = $this->buildContainer(); +// $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass()); +// +// $fresh = false; +// } +// +// require_once $cache; +// +// $this->container = new $class(); +// +// if (!$fresh && $this->container->has('cache_warmer')) { +// $this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir')); +// } +// +// } /** * Gets the cache directory. @@ -91,17 +121,17 @@ class Thelia extends Kernel * * @return ContainerBuilder The compiled service container */ - protected function buildContainer() - { - $container = $this->getContainerBuilder(); - $container->set('kernel', $this); - - foreach ($this->bundles as $bundle) { - $bundle->build($container); - } - - return $container; - } +// protected function buildContainer() +// { +// $container = $this->getContainerBuilder(); +// $container->set('kernel', $this); +// +// foreach ($this->bundles as $bundle) { +// $bundle->build($container); +// } +// +// return $container; +// } /** * return available bundle @@ -115,8 +145,7 @@ class Thelia extends Kernel { $bundles = array( /* TheliaBundle contain all the dependency injection description */ - new Bundle\TheliaBundle(), - new Bundle\PropelBundle() + new Bundle\TheliaBundle() ); /** diff --git a/core/lib/Thelia/Log/Tlog.php b/core/lib/Thelia/Log/Tlog.php index 865fb594a..007115054 100644 --- a/core/lib/Thelia/Log/Tlog.php +++ b/core/lib/Thelia/Log/Tlog.php @@ -23,6 +23,7 @@ namespace Thelia\Log; use Thelia\Model\ConfigQuery; +use Psr\Log\LoggerInterface; /** * @@ -33,7 +34,7 @@ use Thelia\Model\ConfigQuery; * @author Franck Allimant * @author Manuel Raynaud */ -class Tlog Implements TlogInterface +class Tlog Implements LoggerInterface { // Nom des variables de configuration const VAR_LEVEL = "tlog_level"; @@ -44,13 +45,26 @@ class Tlog Implements TlogInterface const VAR_SHOW_REDIRECT = "tlog_show_redirect"; // all level of trace - const TRACE = 100; - const DEBUG = 200; - const WARNING = 300; - const INFO = 400; + const DEBUG = 100; + const INFO = 200; + const NOTICE = 300; + const WARNING = 400; const ERROR = 500; - const FATAL = 600; + const CRITICAL = 600; + const ALERT = 700; + const EMERGENCY = 800; const MUET = PHP_INT_MAX; + + protected $levels = array( + 100 => "DEBUG", + 200 => "INFO", + 300 => "NOTICE", + 400 => "WARNING", + 500 => "ERROR", + 600 => "CRITICAL", + 700 => "ALERT", + 800 => "EMERGENCY" + ); // default values const DEFAULT_LEVEL = self::DEBUG; @@ -187,65 +201,54 @@ class Tlog Implements TlogInterface // Methodes d'accès aux traces // --------------------------- - public function trace() + public function debug($message, array $context = array()) { - if ($this->level > self::TRACE) - return; - - $args = func_get_args(); - - $this->out("TRACE", $args); + $this->log(self::DEBUG, $message, $context); } - public function debug() + public function info($message, array $context = array()) { - if ($this->level > self::DEBUG) - return; - - $args = func_get_args(); - - $this->out("DEBUG", $args); + $this->log(self::INFO, $message, $context); + } + + public function notice($message, array $context = array()) + { + $this->log(self::NOTICE, $message, $context); } - public function info() + public function warning($message, array $context = array()) { - if ($this->level > self::INFO) - return; - - $args = func_get_args(); - - $this->out("INFO", $args); + $this->log(self::WARNING, $message, $context); } - public function warning() + public function error($message, array $context = array()) { - if ($this->level > self::WARNING) + $this->log(self::ERROR, $message, $context); + } + + public function critical($message, array $context = array()) + { + $this->log(self::CRITICAL, $message, $context); + } + + public function alert($message, array $context = array()) + { + $this->log(self::ALERT, $message, $context); + } + + public function emergency($message, array $context = array()) + { + $this->log(self::EMERGENCY, $message, $context); + } + + public function log($level, $message, array $context = array()) { + if($this->level > $level && array_key_exists($level, $this->levels) === false) return; - - $args = func_get_args(); - - $this->out("WARNING", $args); + + $this->out($this->levels[$level], $message, $context); } - public function error() - { - if ($this->level > self::ERROR) - return; - - $args = func_get_args(); - - $this->out("ERREUR", $args); - } - - public function fatal() - { - if ($this->level > self::FATAL) - return; - - $args = func_get_args(); - - $this->out("FATAL", $args); - } + // Mode back office public static function SetBackOfficeMode($booleen) @@ -368,14 +371,34 @@ class Tlog Implements TlogInterface return $origine; } + + protected function interpolate($message, array $context = array()) + { + // build a replacement array with braces around the context keys + $replace = array(); + foreach ($context as $key => $val) { + $replace['{' . $key . '}'] = $val; + } - private function out($level, $tabargs) + // interpolate replacement values into the message and return + return strtr($message, $replace); + } + + private function out($level, $message, array $context = array()) { $text = ''; - - foreach ($tabargs as $arg) { - $text .= is_scalar($arg) ? $arg : print_r($arg, true); + + /*if (is_array($message)) { + foreach ($message as $arg) { + $text .= is_scalar($arg) ? $arg : print_r($arg, true); + } + } else */ if (is_scalar($message) === false) { + $text = print_r($message, true); + } else { + $text = $message; } + + $text = $this->interpolate($text, $context); $origine = $this->findOrigin();