Added profiler options.

This commit is contained in:
Josh Sherman 2010-10-22 00:31:26 -04:00
parent 58a4254738
commit 92e4b0391a
4 changed files with 47 additions and 15 deletions

View file

@ -41,6 +41,15 @@ class Object
*/
protected $config = null;
/**
* Profiler flag
*
*
* @access private
* @var mixed
*/
private $profiler = false;
/**
* Constructor
*
@ -48,6 +57,7 @@ class Object
*/
public function __construct()
{
// Gets an instance of the config, unless we ARE the config
if (get_class($this) == 'Config')
{
$this->config = true;
@ -56,9 +66,12 @@ class Object
{
$this->config = Config::getInstance();
}
// Assigns the profiler flag
$this->profiler = (isset($this->config->pickles['profiler']) && $this->config->pickles['profiler'] != '' ? $this->config->pickles['profiler'] : false);
// Optionally logs the constructor to the profiler
if ($this->config == true || (isset($this->config->pickles['profiler']) && $this->config->pickles['profiler'] == true))
if ($this->profiler === true || ((is_array($this->profiler) && in_array('objects', $this->profiler)) || stripos($this->profiler, 'objects') !== false))
{
Profiler::log($this, '__construct');
}
@ -99,7 +112,7 @@ class Object
public function __destruct()
{
// Optionally logs the destructor to the profiler
if ($this->config == true || (isset($this->config->pickles['profiler']) && $this->config->pickles['profiler'] == true))
if ($this->profiler === true || ((is_array($this->profiler) && in_array('objects', $this->profiler)) || stripos($this->profiler, 'objects') !== false))
{
Profiler::log($this, '__destruct');
}