Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Changed forge to be more like core fuel View and allow setting filena…

…me later after getting the view object.

Signed-off-by: Derek Myers <arcticpro@gmail.com>
  • Loading branch information...
commit c6eaeaafe64f13515ccdadd67637360e5ede1e3a 1 parent f85eafe
Derek Myers authored September 23, 2012

Showing 1 changed file with 22 additions and 8 deletions. Show diff stats Hide diff stats

  1. 30  classes/view.php
30  classes/view.php
@@ -53,11 +53,22 @@ public static function _init()
53 53
 	 */
54 54
 	public static function forge($file = null, $data = null, $auto_encode = null)
55 55
 	{
56  
-		$extension = pathinfo($file, PATHINFO_EXTENSION);
57  
-		$class     = \Config::get('parser.extensions.'.$extension, get_called_class());
  56
+		$class = null;
  57
+
  58
+		if ($file !== null)
  59
+		{
  60
+			$extension = pathinfo($file, PATHINFO_EXTENSION);
  61
+
  62
+			$class = \Config::get('parser.extensions.'.$extension, null);
  63
+		}
  64
+		
  65
+		if ($class === null)
  66
+		{
  67
+			$class = get_called_class();
  68
+		}
58 69
 
59 70
 		// Only get rid of the extension if it is not an absolute file path
60  
-		if ($file[0] !== '/' and $file[1] !== ':')
  71
+		if ($file !== null and $file[0] !== '/' and $file[1] !== ':')
61 72
 		{
62 73
 			$file = $extension ? preg_replace('/\.'.preg_quote($extension).'$/i', '', $file) : $file;
63 74
 		}
@@ -87,11 +98,14 @@ public static function forge($file = null, $data = null, $auto_encode = null)
87 98
 
88 99
 		$view = new $class(null, $data, $auto_encode);
89 100
 
90  
-		// Set extension when given
91  
-		$extension and $view->extension = $extension;
92  
-
93  
-		// Load the view file
94  
-		$view->set_filename($file);
  101
+		if ($file !== null)
  102
+		{
  103
+			// Set extension when given
  104
+			$extension and $view->extension = $extension;
  105
+			
  106
+			// Load the view file
  107
+			$view->set_filename($file);
  108
+		}
95 109
 
96 110
 		return $view;
97 111
 	}

0 notes on commit c6eaeaa

Please sign in to comment.
Something went wrong with that request. Please try again.