LaravelRequest.php 1.02 KB
Newer Older
Taylor Otwell committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
<?php namespace Symfony\Component\HttpFoundation;

class LaravelRequest extends Request {

    /**
     * Creates a new request with values from PHP's super globals.
     *
     * @return Request A new request
     *
     * @api
     */
    static public function createFromGlobals()
    {
        $request = new static($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER);

        if (0 === strpos($request->server->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
            && in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH'))
        ) {
            parse_str($request->getContent(), $data);
            if (magic_quotes()) $data = array_strip_slashes($data);
            $request->request = new ParameterBag($data);
        }

        return $request;
    }

27 28 29 30 31 32 33 34 35 36
    /**
     * Get the root URL of the application.
     *
     * @return string
     */
    public function getRootUrl()
    {
        return $this->getScheme().'://'.$this->getHttpHost().$this->getBasePath();
    }

Taylor Otwell committed
37
}