From 7464b2a5cee7d82640764e38e8e9fd1ff68e979d Mon Sep 17 00:00:00 2001 From: Connor Parks Date: Fri, 29 May 2015 11:13:06 +0100 Subject: [PATCH] move to illuminate's request instead of our own http implementation --- Herbert/Framework/Http.php | 140 +----------------- .../Providers/HerbertServiceProvider.php | 2 +- composer.json | 8 +- 3 files changed, 10 insertions(+), 140 deletions(-) diff --git a/Herbert/Framework/Http.php b/Herbert/Framework/Http.php index b2c0ee7..c91c0a7 100644 --- a/Herbert/Framework/Http.php +++ b/Herbert/Framework/Http.php @@ -1,144 +1,12 @@ bag = $bag ?: $this->collectBag(); - $this->method = $_SERVER['REQUEST_METHOD']; - - if (isset($_POST['_method']) && in_array(strtoupper($_POST['_method']), static::$methods)) - { - $this->method = strtoupper($_POST['_method']); - } - } - - /** - * Gets the HTTP method. - * - * @return mixed - */ - public function method() - { - return $this->method; - } - - /** - * Checks if a key exists. - * - * @param $key - * @return bool - */ - public function has($key) - { - return isset($this->bag[$key]); - } - - /** - * Get all the keys and values. - * - * @return array - */ - public function all() - { - return array_merge($this->bag, []); - } - - /** - * Gets a key's value. - * - * @param $key - * @param mixed $default - * @return mixed - */ - public function get($key, $default = null) - { - if (!$this->has($key)) - { - return $default; - } - - return $this->bag[$key]; - } - - /** - * Sets a key's value. - * - * @param $key - * @param $value - * @return void - */ - public function set($key, $value) - { - $this->bag[$key] = $value; - } - - /** - * Merges two bags. - * - * @param array $bag - */ - public function put($bag = []) - { - $this->bag = array_merge($this->bag, $bag); - } - - /** - * Forgets a key. - * - * @param $key - * @return mixed - */ - public function forget($key) - { - if (!$this->has($key)) - { - return null; - } - - $value = $this->get($key); - unset($this->bag[$key]); - - return $value; - } +class Http extends Request { - /** - * Collects the current bag. - * - * @return mixed - */ - protected function collectBag() - { - return $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET; - } + // } diff --git a/Herbert/Framework/Providers/HerbertServiceProvider.php b/Herbert/Framework/Providers/HerbertServiceProvider.php index d40ac62..5b8c476 100644 --- a/Herbert/Framework/Providers/HerbertServiceProvider.php +++ b/Herbert/Framework/Providers/HerbertServiceProvider.php @@ -26,7 +26,7 @@ public function register() $this->app->instance( 'http', - $this->app->make('Herbert\Framework\Http', ['app' => $this->app]) + \Herbert\Framework\Http::capture() ); $this->app->alias( diff --git a/composer.json b/composer.json index f56cf92..ab2e78a 100644 --- a/composer.json +++ b/composer.json @@ -3,9 +3,11 @@ "description": "Herbert", "license": "MIT", "require": { - "twig/twig": "1.16.*", - "illuminate/database": "5.1.*", - "vierbergenlars/php-semver": "~3.0" + "twig/twig": "~1.16", + "illuminate/database": "~5.1", + "vierbergenlars/php-semver": "~3.0", + "symfony/var-dumper": "~3.0", + "illuminate/http": "~5.1" }, "autoload": { "psr-4": {