Airship\Cabin\Bridge\Landing\Redirects::editRedirect PHP Method

editRedirect() public method

Edit a redirect.
public editRedirect ( string $cabin, string $redirectId )
$cabin string
$redirectId string
    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]);
    }