mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Changed the method layout to template. Template is required to render, but layout is not.
This commit is contained in:
parent
38f5d9da1f
commit
7acdf1e436
2 changed files with 37 additions and 14 deletions
|
@ -638,22 +638,22 @@ class CakeEmail {
|
|||
}
|
||||
|
||||
/**
|
||||
* Layout and template
|
||||
* Template and layout
|
||||
*
|
||||
* @param string $layout
|
||||
* @param string $template
|
||||
* @param mixed $template Template name or null to not use
|
||||
* @param mixed $layout Layout name or null to not use
|
||||
* @return mixed
|
||||
*/
|
||||
public function layout($layout = null, $template = null) {
|
||||
if ($layout === null) {
|
||||
public function template($template = false, $layout = false) {
|
||||
if ($template === false) {
|
||||
return array(
|
||||
'layout' => $this->_layout,
|
||||
'template' => $this->_template
|
||||
'template' => $this->_template,
|
||||
'layout' => $this->_layout
|
||||
);
|
||||
}
|
||||
$this->_layout = (string)$layout;
|
||||
if ($template !== null) {
|
||||
$this->_template = (string)$template;
|
||||
$this->_template = $template;
|
||||
if ($layout !== false) {
|
||||
$this->_layout = $layout;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -409,7 +409,30 @@ class CakeEmailTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* testAttachments
|
||||
* testTemplate method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTemplate() {
|
||||
$this->CakeEmail->template('template', 'layout');
|
||||
$expected = array('template' => 'template', 'layout' => 'layout');
|
||||
$this->assertIdentical($this->CakeEmail->template(), $expected);
|
||||
|
||||
$this->CakeEmail->template('new_template');
|
||||
$expected = array('template' => 'new_template', 'layout' => 'layout');
|
||||
$this->assertIdentical($this->CakeEmail->template(), $expected);
|
||||
|
||||
$this->CakeEmail->template('template', null);
|
||||
$expected = array('template' => 'template', 'layout' => null);
|
||||
$this->assertIdentical($this->CakeEmail->template(), $expected);
|
||||
|
||||
$this->CakeEmail->template(null, null);
|
||||
$expected = array('template' => null, 'layout' => null);
|
||||
$this->assertIdentical($this->CakeEmail->template(), $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* testAttachments method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -510,7 +533,7 @@ class CakeEmailTest extends CakeTestCase {
|
|||
$this->CakeEmail->to(array('you@cakephp.org' => 'You'));
|
||||
$this->CakeEmail->subject('My title');
|
||||
$this->CakeEmail->config(array('empty'));
|
||||
$this->CakeEmail->layout('default', 'default');
|
||||
$this->CakeEmail->template('default', 'default');
|
||||
$result = $this->CakeEmail->send();
|
||||
|
||||
$this->assertTrue((bool)strpos(DebugTransport::$lastEmail, 'This email was sent using the CakePHP Framework'));
|
||||
|
@ -532,7 +555,7 @@ class CakeEmailTest extends CakeTestCase {
|
|||
$this->CakeEmail->to(array('you@cakephp.org' => 'You'));
|
||||
$this->CakeEmail->subject('My title');
|
||||
$this->CakeEmail->config(array('empty'));
|
||||
$this->CakeEmail->layout('default', 'custom');
|
||||
$this->CakeEmail->template('custom', 'default');
|
||||
$this->CakeEmail->viewVars(array('value' => 12345));
|
||||
$result = $this->CakeEmail->send();
|
||||
|
||||
|
@ -553,7 +576,7 @@ class CakeEmailTest extends CakeTestCase {
|
|||
$this->CakeEmail->to(array('you@cakephp.org' => 'You'));
|
||||
$this->CakeEmail->subject('My title');
|
||||
$this->CakeEmail->config(array('empty'));
|
||||
$this->CakeEmail->layout('default', 'default');
|
||||
$this->CakeEmail->template('default', 'default');
|
||||
$this->CakeEmail->emailFormat('both');
|
||||
$result = $this->CakeEmail->send();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue