public function output($panadaViewfile, $data = [])
{
$panadaFilePath = APP . 'views/' . $panadaViewfile;
if ($this->childClass['namespaceArray'][0] == 'Modules') {
$panadaFilePath = $this->configMain['module']['path'] . $this->childClass['namespaceArray'][0] . '/' . $this->childClass['namespaceArray'][1] . '/views/' . $panadaViewfile;
}
try {
if (!file_exists($this->viewFile = $panadaFilePath . '.php')) {
throw new RunException('View file in ' . $this->viewFile . ' does not exits');
}
} catch (RunException $e) {
$arr = $e->getTrace();
RunException::outputError($e->getMessage(), $arr[0]['file'], $arr[0]['line']);
}
if (!empty($data)) {
$this->viewCache = array('data' => $data, 'prefix' => $this->childClass['namespaceString']);
}
// We don't need this variables anymore.
unset($panadaViewFile, $data, $panadaFilePath);
if (!empty($this->viewCache) && $this->viewCache['prefix'] == $this->childClass['namespaceString']) {
extract($this->viewCache['data'], EXTR_SKIP);
}
ob_start();
include $this->viewFile;
$return = ob_get_contents();
ob_end_clean();
return $return;
}