mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Making EmailComponent register and un-register its view object, when rendering email templates. This allows helpers to use the view to do additional processing. Fixes #442
This commit is contained in:
parent
c5c638e8f5
commit
5092013304
2 changed files with 8 additions and 1 deletions
|
@ -458,7 +458,7 @@ class EmailComponent extends Object{
|
|||
App::import('View', $this->Controller->view);
|
||||
}
|
||||
|
||||
$View = new $viewClass($this->Controller, false);
|
||||
$View = new $viewClass($this->Controller);
|
||||
$View->layout = $this->layout;
|
||||
$msg = array();
|
||||
|
||||
|
@ -496,6 +496,7 @@ class EmailComponent extends Object{
|
|||
$msg[] = '--alt-' . $this->__boundary . '--';
|
||||
$msg[] = '';
|
||||
|
||||
ClassRegistry::removeObject('view');
|
||||
return $msg;
|
||||
}
|
||||
|
||||
|
@ -525,6 +526,7 @@ class EmailComponent extends Object{
|
|||
}
|
||||
|
||||
$msg = array_merge($msg, $content);
|
||||
ClassRegistry::removeObject('view');
|
||||
|
||||
return $msg;
|
||||
}
|
||||
|
|
|
@ -538,6 +538,8 @@ MSGBLOC;
|
|||
* @return void
|
||||
*/
|
||||
function testTemplates() {
|
||||
ClassRegistry::flush();
|
||||
|
||||
$this->Controller->EmailTest->to = 'postmaster@localhost';
|
||||
$this->Controller->EmailTest->from = 'noreply@example.com';
|
||||
$this->Controller->EmailTest->subject = 'Cake SMTP test';
|
||||
|
@ -629,6 +631,9 @@ HTMLBLOC;
|
|||
$expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html . '</pre>';
|
||||
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message', 'default', 'thin'));
|
||||
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
|
||||
|
||||
$result = ClassRegistry::getObject('view');
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue