Skip to content

Instantly share code, notes, and snippets.

@samsoir
Created February 13, 2010 17:13
Show Gist options
  • Select an option

  • Save samsoir/303566 to your computer and use it in GitHub Desktop.

Select an option

Save samsoir/303566 to your computer and use it in GitHub Desktop.
Refactored the Kohana_View::set_filename() method to allow use of .phtml or other extensions besides .php
<?php
/**
* Sets the view filename.
*
* @throws View_Exception
* @param string filename
* @return View
*/
public function set_filename($file)
{
// Detect if there was a file extension
$_file = explode('.', $file);
// If there are several components
if (count($_file) > 1)
{
// Take the extension
$ext = array_pop($_file);
$file = implode('.', $_file);
}
// Otherwise set the extension to the standard
else
$ext = EXT;
if (($path = Kohana::find_file('views', $file, $ext)) === FALSE)
{
throw new Kohana_View_Exception('The requested view :file could not be found', array(
':file' => $file,
));
}
// Store the file path locally
$this->_file = $path;
return $this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment