Airship\Cabin\Hull\Blueprint\Blog::longURL PHP Method

longURL() public method

Get the long URL for a given short URL
public longURL ( string $shortURL = '' ) : string
$shortURL string
return string
    public function longURL(string $shortURL = '') : string
    {
        $post = $this->db->row("SELECT * FROM view_hull_blog_list WHERE shorturl = ?", $shortURL);
        if (empty($post)) {
            return '';
        }
        return \implode('/', ['', $post['blogyear'], \str_pad($post['blogmonth'], 2, '0', STR_PAD_LEFT), $post['slug']]);
    }

Usage Example

Example #1
0
 /**
  * Handle short URLs
  *
  * @param string $uniqueID
  * @route b/(.*)
  */
 public function shortURL(string $uniqueID = '')
 {
     if (empty($uniqueID)) {
         \Airship\redirect($this->airship_cabin_prefix . '/blog');
     }
     $long = $this->blog->longURL($uniqueID);
     \Airship\redirect($this->airship_cabin_prefix . '/blog' . $long);
 }