createDifferentCabinRedirect() public method

Create a redirect
public createDifferentCabinRedirect ( string $oldURL, string $newURL, string $cabin ) : boolean
$oldURL string
$newURL string
$cabin string
return boolean
コード例 #1
0
ファイル: Redirects.php プロジェクト: paragonie/airship
 /**
  * Create a new redirect
  *
  * @param string $cabin
  * @route redirects/{string}/new
  */
 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]);
 }