create CakeRequest in View instead of in CakeEmail

This commit is contained in:
Rachman Chavik 2012-06-04 20:29:28 +07:00
parent e821c27f54
commit 8966f1b324
4 changed files with 7 additions and 19 deletions

View file

@ -1441,12 +1441,6 @@ class CakeEmail {
$View = new $viewClass(null);
$View->viewVars = $this->_viewVars;
$View->helpers = $this->_helpers;
if (!$request = Router::getRequest(true)) {
$request = new CakeRequest('/', false);
$request->base = '';
$request->here = $request->webroot = '/';
}
$View->request = $request;
list($templatePlugin, $template) = pluginSplit($this->_template);
list($layoutPlugin, $layout) = pluginSplit($this->_layout);

View file

@ -1044,18 +1044,7 @@ class CakeEmailTest extends CakeTestCase {
$this->CakeEmail->template('image');
$this->CakeEmail->emailFormat('html');
$View = new View();
$View->request = new CakeRequest('/', true);
$View->request->base = '';
$View->request->webroot = '/';
$View->request->here = '/';
$View->Helpers->load('Html');
$expected = $View->Html->image('image.gif', array(
'fullBase' => true, 'alt' => 'cool image',
'width' => 100, 'height' => 100,
));
$expected = '<img src="http://localhost/img/image.gif" alt="cool image" width="100" height="100" />';
$result = $this->CakeEmail->send();
$this->assertContains($expected, $result['message']);
}

View file

@ -324,7 +324,7 @@ object(View) {
validationErrors => array()
hasRendered => false
uuids => array()
request => null
request => object(CakeRequest) {}
response => object(CakeResponse) {}
elementCache => 'default'
int => (int) 2

View file

@ -314,6 +314,11 @@ class View extends Object {
}
$this->_eventManager = $controller->getEventManager();
}
if (empty($this->request) && !($this->request = Router::getRequest(true))) {
$this->request = new CakeRequest(null, false);
$this->request->base = '';
$this->request->here = $this->request->webroot = '/';
}
if (is_object($controller) && isset($controller->response)) {
$this->response = $controller->response;
} else {