2017-07-18 21:38:53 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Http;
|
|
|
|
|
2017-08-29 16:21:25 +02:00
|
|
|
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
|
2017-07-18 21:38:53 +02:00
|
|
|
|
2017-08-29 16:21:25 +02:00
|
|
|
class Request extends SymfonyRequest
|
2017-07-18 21:38:53 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Get POST input
|
|
|
|
*
|
|
|
|
* @param string $key
|
|
|
|
* @param mixed $default
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2017-08-29 16:21:25 +02:00
|
|
|
public function postData($key, $default = null)
|
2017-07-18 21:38:53 +02:00
|
|
|
{
|
2017-08-29 16:21:25 +02:00
|
|
|
return $this->request->get($key, $default);
|
2017-07-18 21:38:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get input data
|
|
|
|
*
|
|
|
|
* @param string $key
|
|
|
|
* @param mixed $default
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function input($key, $default = null)
|
|
|
|
{
|
2017-08-29 16:21:25 +02:00
|
|
|
return $this->get($key, $default);
|
2017-07-18 21:38:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the input exists
|
|
|
|
*
|
|
|
|
* @param string $key
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function has($key)
|
|
|
|
{
|
2017-11-19 14:47:32 +01:00
|
|
|
$value = $this->input($key, null);
|
2017-07-18 21:38:53 +02:00
|
|
|
|
2017-11-19 14:47:32 +01:00
|
|
|
return !($value === null);
|
2017-07-18 21:38:53 +02:00
|
|
|
}
|
|
|
|
|
2017-08-28 16:21:10 +02:00
|
|
|
/**
|
|
|
|
* Get the requested path
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function path()
|
|
|
|
{
|
2017-08-29 16:21:25 +02:00
|
|
|
$pattern = trim($this->getPathInfo(), '/');
|
2017-08-28 16:21:10 +02:00
|
|
|
|
2017-08-29 16:21:25 +02:00
|
|
|
return $pattern == '' ? '/' : $pattern;
|
2017-08-28 16:21:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-08-29 16:21:25 +02:00
|
|
|
* Return the current URL
|
|
|
|
*
|
2017-08-28 16:21:10 +02:00
|
|
|
* @return string
|
|
|
|
*/
|
2017-08-29 16:21:25 +02:00
|
|
|
public function url()
|
2017-08-28 16:21:10 +02:00
|
|
|
{
|
2017-08-29 16:21:25 +02:00
|
|
|
return rtrim(preg_replace('/\?.*/', '', $this->getUri()), '/');
|
2017-08-28 16:21:10 +02:00
|
|
|
}
|
2017-07-18 21:38:53 +02:00
|
|
|
}
|