fix some CS
This commit is contained in:
@@ -56,8 +56,7 @@ class LoggerBundle extends Bundle
|
||||
|
||||
$kernel = $container->get('kernel');
|
||||
|
||||
if($kernel->isDebug())
|
||||
{
|
||||
if ($kernel->isDebug()) {
|
||||
// $debug = function ($query, $parameters)
|
||||
// {
|
||||
//
|
||||
|
||||
@@ -51,8 +51,7 @@ class ModelBundle extends Bundle
|
||||
|
||||
public function build(ContainerBuilder $container)
|
||||
{
|
||||
foreach(DIGenerator::genDiModel(realpath(THELIA_ROOT . "core/lib/Thelia/Model"), array('Base')) as $name => $class)
|
||||
{
|
||||
foreach (DIGenerator::genDiModel(realpath(THELIA_ROOT . "core/lib/Thelia/Model"), array('Base')) as $name => $class) {
|
||||
$container->register('model.'.$name, $class)
|
||||
->addArgument(new Reference("database"));
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
/**
|
||||
* First Bundle use in Thelia
|
||||
* It initialize dependency injection container.
|
||||
@@ -63,10 +61,8 @@ class NotORMBundle extends Bundle
|
||||
$container->register('database','\Thelia\Database\NotORM')
|
||||
->addArgument($pdo);
|
||||
|
||||
if(defined('THELIA_DB_CACHE') && !$kernel->isDebug())
|
||||
{
|
||||
switch(THELIA_DB_CACHE)
|
||||
{
|
||||
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');
|
||||
@@ -76,8 +72,7 @@ class NotORMBundle extends Bundle
|
||||
->addArgument($kernel->getCacheDir().'/database_include.php');
|
||||
break;
|
||||
case 'apc':
|
||||
if (extension_loaded('apc'))
|
||||
{
|
||||
if (extension_loaded('apc')) {
|
||||
$container->register('database_cache','\NotORM_Cache_APC');
|
||||
}
|
||||
break;
|
||||
@@ -85,8 +80,7 @@ class NotORMBundle extends Bundle
|
||||
$container->register('database_cache','\NotORM_Cache_Session');
|
||||
break;
|
||||
case 'memcache':
|
||||
if(class_exists('Memcache'))
|
||||
{
|
||||
if (class_exists('Memcache')) {
|
||||
$container->register('database_cache','\NotORM_Cache_Memcache')
|
||||
->addArgument(new \Memcache());
|
||||
}
|
||||
@@ -94,15 +88,11 @@ class NotORMBundle extends Bundle
|
||||
|
||||
}
|
||||
|
||||
if($container->hasDefinition('database_cache'))
|
||||
{
|
||||
if ($container->hasDefinition('database_cache')) {
|
||||
$container->getDefinition('database')
|
||||
->addMethodCall('setCache', array(new Reference('database_cache')));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,8 +62,7 @@ class Thelia extends Kernel
|
||||
*/
|
||||
public function getCacheDir()
|
||||
{
|
||||
if(defined('THELIA_ROOT'))
|
||||
{
|
||||
if (defined('THELIA_ROOT')) {
|
||||
return THELIA_ROOT.'cache/'.$this->environment;
|
||||
} else {
|
||||
return parent::getCacheDir();
|
||||
@@ -80,8 +79,7 @@ class Thelia extends Kernel
|
||||
*/
|
||||
public function getLogDir()
|
||||
{
|
||||
if(defined('THELIA_ROOT'))
|
||||
{
|
||||
if (defined('THELIA_ROOT')) {
|
||||
return THELIA_ROOT.'log/';
|
||||
} else {
|
||||
return parent::getLogDir();
|
||||
|
||||
@@ -43,7 +43,6 @@ class TheliaHttpKernel extends HttpKernel
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles a Request to convert it to a Response.
|
||||
*
|
||||
|
||||
@@ -25,7 +25,6 @@ namespace Thelia\Database;
|
||||
use Thelia\Log\TlogInterface;
|
||||
use Thelia\Database\NotORM\Result;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Class Thelia\Database\NotORM extending \NotORM library http://www.notorm.com/
|
||||
@@ -51,8 +50,7 @@ class NotORM extends \NotORM
|
||||
|
||||
public function setDebug($debug)
|
||||
{
|
||||
if(is_callable($debug))
|
||||
{
|
||||
if (is_callable($debug)) {
|
||||
$this->debug = $debug;
|
||||
} else {
|
||||
$this->debug = true;
|
||||
@@ -64,11 +62,13 @@ class NotORM extends \NotORM
|
||||
* @param array (["condition"[, array("value")]]) passed to NotORM_Result::where()
|
||||
* @return NotORM_Result
|
||||
*/
|
||||
function __call($table, array $where) {
|
||||
public function __call($table, array $where)
|
||||
{
|
||||
$return = new Result($this->structure->getReferencingTable($table, ''), $this);
|
||||
if ($where) {
|
||||
call_user_func_array(array($return, 'where'), $where);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,8 @@ namespace Thelia\Database\NotORM;
|
||||
|
||||
class Result extends \NotORM_Result
|
||||
{
|
||||
protected function query($query, $parameters) {
|
||||
protected function query($query, $parameters)
|
||||
{
|
||||
if ($this->notORM->debug) {
|
||||
if (!is_callable($this->notORM->debug)) {
|
||||
$debug = "$query;";
|
||||
@@ -23,8 +24,7 @@ class Result extends \NotORM_Result
|
||||
}
|
||||
}
|
||||
|
||||
if($this->notORM->logger !== false)
|
||||
{
|
||||
if ($this->notORM->logger !== false) {
|
||||
$this->notORM->logger->debug($query);
|
||||
$this->notORM->logger->debug($parameters);
|
||||
}
|
||||
@@ -34,8 +34,10 @@ class Result extends \NotORM_Result
|
||||
$this->notORM->logger->fatal($this->notORM->errorCode());
|
||||
$this->notORM->logger->fatal(print_r($this->notORM->errorInfo(), true));
|
||||
$this->notORM->logger->fatal(print_r($return->errorInfo(), true));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,8 @@
|
||||
|
||||
namespace Thelia\Log;
|
||||
|
||||
abstract class AbstractTlogDestination {
|
||||
|
||||
abstract class AbstractTlogDestination
|
||||
{
|
||||
//Tableau de TlogDestinationConfig paramétrant la destination
|
||||
protected $_configs;
|
||||
|
||||
@@ -36,7 +36,8 @@ abstract class AbstractTlogDestination {
|
||||
|
||||
protected $configModel;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->_configs = array();
|
||||
$this->_logs = array();
|
||||
|
||||
@@ -48,7 +49,8 @@ abstract class AbstractTlogDestination {
|
||||
}
|
||||
|
||||
//Affecte une valeur à une configuration de la destination
|
||||
public function set_config($nom, $valeur) {
|
||||
public function set_config($nom, $valeur)
|
||||
{
|
||||
foreach ($this->_configs as $config) {
|
||||
if ($config->nom == $nom) {
|
||||
$config->valeur = $valeur;
|
||||
@@ -58,6 +60,7 @@ abstract class AbstractTlogDestination {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -72,36 +75,40 @@ abstract class AbstractTlogDestination {
|
||||
}
|
||||
|
||||
//Récupère la valeur affectée à une configuration de la destination
|
||||
public function get_config($nom) {
|
||||
public function get_config($nom)
|
||||
{
|
||||
foreach ($this->_configs as $config) {
|
||||
if ($config->nom == $nom) {
|
||||
return $config->valeur;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get_configs() {
|
||||
public function get_configs()
|
||||
{
|
||||
return $this->_configs;
|
||||
}
|
||||
|
||||
public function mode_back_office($bool) {
|
||||
public function mode_back_office($bool)
|
||||
{
|
||||
$this->flag_back_office = $bool;
|
||||
}
|
||||
|
||||
//Ajoute une ligne de logs à la destination
|
||||
public function ajouter($string) {
|
||||
public function ajouter($string)
|
||||
{
|
||||
$this->_logs[] = $string;
|
||||
}
|
||||
|
||||
protected function inserer_apres_body(&$res, $logdata) {
|
||||
|
||||
protected function inserer_apres_body(&$res, $logdata)
|
||||
{
|
||||
$match = array();
|
||||
|
||||
if (preg_match("/(<body[^>]*>)/i", $res, $match)) {
|
||||
$res = str_replace($match[0], $match[0] . "\n" . $logdata, $res);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$res = $logdata . $res;
|
||||
}
|
||||
}
|
||||
@@ -109,7 +116,8 @@ abstract class AbstractTlogDestination {
|
||||
// Demande à la destination de se configurer pour être prête
|
||||
// a fonctionner. Si $config est != false, celà indique
|
||||
// que seul le paramètre de configuration indiqué a été modifié.
|
||||
protected function configurer($config = false) {
|
||||
protected function configurer($config = false)
|
||||
{
|
||||
// Cette methode doit etre surchargée si nécessaire.
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace Thelia\Log\Destination;
|
||||
use Thelia\Log\AbstractTlogDestination;
|
||||
use Thelia\Log\TlogDestinationConfig;
|
||||
|
||||
class TlogDestinationFile extends AbstractTlogDestination {
|
||||
|
||||
class TlogDestinationFile extends AbstractTlogDestination
|
||||
{
|
||||
// Nom des variables de configuration
|
||||
// ----------------------------------
|
||||
const VAR_PATH_FILE = "tlog_destinationfile_path";
|
||||
@@ -39,14 +39,15 @@ class TlogDestinationFile extends AbstractTlogDestination {
|
||||
protected $path_defaut = false;
|
||||
protected $fh = false;
|
||||
|
||||
public function __construct($configModel = null) {
|
||||
|
||||
public function __construct($configModel = null)
|
||||
{
|
||||
$this->path_defaut = THELIA_ROOT . "log/" . self::TLOG_DEFAULT_NAME;
|
||||
$this->setConfigModel($configModel);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function configurer($config = false) {
|
||||
public function configurer($config = false)
|
||||
{
|
||||
$file_path = $this->get_config(self::VAR_PATH_FILE);
|
||||
$mode = strtolower($this->get_config(self::VAR_MODE)) == 'a' ? 'a' : 'w';
|
||||
|
||||
@@ -64,15 +65,18 @@ class TlogDestinationFile extends AbstractTlogDestination {
|
||||
}
|
||||
}
|
||||
|
||||
public function get_titre() {
|
||||
public function get_titre()
|
||||
{
|
||||
return "Text File";
|
||||
}
|
||||
|
||||
public function get_description() {
|
||||
public function get_description()
|
||||
{
|
||||
return "Store logs into text file";
|
||||
}
|
||||
|
||||
public function get_configs() {
|
||||
public function get_configs()
|
||||
{
|
||||
return array(
|
||||
new TlogDestinationConfig(
|
||||
self::VAR_PATH_FILE,
|
||||
@@ -93,13 +97,15 @@ class TlogDestinationFile extends AbstractTlogDestination {
|
||||
);
|
||||
}
|
||||
|
||||
public function ajouter($texte) {
|
||||
public function ajouter($texte)
|
||||
{
|
||||
if ($this->fh) {
|
||||
fwrite($this->fh, $texte."\n");
|
||||
}
|
||||
}
|
||||
|
||||
public function ecrire(&$res) {
|
||||
public function ecrire(&$res)
|
||||
{
|
||||
if ($this->fh) @fclose($this->fh);
|
||||
|
||||
$this->fh = false;
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace Thelia\Log\Destination;
|
||||
|
||||
use Thelia\Log\AbstractTlogDestination;
|
||||
|
||||
class TlogDestinationHtml extends AbstractTlogDestination {
|
||||
|
||||
class TlogDestinationHtml extends AbstractTlogDestination
|
||||
{
|
||||
// Nom des variables de configuration
|
||||
// ----------------------------------
|
||||
const VAR_STYLE = "tlog_destinationhtml_style";
|
||||
@@ -34,24 +34,29 @@ class TlogDestinationHtml extends AbstractTlogDestination {
|
||||
|
||||
private $style;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
public function configurer($config = false) {
|
||||
public function configurer($config = false)
|
||||
{
|
||||
$this->style = $this->get_config(self::VAR_STYLE);
|
||||
}
|
||||
|
||||
public function get_titre() {
|
||||
public function get_titre()
|
||||
{
|
||||
return "Affichage direct dans la page, en HTML";
|
||||
}
|
||||
|
||||
public function get_description() {
|
||||
public function get_description()
|
||||
{
|
||||
return "Permet d'afficher les logs directement dans la page resultat, avec une mise en forme HTML.";
|
||||
}
|
||||
|
||||
public function get_configs() {
|
||||
public function get_configs()
|
||||
{
|
||||
// return array(
|
||||
// new TlogDestinationConfig(
|
||||
// self::VAR_STYLE,
|
||||
@@ -63,8 +68,8 @@ class TlogDestinationHtml extends AbstractTlogDestination {
|
||||
// );
|
||||
}
|
||||
|
||||
public function ecrire(&$res) {
|
||||
|
||||
public function ecrire(&$res)
|
||||
{
|
||||
$block = sprintf('<pre class="tlog-trace" style="%s">%s</pre>', $this->style, htmlspecialchars(implode("\n", $this->_logs)));
|
||||
|
||||
$this->inserer_apres_body($res, $block);
|
||||
|
||||
@@ -25,21 +25,25 @@ namespace Thelia\Log\Destination;
|
||||
|
||||
use Thelia\Log\AbstractTlogDestination;
|
||||
|
||||
class TlogDestinationNull extends AbstractTlogDestination {
|
||||
|
||||
public function get_titre() {
|
||||
class TlogDestinationNull extends AbstractTlogDestination
|
||||
{
|
||||
public function get_titre()
|
||||
{
|
||||
return "Trou noir";
|
||||
}
|
||||
|
||||
public function get_description() {
|
||||
public function get_description()
|
||||
{
|
||||
return "Cette destination ne provoque aucune sortie";
|
||||
}
|
||||
|
||||
public function ajouter($string) {
|
||||
public function ajouter($string)
|
||||
{
|
||||
// Rien
|
||||
}
|
||||
|
||||
public function ecrire(&$res) {
|
||||
public function ecrire(&$res)
|
||||
{
|
||||
// Rien
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,26 +25,30 @@ namespace Thelia\Log\Destination;
|
||||
|
||||
use Thelia\Log\AbstractTlogDestination;
|
||||
|
||||
|
||||
class TlogDestinationText extends AbstractTlogDestination {
|
||||
|
||||
public function __construct() {
|
||||
class TlogDestinationText extends AbstractTlogDestination
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function get_titre() {
|
||||
public function get_titre()
|
||||
{
|
||||
return "Affichage direct dans la page, en texte brut";
|
||||
}
|
||||
|
||||
public function get_description() {
|
||||
public function get_description()
|
||||
{
|
||||
return "Permet d'afficher les logs directement dans la page resultat, au format texte brut.";
|
||||
}
|
||||
|
||||
public function ajouter($texte) {
|
||||
public function ajouter($texte)
|
||||
{
|
||||
echo $texte."\n";
|
||||
}
|
||||
|
||||
public function ecrire(&$res) {
|
||||
public function ecrire(&$res)
|
||||
{
|
||||
// Rien
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,8 @@ class Tlog Implements TlogInterface
|
||||
// return self::$instance;
|
||||
// }
|
||||
|
||||
protected function init() {
|
||||
protected function init()
|
||||
{
|
||||
$config = $this->container->get("model.config");
|
||||
|
||||
$level = $config->read(self::VAR_LEVEL, self::DEFAULT_LEVEL);
|
||||
@@ -131,7 +132,8 @@ class Tlog Implements TlogInterface
|
||||
// Configuration
|
||||
// -------------
|
||||
|
||||
public function set_destinations($destinations) {
|
||||
public function set_destinations($destinations)
|
||||
{
|
||||
if (! empty($destinations)) {
|
||||
|
||||
$this->destinations = array();
|
||||
@@ -141,40 +143,44 @@ class Tlog Implements TlogInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function set_level($level) {
|
||||
public function set_level($level)
|
||||
{
|
||||
$this->level = $level;
|
||||
}
|
||||
|
||||
public function set_prefixe($prefixe) {
|
||||
|
||||
public function set_prefixe($prefixe)
|
||||
{
|
||||
$this->prefixe = $prefixe;
|
||||
}
|
||||
|
||||
public function set_files($files) {
|
||||
public function set_files($files)
|
||||
{
|
||||
$this->files = explode(";", $files);
|
||||
|
||||
$this->all_files = in_array('*', $this->files);
|
||||
}
|
||||
|
||||
public function set_ip($ips) {
|
||||
public function set_ip($ips)
|
||||
{
|
||||
if (! empty($ips) && ! in_array($_SERVER['REMOTE_ADDR'], explode(";", $ips))) $this->level = self::MUET;
|
||||
}
|
||||
|
||||
public function set_show_redirect($bool) {
|
||||
public function set_show_redirect($bool)
|
||||
{
|
||||
$this->show_redirect = $bool;
|
||||
}
|
||||
|
||||
// Configuration d'une destination
|
||||
public function set_config($destination, $param, $valeur) {
|
||||
|
||||
public function set_config($destination, $param, $valeur)
|
||||
{
|
||||
if (isset($this->destinations[$destination])) {
|
||||
$this->destinations[$destination]->set_config($param, $valeur);
|
||||
}
|
||||
}
|
||||
|
||||
// Configuration d'une destination
|
||||
public function get_config($destination, $param) {
|
||||
|
||||
public function get_config($destination, $param)
|
||||
{
|
||||
if (isset($this->destinations[$destination])) {
|
||||
return $this->destinations[$destination]->get_config($param);
|
||||
}
|
||||
@@ -185,7 +191,8 @@ class Tlog Implements TlogInterface
|
||||
// Methodes d'accès aux traces
|
||||
// ---------------------------
|
||||
|
||||
public function trace() {
|
||||
public function trace()
|
||||
{
|
||||
if ($this->level > self::TRACE)
|
||||
return;
|
||||
|
||||
@@ -194,7 +201,8 @@ class Tlog Implements TlogInterface
|
||||
$this->out("TRACE", $args);
|
||||
}
|
||||
|
||||
public function debug() {
|
||||
public function debug()
|
||||
{
|
||||
if ($this->level > self::DEBUG)
|
||||
return;
|
||||
|
||||
@@ -203,7 +211,8 @@ class Tlog Implements TlogInterface
|
||||
$this->out("DEBUG", $args);
|
||||
}
|
||||
|
||||
public function info() {
|
||||
public function info()
|
||||
{
|
||||
if ($this->level > self::INFO)
|
||||
return;
|
||||
|
||||
@@ -212,7 +221,8 @@ class Tlog Implements TlogInterface
|
||||
$this->out("INFO", $args);
|
||||
}
|
||||
|
||||
public function warning() {
|
||||
public function warning()
|
||||
{
|
||||
if ($this->level > self::WARNING)
|
||||
return;
|
||||
|
||||
@@ -221,7 +231,8 @@ class Tlog Implements TlogInterface
|
||||
$this->out("WARNING", $args);
|
||||
}
|
||||
|
||||
public function error() {
|
||||
public function error()
|
||||
{
|
||||
if ($this->level > self::ERROR)
|
||||
return;
|
||||
|
||||
@@ -230,7 +241,8 @@ class Tlog Implements TlogInterface
|
||||
$this->out("ERREUR", $args);
|
||||
}
|
||||
|
||||
public function fatal() {
|
||||
public function fatal()
|
||||
{
|
||||
if ($this->level > self::FATAL)
|
||||
return;
|
||||
|
||||
@@ -240,16 +252,16 @@ class Tlog Implements TlogInterface
|
||||
}
|
||||
|
||||
// Mode back office
|
||||
public static function mode_back_office($booleen) {
|
||||
|
||||
public static function mode_back_office($booleen)
|
||||
{
|
||||
foreach (Tlog::instance()->destinations as $dest) {
|
||||
$dest->mode_back_office($booleen);
|
||||
}
|
||||
}
|
||||
|
||||
// Ecriture finale
|
||||
public function ecrire(&$res) {
|
||||
|
||||
public function ecrire(&$res)
|
||||
{
|
||||
self::$ecrire_effectue = true;
|
||||
|
||||
// Muet ? On ne fait rien
|
||||
@@ -260,7 +272,8 @@ class Tlog Implements TlogInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function ecrire_si_exit() {
|
||||
public function ecrire_si_exit()
|
||||
{
|
||||
// Si les infos de debug n'ont pas été ecrites, le faire maintenant
|
||||
if (self::$ecrire_effectue === false) {
|
||||
|
||||
@@ -272,8 +285,8 @@ class Tlog Implements TlogInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function afficher_redirections($url) {
|
||||
|
||||
public function afficher_redirections($url)
|
||||
{
|
||||
if ($this->level != self::MUET && $this->show_redirect) {
|
||||
echo "
|
||||
<html>
|
||||
@@ -285,16 +298,15 @@ class Tlog Implements TlogInterface
|
||||
";
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Permet de déterminer si la trace est active, en prenant en compte
|
||||
// le level et le filtrage par fichier
|
||||
public function active($level) {
|
||||
|
||||
public function active($level)
|
||||
{
|
||||
if ($this->level <= $level) {
|
||||
|
||||
$origine = $this->trouver_origine();
|
||||
@@ -309,15 +321,16 @@ class Tlog Implements TlogInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
public function is_file_active($file) {
|
||||
public function is_file_active($file)
|
||||
{
|
||||
return ($this->all_files || in_array($file, $this->files)) && ! in_array("!$file", $this->files);
|
||||
}
|
||||
|
||||
/* -- Methodes privees ---------------------------------------- */
|
||||
|
||||
// Adapté de LoggerLoginEvent dans log4php
|
||||
private function trouver_origine() {
|
||||
|
||||
private function trouver_origine()
|
||||
{
|
||||
$origine = array();
|
||||
|
||||
if (function_exists('debug_backtrace')) {
|
||||
@@ -359,8 +372,8 @@ class Tlog Implements TlogInterface
|
||||
return $origine;
|
||||
}
|
||||
|
||||
private function out($level, $tabargs) {
|
||||
|
||||
private function out($level, $tabargs)
|
||||
{
|
||||
$text = '';
|
||||
|
||||
foreach ($tabargs as $arg) {
|
||||
@@ -397,16 +410,13 @@ class Tlog Implements TlogInterface
|
||||
* @param type $destinations
|
||||
* @param array $actives array containing classes instanceof AbstractTlogDestination
|
||||
*/
|
||||
protected function loadDestinations(&$destinations, array $actives = NULL) {
|
||||
|
||||
foreach($actives as $active)
|
||||
{
|
||||
if(class_exists($active))
|
||||
protected function loadDestinations(&$destinations, array $actives = NULL)
|
||||
{
|
||||
foreach ($actives as $active) {
|
||||
if (class_exists($active)) {
|
||||
$class = new $active($this->container->get('model.config'));
|
||||
|
||||
if(!$class instanceof AbstractTlogDestination)
|
||||
{
|
||||
if (!$class instanceof AbstractTlogDestination) {
|
||||
throw new \UnexpectedValueException($active." must extends Thelia\Tlog\AbstractTlogDestination");
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ class TlogDestinationConfig
|
||||
public $type;
|
||||
public $valeur;
|
||||
|
||||
public function __construct($nom, $titre, $label, $defaut, $type, $config = null) {
|
||||
|
||||
public function __construct($nom, $titre, $label, $defaut, $type, $config = null)
|
||||
{
|
||||
$this->nom = $nom;
|
||||
$this->titre = $titre;
|
||||
$this->label = $label;
|
||||
@@ -45,8 +45,7 @@ class TlogDestinationConfig
|
||||
|
||||
// @$this->charger();
|
||||
|
||||
if($config)
|
||||
{
|
||||
if ($config) {
|
||||
$this->valeur = $config->read($this->nom, $this->defaut);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Thelia\Log;
|
||||
|
||||
|
||||
Interface TlogInterface
|
||||
{
|
||||
|
||||
|
||||
@@ -6,50 +6,45 @@ use Thelia\Model\Base\Base;
|
||||
|
||||
class Accessory extends Base
|
||||
{
|
||||
protected $id;
|
||||
|
||||
protected $product_id;
|
||||
protected $accessory;
|
||||
protected $position;
|
||||
|
||||
protected $properties = array(
|
||||
"id",
|
||||
"product_id",
|
||||
"accessory",
|
||||
"position"
|
||||
);
|
||||
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getProductId() {
|
||||
public function getProductId()
|
||||
{
|
||||
return $this->product_id;
|
||||
}
|
||||
|
||||
public function setProductId($product_id) {
|
||||
public function setProductId($product_id)
|
||||
{
|
||||
$this->product_id = $product_id;
|
||||
}
|
||||
|
||||
public function getAccessory() {
|
||||
public function getAccessory()
|
||||
{
|
||||
return $this->accessory;
|
||||
}
|
||||
|
||||
public function setAccessory($accessory) {
|
||||
public function setAccessory($accessory)
|
||||
{
|
||||
$this->accessory = $accessory;
|
||||
}
|
||||
|
||||
public function getPosition() {
|
||||
public function getPosition()
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
public function setPosition($position) {
|
||||
public function setPosition($position)
|
||||
{
|
||||
$this->position = $position;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,11 @@ namespace Thelia\Model\Base;
|
||||
*/
|
||||
abstract class Base
|
||||
{
|
||||
/**
|
||||
* Primary key
|
||||
* @var int
|
||||
*/
|
||||
protected $id;
|
||||
/**
|
||||
*
|
||||
* @var \NotORM
|
||||
@@ -45,15 +50,21 @@ abstract class Base
|
||||
*/
|
||||
protected $updated_at;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string date when the record had been saved
|
||||
*/
|
||||
protected $created_at;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* base properties for all models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $baseProperties = array(
|
||||
"created_at",
|
||||
"update_at"
|
||||
);
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -61,43 +72,96 @@ abstract class Base
|
||||
*
|
||||
* @param \NotORM $NotORM
|
||||
*/
|
||||
public function __construct(\NotORM $NotORM) {
|
||||
public function __construct(\NotORM $NotORM)
|
||||
{
|
||||
$this->db = $NotORM;
|
||||
$this->table = $this->getTableName();
|
||||
}
|
||||
|
||||
public function getUpdatedAt() {
|
||||
public function getUpdatedAt()
|
||||
{
|
||||
return $this->updated_at;
|
||||
}
|
||||
|
||||
public function setUpdatedAt($updated_at) {
|
||||
public function setUpdatedAt($updated_at)
|
||||
{
|
||||
$this->updated_at = $updated_at;
|
||||
}
|
||||
|
||||
public function getCreatedAt() {
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->created_at;
|
||||
}
|
||||
|
||||
public function setCreatedAt($created_at) {
|
||||
public function setCreatedAt($created_at)
|
||||
{
|
||||
$this->created_at = $created_at;
|
||||
}
|
||||
|
||||
private function getBaseProperties()
|
||||
{
|
||||
return $this->baseProperties;
|
||||
}
|
||||
|
||||
public function getProperties()
|
||||
{
|
||||
return $this->properties;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return \NotORM
|
||||
*/
|
||||
public function getDb() {
|
||||
public function getDb()
|
||||
{
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
public function getTable() {
|
||||
public function getTable()
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->updated_at = $this->created_at = date('Y-m-d H:i:s');
|
||||
|
||||
$values = $this->prepare();
|
||||
|
||||
// $this->db->insert_update(
|
||||
// array("id", $this->getId()),
|
||||
// $values,
|
||||
//
|
||||
// );
|
||||
|
||||
}
|
||||
|
||||
private function prepare()
|
||||
{
|
||||
$properties = array_merge($this->getBaseProperties(), $this->getProperties());
|
||||
|
||||
$values = array();
|
||||
|
||||
foreach ($properties as $property) {
|
||||
$values[$property] = $this->$property;
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
public function isNew()
|
||||
{
|
||||
return $this->getId() ? false:true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,6 +190,7 @@ abstract class Base
|
||||
$tmp = str_replace('::', '/', $tmp);
|
||||
$tmp = self::pregtr($tmp, array('/([A-Z]+)([A-Z][a-z])/' => '\\1_\\2',
|
||||
'/([a-z\d])([A-Z])/' => '\\1_\\2'));
|
||||
|
||||
return strtolower($tmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
|
||||
namespace Thelia\Tests\Log;
|
||||
|
||||
use Thelia\Log\Tlog;
|
||||
@@ -33,7 +32,8 @@ class TlogTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected $regex = "/(\\d)(.)(\\s+)((?:[a-z][a-z]+))(\\s+)(\\[.*?\\])(\\s+)(\\{.*?\\})(\\s+)((?:2|1)\\d{3}(?:-|\\/)(?:(?:0[1-9])|(?:1[0-2]))(?:-|\\/)(?:(?:0[1-9])|(?:[1-2][0-9])|(?:3[0-1]))(?:T|\\s)(?:(?:[0-1][0-9])|(?:2[0-3])):(?:[0-5][0-9]):(?:[0-5][0-9]))(.)(\\s+)(%s)/is";
|
||||
|
||||
public function setUp() {
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
@@ -50,7 +50,6 @@ class TlogTest extends \PHPUnit_Framework_TestCase
|
||||
->with($this->stringContains("logger.class"))
|
||||
->will($this->returnValue("Thelia\Log\Tlog"));
|
||||
|
||||
|
||||
$this->logger = new Tlog($containerMock);
|
||||
|
||||
$this->logger->set_destinations("Thelia\Log\Destination\TlogDestinationText");
|
||||
@@ -179,10 +178,10 @@ class TlogTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ConfigModel
|
||||
{
|
||||
public function __call($name, $arguments) {
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
return $arguments[1];
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,5 @@ class DIGeneratorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$models = DIGenerator::genDiModel(__DIR__ . '/wrongDirectory');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
namespace Thelia\Tests\Tools\_files;
|
||||
|
||||
class A {
|
||||
|
||||
class A
|
||||
{
|
||||
}
|
||||
|
||||
@@ -39,8 +39,7 @@ class DIGenerator
|
||||
{
|
||||
if(!is_string($directory)) return array();
|
||||
|
||||
if(!is_dir($directory))
|
||||
{
|
||||
if (!is_dir($directory)) {
|
||||
throw new \RuntimeException($directory." is not a valid directory");
|
||||
}
|
||||
|
||||
@@ -48,8 +47,7 @@ class DIGenerator
|
||||
|
||||
$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory));
|
||||
|
||||
foreach($files as $file)
|
||||
{
|
||||
foreach ($files as $file) {
|
||||
//$file is instance of SplFileInfo
|
||||
if(!$file->isFile()) continue;
|
||||
|
||||
@@ -57,12 +55,10 @@ class DIGenerator
|
||||
|
||||
$classes = self::findClasses($filePath);
|
||||
|
||||
foreach($classes as $class)
|
||||
{
|
||||
foreach ($classes as $class) {
|
||||
$classInfo = new \ReflectionClass($class);
|
||||
$shortName = $classInfo->getShortName();
|
||||
if(!in_array($shortName, $exclude))
|
||||
{
|
||||
if (!in_array($shortName, $exclude)) {
|
||||
$results[$shortName] = $class;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user