Base::redirect PHP Method

redirect() public method

Redirect a route to another URL
public redirect ( $pattern, $url, $permanent = TRUE ) : null
$pattern string|array
$url string
$permanent bool
return null
    function redirect($pattern, $url, $permanent = TRUE)
    {
        if (is_array($pattern)) {
            foreach ($pattern as $item) {
                $this->redirect($item, $url, $permanent);
            }
            return;
        }
        $this->route($pattern, function ($fw) use($url, $permanent) {
            $fw->reroute($url, $permanent);
        });
    }

Usage Example

Example #1
0
 private function themes()
 {
     if (isset($_GET['theme']) && Validate::slug($_GET['theme']) && file_exists(PATH . '/themes/' . $_GET['theme'] . '/theme.json')) {
         $opt = Options::where('name', 'theme')->findOne();
         $opt->value = $_GET['theme'];
         $opt->save();
         Base::redirect('/admin/themes');
     }
     /**
      * Get themes
      */
     $dir = PATH . '/themes/';
     if ($dh = opendir($dir)) {
         $themes = array();
         while (($theme = readdir($dh)) !== false) {
             $file = $dir . $theme . '/theme.json';
             if (file_exists($file)) {
                 $file = file_get_contents($file);
                 $file = (array) json_decode($file);
                 $file['theme'] = $theme;
                 $themes[] = $file;
             }
         }
         closedir($dh);
     }
     View::set('themes', $themes);
     View::show('admin/themes');
 }
All Usage Examples Of Base::redirect