/** * Routes an exception through the error callbacks * * @param Exception $err The exception that occurred * @throws UnhandledException If the error/exception isn't handled by an error callback * @access protected * @return void */ protected function error(Exception $err) { $type = get_class($err); $msg = $err->getMessage(); if (count($this->errorCallbacks) > 0) { foreach (array_reverse($this->errorCallbacks) as $callback) { if (is_callable($callback)) { if (is_string($callback)) { $callback($this, $msg, $type, $err); return; } else { call_user_func($callback, $this, $msg, $type, $err); return; } } else { if (null !== $this->service && null !== $this->response) { $this->service->flash($err); $this->response->redirect($callback); } } } } else { $this->response->code(500); throw new UnhandledException($msg, $err->getCode(), $err); } // Lock our response, since we probably don't want // anything else messing with our error code/body $this->response->lock(); }
public function testMagicGetSetExistsRemove() { $test_data = array('name' => 'huh?'); $service = new ServiceProvider(); $this->assertEmpty($service->sharedData()->all()); $this->assertNull($service->sharedData()->get('test_data')); $this->assertNull($service->name); $this->assertFalse(isset($service->name)); $service->name = $test_data['name']; $this->assertTrue(isset($service->name)); $this->assertSame($test_data['name'], $service->name); unset($service->name); $this->assertEmpty($service->sharedData()->all()); $this->assertNull($service->sharedData()->get('test_data')); $this->assertNull($service->name); $this->assertFalse(isset($service->name)); }
/** * Return the view service provider * * @param string $view View file path * @param array $data */ public function render($view, array $data = array()) { @parent::render($view, $data); }
/** * Routes an exception through the error callbacks * * @param Exception $err The exception that occurred * @access protected * @return void */ protected function error(Exception $err) { $type = get_class($err); $msg = $err->getMessage(); if (count($this->errorCallbacks) > 0) { foreach (array_reverse($this->errorCallbacks) as $callback) { if (is_callable($callback)) { if (is_string($callback)) { if ($callback($this, $msg, $type, $err)) { return; } } else { if (call_user_func($callback, $this, $msg, $type, $err)) { return; } } } else { if (null !== $this->service && null !== $this->response) { $this->service->flash($err); $this->response->redirect($callback); } } } } else { $this->response->code(500); throw new UnhandledException($err); } }