本文整理汇总了PHP中Event::shutdown方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::shutdown方法的具体用法?PHP Event::shutdown怎么用?PHP Event::shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Event
的用法示例。
在下文中一共展示了Event::shutdown方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* When this type of exception isn't caught this method is called by
* Error::exception_handler() to deal with the problem.
*/
public function handle()
{
$response = new \Response(\View::forge('404'), 404);
\Event::shutdown();
$response->send(true);
return;
}
示例2: redirect
/**
* Redirects to another uri/url. Sets the redirect header,
* sends the headers and exits. Can redirect via a Location header
* or using a refresh header.
*
* The refresh header works better on certain servers like IIS.
*
* @access public
* @param string The url
* @param string The redirect method
* @param int The redirect status code
* @return void
*/
public static function redirect($url = '', $method = 'location', $redirect_code = 302)
{
static::$status = $redirect_code;
if (strpos($url, '://') === false) {
$url = Uri::create($url);
}
if ($method == 'location') {
static::set_header('Location', $url);
} elseif ($method == 'refresh') {
static::set_header('Refresh', '0;url=' . $url);
} else {
return;
}
Event::shutdown();
static::send_headers();
exit;
}
示例3: redirect
/**
* Redirects to another uri/url. Sets the redirect header,
* sends the headers and exits. Can redirect via a Location header
* or using a refresh header.
*
* The refresh header works better on certain servers like IIS.
*
* @param string $url The url
* @param string $method The redirect method
* @param int $code The redirect status code
* @return void
*/
public static function redirect($url = '', $method = 'location', $code = 302)
{
$response = new static();
$response->set_status($code);
if (strpos($url, '://') === false) {
$url = $url !== '' ? \Uri::create($url) : \Uri::base();
}
if ($method == 'location') {
$response->set_header('Location', $url);
} elseif ($method == 'refresh') {
$response->set_header('Refresh', '0;url=' . $url);
} else {
return;
}
\Event::shutdown();
$response->send(true);
exit;
}
示例4: call_user_func
// Use an anonymous function to keep the global namespace clean
call_user_func(function () {
/**
* Set all the paths here
*/
$app_path = '../fuel/app/';
$package_path = '../fuel/packages/';
$core_path = '../fuel/core/';
/**
* Website docroot
*/
define('DOCROOT', __DIR__ . DIRECTORY_SEPARATOR);
!is_dir($app_path) and is_dir(DOCROOT . $app_path) and $app_path = DOCROOT . $app_path;
!is_dir($core_path) and is_dir(DOCROOT . $core_path) and $core_path = DOCROOT . $core_path;
!is_dir($package_path) and is_dir(DOCROOT . $package_path) and $package_path = DOCROOT . $package_path;
define('APPPATH', realpath($app_path) . DIRECTORY_SEPARATOR);
define('PKGPATH', realpath($package_path) . DIRECTORY_SEPARATOR);
define('COREPATH', realpath($core_path) . DIRECTORY_SEPARATOR);
});
// Get the start time and memory for use later
defined('FUEL_START_TIME') or define('FUEL_START_TIME', microtime(true));
defined('FUEL_START_MEM') or define('FUEL_START_MEM', memory_get_usage());
// Boot the app
require_once APPPATH . 'bootstrap.php';
// Generate the request, execute it and send the output.
echo Request::factory()->execute()->send_headers()->output();
// Fire off the shutdown event
Event::shutdown();
// Do some final cleanup
Fuel::finish();
/* End of file index.php */
示例5: download
/**
* Download a file
*
* @param string file path
* @param string|null custom name for the file to be downloaded
* @param string|null custom mime type or null for file mime type
* @param string|File_Area|null file area name, object or null for base area
* @param bool if false, return instead of exit
*/
public static function download($path, $name = null, $mime = null, $area = null, $exit = true)
{
$info = static::file_info($path, $area);
empty($mime) and $mime = $info['mimetype'];
empty($name) and $name = $info['basename'];
if (!($file = static::open_file(@fopen($info['realpath'], 'rb'), LOCK_SH, $area))) {
throw new \FileAccessException('Filename given could not be opened for download.');
}
while (ob_get_level() > 0) {
ob_end_clean();
}
ini_get('zlib.output_compression') and ini_set('zlib.output_compression', 0);
!ini_get('safe_mode') and set_time_limit(0);
header('Content-Type: ' . $mime);
header('Content-Disposition: attachment; filename="' . $name . '"');
header('Content-Description: File Transfer');
header('Content-Length: ' . $info['size']);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
while (!feof($file)) {
echo fread($file, 2048);
}
static::close_file($file, $area);
if ($exit) {
\Event::shutdown();
exit;
}
}
示例6: show_404
/**
* Shows a 404. Checks to see if a 404_override route is set, if not show
* a default 404.
*
* Usage:
*
* Request::show_404();
*
* @param bool Whether to return the 404 output or just output and exit
* @return void|string Void if $return is false, the output if $return is true
*/
public static function show_404($return = false)
{
logger(Fuel::L_INFO, 'Called', __METHOD__);
// This ensures that show_404 doesn't recurse indefinately
static $call_count = 0;
$call_count++;
if ($call_count == 1) {
// first call, route the 404 route
$route_request = true;
} elseif ($call_count == 2) {
// second call, try the 404 route without routing
$route_request = false;
} else {
// third call, there's something seriously wrong now
exit('It appears your _404_ route is incorrect. Multiple Recursion has happened.');
}
if (\Config::get('routes._404_') === null) {
$response = new \Response(\View::factory('404'), 404);
if ($return) {
return $response;
}
\Event::shutdown();
$response->send(true);
} else {
$request = \Request::factory(\Config::get('routes._404_'), $route_request)->execute();
if ($return) {
return $request->response;
}
\Event::shutdown();
$request->response->send(true);
}
\Fuel::finish();
exit;
}
示例7: handle
/**
* When this type of exception isn't caught this method is called by
* Error::exception_handler() to deal with the problem.
*/
public function handle()
{
$response = $this->response();
\Event::shutdown();
$response->send(true);
}
示例8: handle
/**
* When this type of exception isn't caught this method is called by
* Error::exception_handler() to deal with the problem.
*/
public function handle()
{
$response = new \Response(\View::forge('500'), 500);
\Event::shutdown();
$response->send(true);
}
示例9: build
/**
* Build
*
* Builds the grid and renders
* it as a View object
*
* @access public
* @return View
*/
public function build()
{
// Make sure we have columns
if (!$this->get_columns()->count()) {
throw new Exception('You must add a column to the grid before building it');
}
$this->_prepare_grid();
// Build the grid
$grid = \View::forge(\Config::get('grid.view.grid', 'grid'))->set('grid', $this, false);
// If we can't display a container just return
// the grid
if (!$this->can_display_container()) {
// If we're dealing with an
// AJAX request, we want to
// stream a new response
if (\Input::is_ajax() and $this->should_override_response()) {
// Create and send a response
// with the grid as the contents
$response = new \Response($grid);
$response->send(true);
// Close down fuel
\Event::shutdown();
\Fuel::finish();
exit;
}
// Return the grid
return $grid;
}
// If we can display a container, add it
// and return both of them
return $this->get_container()->build()->set('grid', $grid, false);
}