Created
February 13, 2010 17:13
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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