LaravelRequest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php namespace Symfony\Component\HttpFoundation;
  2. class LaravelRequest extends Request {
  3. /**
  4. * Creates a new request with values from PHP's super globals.
  5. *
  6. * @return Request A new request
  7. *
  8. * @api
  9. */
  10. static public function createFromGlobals()
  11. {
  12. $request = new static($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER);
  13. if ((0 === strpos($request->server->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
  14. || (0 === strpos($request->server->get('HTTP_CONTENT_TYPE'), 'application/x-www-form-urlencoded')))
  15. && in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH'))
  16. ) {
  17. parse_str($request->getContent(), $data);
  18. if (magic_quotes()) $data = array_strip_slashes($data);
  19. $request->request = new ParameterBag($data);
  20. }
  21. return $request;
  22. }
  23. /**
  24. * Get the root URL of the application.
  25. *
  26. * @return string
  27. */
  28. public function getRootUrl()
  29. {
  30. return $this->getScheme().'://'.$this->getHttpHost().$this->getBasePath();
  31. }
  32. }