Ticket Details
Using Custom Media Type Gives A Notice
BUG Ticket (closed)
###What happened:
Think I may have found a bug with the Media class when creating your own ```Media::type()``` (mine is called 'template'). In the second parameter of that function, you can supply the content type for your custom media type to use. Well if I use ```text/html``` in that second parameter, it utilizes my custom Media type even if I don't call it by ```$this->_render['type'] = 'template'``` in the controller. This is why I want to pass ```null``` in that second parameter. When I pass ```null``` and try to render a page through my custom Media Type I get this: ```Notice: Undefined index: template in /usr/share/lithium/libraries/lithium/net/http/Media.php on line 412```. Maybe I am using it incorrectly and that's the reason why this is happening and sorry to waste your guys' time. Here is my custom Media Type's code in the bootstrap:
{{{
use \lithium\net\http\Media;
Media::type('template', null, array(
'view' => '\lithium\template\View',
'renderer' => '\cms\extensions\adapter\view\Template',
'paths' => array(
'template' => '{:library}/views/{:controller}/{:template}.html.tpl',
'layout' => '{:library}/views/layouts/{:layout}.html.tpl'
)
));
}}}
A point of note is that my view adapter works just fine, it's just that notice that pop's up.
###What was expected:
There should be no notice on line 412 of the Media class.
###Test Case
{{{
namespace app\tests\cases\net\http;
use \lithium\net\http\Media;
use \lithium\action\Response;
class MediaTest extends \lithium\test\Unit {
public function testCustomMediaTypeNullContentType(){
Media::type('custom', null);
$response = new Response();
$response->type = 'custom';
Media::render($response, null, array(
'layout' => false,
'template' => false,
'encode' => function($data) { return $data; }
));
$expected = array('Content-type: text/html');
$result = $response->headers();
$this->assertEqual($expected, $result);
}
}
}}}
Updates
on 03.10.10
by meenie
- description was changed
(invalid)
on 03.28.10
by nate
- owner was changed to nate
- status was changed to closed
- resolution was changed to invalid