Skip to content

Commit

Permalink
Fusion des logs en session et en variable temporaire dans le Logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Simounet committed Mar 25, 2016
1 parent 95d7b72 commit d011d98
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Logger.class.php
Expand Up @@ -29,9 +29,12 @@ protected function destroy(){
unset($_SESSION[self::LOGGER_IDENTIFIER][$this->getName()]);
}

protected function isEmpty(){
return ! isset($_SESSION[self::LOGGER_IDENTIFIER][$this->getName()])
|| empty($_SESSION[self::LOGGER_IDENTIFIER][$this->getName()]);
protected function mergeLogsInSession(){
if( isset($_SESSION[self::LOGGER_IDENTIFIER][$this->getName()])
|| !empty($_SESSION[self::LOGGER_IDENTIFIER][$this->getName()])
) {
$this->logs = array_unique(array_merge($this->logs, unserialize($_SESSION[self::LOGGER_IDENTIFIER][$this->getName()])));
}
}

public function setName($name)
Expand All @@ -51,10 +54,8 @@ public function setLogs($logs)

public function getLogs()
{
if($this->isEmpty()){
return $this->logs;
}
return unserialize( $_SESSION[self::LOGGER_IDENTIFIER][$this->getName()] );
$this->mergeLogsInSession();
return $this->logs;
}

}
Expand Down

0 comments on commit d011d98

Please sign in to comment.