UnionOfRAD/lithium — Issue #181: Media::type() - bug or documentation error
Author: tehnorm
Created: 2011-11-02 03:19:54+00:00
State: open

Not sure if this a bug or a documentation error. If I define a media handler like so

```php
Media::type('print', 'text/html', array(
'paths' => array(
'layout' => '{:library}/views/layouts/{:layout}.html.php',
'template' => '{:library}/views/{:controller}/{:template}.html.php',
),
'view' => 'lithium\template\View'
));
```

Everything is peachy and the request is rendered correctly using the correct template. But if I setup the Media handler like so I get a fatal error.

```php
Media::type('print', 'text/html', array(
'layout' => '{:library}/views/layouts/{:layout}.html.php',
'template' => '{:library}/views/{:controller}/{:template}.html.php',
'view' => 'lithium\template\View'
));
```

```php
Fatal error: Uncaught exception 'lithium\template\TemplateException' with message 'Template not found at path `/Users/norm/Projects/taggs.co/site/app/views/home/dashboard_home.print.php`.'
in /Users/norm/Projects/taggs.co/site/libraries/lithium/template/view/adapter/File.php:176

Stack trace:
#0 /Users/norm/Projects/taggs.co/site/libraries/lithium/template/view/adapter/File.php(125): lithium\template\view\adapter\File->_paths('template', Array)
#1 /Users/norm/Projects/taggs.co/site/libraries/lithium/template/View.php(304): lithium\template\view\adapter\File->template('template', Array)
#2 /Users/norm/Projects/taggs.co/site/libraries/lithium/core/Object.php(240): lithium\template\{closure}(Object(lithium\template\View), Array, NULL)
#3 /Users/norm/Projects/taggs.co/site/libraries/lithium/template/View.php(307): lithium\core\Object->_filter('lithium\templat...', Array, Object(Closure))
#4 /Users/norm/Projects/taggs.co/site/libraries/lithium/template/View.php(271): lithium\template\View->_step(Array, Array, Array, Array)
#5 / in /Users/norm/Projects/taggs.co/site/libraries/lithium/template/view/adapter/File.php on line 176
```

With the second syntax it seems to be loading Media::view() to look for the template in `{:library}/views/{:controller}/{:template}.{:type}.php` and not `{:library}/views/{:controller}/{:template}.html.php` as specified and causing it to blow up when it can't find the template in the path.

The doc block on Media::type() makes no mention of being able to pass paths as a key to $options so this is either a documentation error or it shouldn't allow me to do this? Happy to help craft a fix or adjust the docblock little guidance.