mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Allow setting only default layout without specifying template in email config.
Closes #3336
This commit is contained in:
parent
bd5ce96388
commit
ead494eec1
2 changed files with 26 additions and 7 deletions
|
@ -1224,15 +1224,14 @@ class CakeEmail {
|
|||
$this->setHeaders($config['headers']);
|
||||
unset($config['headers']);
|
||||
}
|
||||
|
||||
if (array_key_exists('template', $config)) {
|
||||
$layout = false;
|
||||
if (array_key_exists('layout', $config)) {
|
||||
$layout = $config['layout'];
|
||||
unset($config['layout']);
|
||||
}
|
||||
$this->template($config['template'], $layout);
|
||||
unset($config['template']);
|
||||
$this->_template = $config['template'];
|
||||
}
|
||||
if (array_key_exists('layout', $config)) {
|
||||
$this->_layout = $config['layout'];
|
||||
}
|
||||
|
||||
$this->transportClass()->config($config);
|
||||
}
|
||||
|
||||
|
|
|
@ -1807,6 +1807,26 @@ class CakeEmailTest extends CakeTestCase {
|
|||
$this->assertTrue((bool)strpos($result['headers'], 'To: '));
|
||||
}
|
||||
|
||||
/**
|
||||
* testConfigArrayWithLayoutWithoutTemplate method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConfigArrayWithLayoutWithoutTemplate() {
|
||||
$configs = array(
|
||||
'from' => array('some@example.com' => 'My website'),
|
||||
'to' => 'test@example.com',
|
||||
'subject' => 'Test mail subject',
|
||||
'transport' => 'Debug',
|
||||
'layout' => 'custom'
|
||||
);
|
||||
$this->CakeEmail = new CakeEmail($configs);
|
||||
|
||||
$result = $this->CakeEmail->template();
|
||||
$this->assertEquals('', $result['template']);
|
||||
$this->assertEquals($configs['layout'], $result['layout']);
|
||||
}
|
||||
|
||||
/**
|
||||
* testConstructWithConfigString method
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue