Advertisement
salientdigital

Checking if Kohana is CLI

Jan 21st, 2011
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. if (Kohana::$is_cli)
  2. {
  3.     $args = CLI::options('uri');
  4.     $uri = $args['uri'];
  5. }
  6. else
  7. {
  8.     $uri = Arr::get($_GET, 'kohana_uri');
  9. }
  10.  
  11. $request = Request::instance($uri);
  12. try
  13. {
  14.     // Attempt to fire the request
  15.     $request->execute();
  16. } catch (Exception $e)
  17. {
  18.     if (!IN_PRODUCTION)
  19.     {
  20.         // Just throw the exception
  21.         throw $e;
  22.     }
  23.     // Log the error
  24.     Kohana::$log->add(Kohana::ERROR, Kohana::exception_text($e));
  25.  
  26.     // Create a 404 response
  27.     $request->status = 404;
  28.     $request->response = View::factory('errors/pageNotFound', array(
  29.         'menu' => (strpos($host, 'admin.') !== FALSE) ? '' : HTML::menu()
  30.     ));
  31. }
  32. echo $request->send_headers()
  33. ->response;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement