Skip to content

Commit

Permalink
Added the support to set variables in component.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Apr 17, 2011
1 parent b2f948d commit 88f2c19
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/Cake/Controller/Component/EmailComponent.php
Expand Up @@ -269,6 +269,24 @@ class EmailComponent extends Component {
*/
public $messageId = true;

/**
* Controller reference
*
* @var object Controller
*/
protected $_controller = 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
*
Expand Down Expand Up @@ -330,7 +348,7 @@ public function send($content = null, $template = null, $layout = null) {
if ($layout) {
$this->layout = $layout;
}
$lib->layout($this->layout, $this->template)->emailFormat($this->sendAs);
$lib->layout($this->layout, $this->template)->viewVars($this->_controller->viewVars)->emailFormat($this->sendAs);

if (!empty($this->attachments)) {
$lib->attachments($this->_formatAttachFiles());
Expand Down
Expand Up @@ -272,6 +272,7 @@ function testTemplates() {

$this->Controller->EmailTest->layout = 'default';
$this->Controller->EmailTest->template = 'default';
$this->Controller->set('title_for_layout', 'Email Test');

$text = <<<TEXTBLOC
Expand Down

0 comments on commit 88f2c19

Please sign in to comment.