From 8966f1b324c1967326cc9f57729eefe7883947f6 Mon Sep 17 00:00:00 2001 From: Rachman Chavik Date: Mon, 4 Jun 2012 20:29:28 +0700 Subject: [PATCH] create CakeRequest in View instead of in CakeEmail --- lib/Cake/Network/Email/CakeEmail.php | 6 ------ lib/Cake/Test/Case/Network/Email/CakeEmailTest.php | 13 +------------ lib/Cake/Test/Case/Utility/DebuggerTest.php | 2 +- lib/Cake/View/View.php | 5 +++++ 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 74c9e0a0f..be21205ad 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -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); diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index ee4e8f640..209009415 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -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 = 'cool image'; $result = $this->CakeEmail->send(); $this->assertContains($expected, $result['message']); } diff --git a/lib/Cake/Test/Case/Utility/DebuggerTest.php b/lib/Cake/Test/Case/Utility/DebuggerTest.php index f45f19cdc..2eaab04f6 100644 --- a/lib/Cake/Test/Case/Utility/DebuggerTest.php +++ b/lib/Cake/Test/Case/Utility/DebuggerTest.php @@ -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 diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index f2e40eac5..948d9dc55 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -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 {