/** * Edit a redirect. * * @param string $cabin * @param string $redirectId * @route redirects/{string}/edit/{id} */ public function editRedirect(string $cabin, string $redirectId) { $cabins = $this->getCabinNamespaces(); if (!\in_array($cabin, $cabins) && !$this->can('update')) { \Airship\redirect($this->airship_cabin_prefix . '/redirects'); } $this->setTemplateExtraData($cabin); $post = $this->post(new RedirectFilter()); $redirect = $this->pg->getRedirect($cabin, (int) $redirectId); if (empty($redirect)) { \Airship\redirect($this->airship_cabin_prefix . '/redirects/' . $cabin); } if ($post) { if (\Airship\all_keys_exist(['old_url', 'new_url'], $post)) { if ($this->pg->updateRedirect((int) $redirectId, $post)) { \Airship\redirect($this->airship_cabin_prefix . '/redirects/' . $cabin); } else { $this->storeLensVar('form_error', 'Could not update redirect. Check that it does not already exist.'); } } } $this->lens('redirect/edit', ['cabin' => $cabin, 'redirect' => $redirect]); }