php-framework-benchmark /micromvc4/Class/Core/View.php

Language PHP Lines 69
MD5 Hash 4c7b5250d5736d950604fd4dee0ec596 Estimated Cost $680 (why?)
Repository git://github.com/eryx/php-framework-benchmark.git View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
 * View
 *
 * Provides fetching of HTML template files
 *
 * @package		MicroMVC
 * @author		http://github.com/tweetmvc/tweetmvc-app
 * @copyright	(c) 2011 MicroMVC Framework
 * @license		http://micromvc.com/license
 ********************************** 80 Columns *********************************
 */
namespace Core;

class View
{

	private $__view = NULL;

	/**
	 * Returns a new view object for the given view.
	 *
	 * @param string $file the view file to load
	 * @param string $module name (blank for current theme)
	 */
	public function __construct($file)
	{
		$this->__view = $file;
	}


	/**
	 * Set an array of values
	 *
	 * @param array $array of values
	 */
	public function set($array)
	{
		foreach($array as $k => $v)
		{
			$this->$k = $v;
		}
	}


	/**
	 * Return the view's HTML
	 *
	 * @return string
	 */
	public function __toString()
	{
		try {
			ob_start();
			extract((array) $this);
			require SP . "View/" . $this->__view . EXT;
			return ob_get_clean();
		}
		catch(\Exception $e)
		{
			Error::exception($e);
			return '';
		}
	}

}

// END
Back to Top