public static function renderPartial($viewName, $data = array()) { ob_start(); $view = new View($viewName, $data); $view->render(); $content = ob_get_clean(); return $content; }
public function start() { $this->initController(); View::$controllerName = $this->controllerName; View::$actionName = $this->actionName; try { $method = new \ReflectionMethod($this->controller, $this->actionName); foreach ($method->getParameters() as $param) { $param = $param->getType()->__toString(); if (class_exists($param)) { $this->requestParams[] = new $param(); } } call_user_func_array(array($this->controller, $this->actionName), $this->requestParams); } catch (\Exception $e) { throw new \Exception($e->getMessage(), 404); } }
public static function index($data) { View::show('index'); }
/** * Get a global variable from the view. Shortcut for View::getGlobal() * * @param mixed $var */ public function viewGetGlobal($var) { /* @var $view View */ return \framework\core\View::getGlobal($var); }
<?php use Framework\Core\View; echo View::renderPartial('templates/header', ['title' => 'Hello world!']); echo View::renderPartial($viewName, $data); echo View::renderPartial('templates/footer', ['href' => 'http://sigma.software/', 'title' => 'Sigma Software']);
public static function add($data) { $request = new Request(); View::error([$request->params['POST']['testText']]); }
<?php require_once '../vendor/autoload.php'; use Framework\Core\View; set_exception_handler(function ($exception) { View::error($exception->getMessage()); });