allowing RequestHandler to load helpers for extension from any path, closes #2230

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6141 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2007-12-11 03:01:46 +00:00
parent b7a0d4b31e
commit b6b2696488
2 changed files with 18 additions and 6 deletions

View file

@ -538,9 +538,10 @@ class RequestHandlerComponent extends Object {
$this->respondAs($type);
}
if (!in_array(ucfirst($type), $controller->helpers)) {
if (file_exists(HELPERS . $type . '.php') || fileExistsInPath(LIBS . 'view' . DS . 'helpers' . DS . $type . '.php')) {
$controller->helpers[] = ucfirst($type);
$helper = ucfirst($type);
if (!in_array($helper, $controller->helpers)) {
if (App::import('Helper', $helper)) {
$controller->helpers[] = $helper;
}
}
}

View file

@ -26,7 +26,7 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
uses('controller' . DS . 'components' . DS .'request_handler');
uses('controller' . DS . 'controller', 'controller' . DS . 'components' . DS .'request_handler');
/**
* Short description for class.
*
@ -35,8 +35,19 @@ uses('controller' . DS . 'components' . DS .'request_handler');
*/
class RequestHandlerComponentTest extends CakeTestCase {
function skip() {
$this->skipif (true, 'RequestHandlerComponentTest not implemented');
function setUp() {
$this->RequestHandler = new RequestHandlerComponent();
$this->Controller = new Controller();
}
function testRenderAs() {
$this->RequestHandler->renderAs($this->Controller, 'xml');
$this->assertEqual($this->Controller->helpers, array('Html', 'Xml'));
}
function tearDown() {
unset($this->RequestHandler);
unset($this->Controller);
}
}
?>