for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace WebServCo\Framework\Traits;
trait ResponseUrlTrait
{
abstract protected function request();
/**
* Redirect to an application location (Request target).
* This method returns a HttpResponse object that needs to be in turn returned to the application.
*/
final protected function getRedirectResponse($location, $addSuffix = true)
$url = $this->request()->getAppUrl();
$url .= $location;
if ($addSuffix) {
$url .= $this->request()->getSuffix();
}
return $this->getRedirectUrlResponse($url);
* This method sends a HttpRequest, forcing a redirect.
final protected function forceRedirect($location, $addSuffix = true)
$response = $this->getRedirectResponse($location, $addSuffix);
$response->send();
exit;
exit
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.
* Redirect to the current URL.
final protected function getReloadResponse($removeParameters = [])
$url = $this->request()->getUrl($removeParameters);
* Redirect to a full URL.
final protected function getRedirectUrlResponse($url)
return new \WebServCo\Framework\HttpResponse(
null,
302,
['Location' => $url]
);
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.