Skip to content

Commit

Permalink
Updating EmailComponent to use new methods on the ComponentCollection…
Browse files Browse the repository at this point in the history
… to ensure it always has a controller reference.

Removing triggerDisabled key as its no longer needed or wanted.
  • Loading branch information
markstory committed Sep 15, 2010
1 parent 273a189 commit f34cfd1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion cake/libs/controller/components/email.php
Expand Up @@ -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');
}
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/controller/controller.php
Expand Up @@ -533,7 +533,7 @@ public function getResponse() {
* @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));
}
Expand Down
2 changes: 1 addition & 1 deletion cake/tests/cases/libs/controller/controller.test.php
Expand Up @@ -1478,7 +1478,7 @@ function testStartupProcess() {

$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));
Expand Down

0 comments on commit f34cfd1

Please sign in to comment.