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.
This commit is contained in:
mark_story 2010-09-14 23:02:38 -04:00
parent 273a189e98
commit f34cfd1f1e
3 changed files with 13 additions and 3 deletions

View file

@ -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');
}

View file

@ -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));
}

View file

@ -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));