From f34cfd1f1ec026481997539590394121bb9c0e1d Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 14 Sep 2010 23:02:38 -0400 Subject: [PATCH] Updating EmailComponent to use new methods on the ComponentCollection to ensure it always has a controller reference. Removing triggerDisabled key as its no longer needed or wanted. --- cake/libs/controller/components/email.php | 12 +++++++++++- cake/libs/controller/controller.php | 2 +- cake/tests/cases/libs/controller/controller.test.php | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index b22806895..d0aab867b 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -298,13 +298,23 @@ class EmailComponent extends Component { */ protected $_smtpConnection = null; +/** + * Constructor + * + * @param ComponentCollection $collection A ComponentCollection this component can use to lazy load its components + * @param array $settings Array of configuration settings. + */ + public function __construct(ComponentCollection $collection, $settings = array()) { + $this->Controller = $collection->getController(); + parent::__construct($collection, $settings); + } + /** * Initialize component * * @param object $controller Instantiating controller */ public function initialize(&$controller) { - $this->Controller = $controller; if (Configure::read('App.encoding') !== null) { $this->charset = Configure::read('App.encoding'); } diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 07e0b8f59..0b2e55c35 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -533,7 +533,7 @@ class Controller extends Object { * @return void */ public function startupProcess() { - $this->Components->trigger('initialize', array(&$this), array('triggerDisabled' => true)); + $this->Components->trigger('initialize', array(&$this)); $this->beforeFilter(); $this->Components->trigger('startup', array(&$this)); } diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 20eb72642..5ad875016 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -1478,7 +1478,7 @@ class ControllerTest extends CakeTestCase { $Controller->expects($this->once())->method('beforeFilter'); $Controller->Components->expects($this->at(0))->method('trigger') - ->with('initialize', array(&$Controller), array('triggerDisabled' => true)); + ->with('initialize', array(&$Controller)); $Controller->Components->expects($this->at(1))->method('trigger') ->with('startup', array(&$Controller));