Airship\Cabin\Bridge\Blueprint\CustomPages::createSameCabinRedirect PHP Method

createSameCabinRedirect() public method

Create a redirect
public createSameCabinRedirect ( string $oldURL, string $newURL, string $cabin ) : boolean
$oldURL string
$newURL string
$cabin string
return boolean
    public function createSameCabinRedirect(string $oldURL, string $newURL, string $cabin) : bool
    {
        $this->db->beginTransaction();
        try {
            $this->db->insert('airship_custom_redirect', ['oldpath' => $oldURL, 'newpath' => $newURL, 'cabin' => $cabin, 'same_cabin' => true]);
        } catch (QueryError $e) {
            $this->db->rollBack();
            return false;
        }
        return $this->db->commit();
    }

Usage Example

Example #1
0
 /**
  * Confirm deletion
  *
  * @param int $pageId
  * @param array $post
  * @param string $cabin
  * @param string $dir
  * @return mixed
  */
 protected function processDeletePage(int $pageId, array $post = [], string $cabin = '', string $dir = '') : bool
 {
     $this->log('Attempting to delete a page', LogLevel::ALERT, ['pageId' => $pageId, 'cabin' => $cabin, 'dir' => $dir]);
     list($oldCabin, $oldPath, $oldURL) = $this->pg->getPathByPageId((int) $pageId, $cabin);
     if ($this->pg->deletePage($pageId)) {
         if (!empty($post['create_redirect']) && !empty($post['redirect_to'])) {
             $this->pg->createSameCabinRedirect($oldPath . '/' . $oldURL, $post['redirect_to'], $oldCabin);
         }
         \Airship\redirect($this->airship_cabin_prefix . '/pages/' . $cabin, ['dir' => $dir]);
     }
     return false;
 }
All Usage Examples Of Airship\Cabin\Bridge\Blueprint\CustomPages::createSameCabinRedirect