public function newRedirect(string $cabin)
{
$cabins = $this->getCabinNamespaces();
if (!\in_array($cabin, $cabins) && !$this->can('create')) {
\Airship\redirect($this->airship_cabin_prefix . '/redirects');
}
$this->setTemplateExtraData($cabin);
$post = $this->post(new RedirectFilter());
if ($post) {
if (\Airship\all_keys_exist(['old_url', 'new_url'], $post)) {
if (\preg_match('#^https?://#', $post['new_url'])) {
// Less restrictions:
$result = $this->pg->createDifferentCabinRedirect(\trim($post['old_url'], '/'), \trim($post['new_url'], '/'), $cabin);
} else {
$result = $this->pg->createSameCabinRedirect(\trim($post['old_url'], '/'), \trim($post['new_url'], '/'), $cabin);
}
if ($result) {
\Airship\redirect($this->airship_cabin_prefix . '/redirects/' . $cabin);
}
}
}
$this->lens('redirect/new', ['cabin' => $cabin]);
}