70ea4e5799cde380e93c6425c6f6ca99185e3580
Author: Mark Story
Date: 2009-08-24 23:57:41 -0400
diff --git a/controllers/components/toolbar.php b/controllers/components/toolbar.php
index b297dc2..2889241 100644
--- a/controllers/components/toolbar.php
+++ b/controllers/components/toolbar.php
@@ -21,9 +21,16 @@ class ToolbarComponent extends Object {
/**
* Settings for the Component
*
+ * - forceEnable - Force the toolbar to display even if debug == 0. Default = false
+ * - autoRun - Automatically display the toolbar. If set to false, toolbar display can be triggered by adding
+ * `?debug=true` to your URL.
+ *
* @var array
**/
- var $settings = array();
+ var $settings = array(
+ 'forceEnable' => false,
+ 'autoRun' => true
+ );
/**
* Controller instance reference
*
@@ -83,6 +90,10 @@ class ToolbarComponent extends Object {
$this->enabled = false;
return false;
}
+ if ($this->settings['autoRun'] == false && !isset($controller->params['url']['debug'])) {
+ $this->enabled = false;
+ return false;
+ }
App::import('Vendor', 'DebugKit.DebugKitDebugger');
DebugKitDebugger::setMemoryPoint(__d('debug_kit', 'Component intitailization', true));
diff --git a/tests/cases/controllers/components/toolbar.test.php b/tests/cases/controllers/components/toolbar.test.php
index 3a8425a..c533a1f 100644
--- a/tests/cases/controllers/components/toolbar.test.php
+++ b/tests/cases/controllers/components/toolbar.test.php
@@ -256,6 +256,29 @@ class DebugToolbarTestCase extends CakeTestCase {
Configure::write('debug', $_debug);
}
/**
+ * Test disabling autoRunning of toolbar
+ *
+ * @return void
+ **/
+ function testAutoRunSettingFalse() {
+ $this->Controller->components = array('DebugKit.Toolbar' => array('autoRun' => false));
+ $this->Controller->Component->init($this->Controller);
+ $this->Controller->Component->initialize($this->Controller);
+ $this->assertFalse($this->Controller->Toolbar->enabled);
+ }
+/**
+ * test autorun = false with query string param
+ *
+ * @return void
+ **/
+ function testAutoRunSettingWithQueryString() {
+ $this->Controller->params['url']['debug'] = true;
+ $this->Controller->components = array('DebugKit.Toolbar' => array('autoRun' => false));
+ $this->Controller->Component->init($this->Controller);
+ $this->Controller->Component->initialize($this->Controller);
+ $this->assertTrue($this->Controller->Toolbar->enabled);
+ }
+/**
* test startup
*
* @return void
