Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Add Nooku::isCache() and Nooku::isDebug() methods
Browse files Browse the repository at this point in the history
  • Loading branch information
johanjanssens committed Apr 27, 2015
1 parent 57394a6 commit 08708bb
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 11 deletions.
3 changes: 0 additions & 3 deletions config/bootstrapper.php-empty
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ return array(
'translator' => [

//Cache Settings
'cache' => false,
'cache_namespace' => APPLICATION_NAME,

],
Expand Down Expand Up @@ -84,8 +83,6 @@ return array(
'template.engine.factory' => [

//Cache Settings
'debug' => false,
'cache' => false,
'cache_path' => APPLICATION_BASE.'/cache',
'cache_reload' => false,
'engines' => [
Expand Down
70 changes: 70 additions & 0 deletions library/nooku.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ class Nooku
*/
const VERSION = '1.0-alpha';

/**
* Debug state
*
* @var boolean
*/
protected $_debug;

/**
* Cache state
*
* @var boolean
*/
protected $_cache;

/**
* The root path
*
Expand Down Expand Up @@ -54,6 +68,20 @@ class Nooku
*/
final private function __construct($config = array())
{
//Initialize the debug state
if(isset($config['debug'])) {
$this->_debug = $config['debug'];
} else {
$this->_debug = false;
}

//Initialize the debug state
if(isset($config['cache'])) {
$this->_cache = $config['cache'];
} else {
$this->_cache = false;
}

//Initialize the root path
if(isset($config['root_path'])) {
$this->_root_path = $config['root_path'];
Expand Down Expand Up @@ -175,4 +203,46 @@ public function getBasePath()
{
return $this->_base_path;
}

/**
* Enable or disable debug
*
* @param bool $debug True or false.
* @return Nooku
*/
public function setDebug($debug)
{
return $this->_debug = (bool) $debug;
}

/**
* Check if debug is enabled
*
* @return bool
*/
public function isDebug()
{
return $this->_debug;
}

/**
* Enable or disable the cache
*
* @param bool $cache True or false.
* @return Nooku
*/
public function setCache($cache)
{
return $this->_cache = (bool) $cache;
}

/**
* Check if caching is enabled
*
* @return bool
*/
public function isCache()
{
return $this->_cache;
}
}
4 changes: 2 additions & 2 deletions library/template/engine/abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public function __construct(ObjectConfig $config)
protected function _initialize(ObjectConfig $config)
{
$config->append(array(
'debug' => false,
'cache' => false,
'debug' => \Nooku::getInstance()->isDebug(),
'cache' => \Nooku::getInstance()->isCache(),
'cache_path' => '',
'cache_reload' => true,
'template' => 'default',
Expand Down
4 changes: 2 additions & 2 deletions library/template/engine/factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public function __construct( ObjectConfig $config)
protected function _initialize(ObjectConfig $config)
{
$config->append(array(
'debug' => false,
'cache' => false,
'debug' => \Nooku::getInstance()->isDebug(),
'cache' => \Nooku::getInstance()->isCache(),
'cache_path' => '',
'engines' => array(
'lib:template.engine.nooku'
Expand Down
2 changes: 1 addition & 1 deletion library/template/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function _initialize(ObjectConfig $config)
'helper' => array($this, 'invoke'),
'parameters' => array($this, 'getParameters')
),
'cache' => false,
'cache' => \Nooku::getInstance()->isCache(),
'cache_namespace' => 'nooku',
));

Expand Down
6 changes: 3 additions & 3 deletions library/translator/abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function _initialize(ObjectConfig $config)
$config->append(array(
'locale' => 'en-GB',
'locale_fallback' => 'en-GB',
'cache' => false,
'cache' => \Nooku::getInstance()->isCache(),
'cache_namespace' => 'nooku',
'catalogue' => 'default',
));
Expand Down Expand Up @@ -108,12 +108,12 @@ public static function getInstance(ObjectConfig $config, ObjectManagerInterface

return $instance;
}

/**
* Translates a string and handles parameter replacements
*
* Parameters are wrapped in curly braces. So {foo} would be replaced with bar given that $parameters['foo'] = 'bar'
*
*
* @param string $string String to translate
* @param array $parameters An array of parameters
* @return string Translated string
Expand Down

0 comments on commit 08708bb

Please sign in to comment.