Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow CakeEmail::template() to disable layout rendering.

Fix the code to act as documented. Sending template('view', null) should
disable layout rendering.

Fixes #3983
  • Loading branch information...
commit cb6ea82fea919eff667aa5c79debf3d09a1522d6 1 parent 3bdcf7b
@markstory markstory authored
View
5 lib/Cake/Network/Email/CakeEmail.php
@@ -1573,6 +1573,11 @@ protected function _renderTemplates($content) {
if ($this->_theme) {
$View->theme = $this->_theme;
}
+ // Convert null to false, as View needs false to disable
+ // the layout.
+ if ($layout === null) {
+ $layout = false;
+ }
foreach ($types as $type) {
$View->set('content', $content);
View
20 lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
@@ -1049,6 +1049,26 @@ public function testSendRender() {
}
/**
+ * test sending and rendering with no layout
+ *
+ * @return void
+ */
+ public function testSendRenderNoLayout() {
+ $this->CakeEmail->reset();
+ $this->CakeEmail->transport('debug');
+
+ $this->CakeEmail->from('cake@cakephp.org');
+ $this->CakeEmail->to(array('you@cakephp.org' => 'You'));
+ $this->CakeEmail->subject('My title');
+ $this->CakeEmail->config(array('empty'));
+ $this->CakeEmail->template('default', null);
+ $result = $this->CakeEmail->send('message body.');
+
+ $this->assertContains('message body.', $result['message']);
+ $this->assertNotContains('This email was sent using the CakePHP Framework', $result['message']);
+ }
+
+/**
* testSendRender method for ISO-2022-JP
*
* @return void
Please sign in to comment.
Something went wrong with that request. Please try again.