Ejemplo n.º 1
0
 /**
  * @dataProvider providerFile
  */
 public function testLoadFile($file, $exception)
 {
     try {
         $view = new View();
         $view->file($file);
         $this->assertSame(false, $exception);
     } catch (ViewException $e) {
         $this->assertSame(true, $exception);
     }
 }
Ejemplo n.º 2
0
 public function __construct(IConfig $config = null)
 {
     View::$_instance = $this;
     if ($config !== null) {
         $this->_config = new Config($config->data('view'));
     }
     $this->_loader = new \Twig_Loader_Filesystem($this->_config ? ROOT_PATH . $this->_config->data('path') : MI_TEMPLATE_PATH);
     $this->_twig_temp = new \Twig_Environment($this->_loader);
     $this->_twig_str = new \Twig_Environment(new \Twig_Loader_String());
     $this->_file = 'error';
 }
Ejemplo n.º 3
0
 public static function sendHandler(\Exception $e)
 {
     try {
         $view = View::getInstance();
         $code = $e->getCode() == 0 ? 200 : $e->getCode();
         $response = new Response($view->render('error', array('error' => array('code' => $e->getCode(), 'message' => $e->getMessage(), 'details' => self::getText($e)))), $code, new DataHtml());
         $response->send();
     } catch (\Exception $e) {
         ob_get_level();
         ob_clean();
         header('Content-Type: text/plain;', true, $e->getCode());
         echo self::getText($e);
         exit(1);
     }
 }