public function redirectIf(string $dir, string $to = '/', bool $exit = true): void
    {
        if ($this->acl != null) {
            $app = $this->acl->getService()->getApp();
            if ($dir == 'in' && $this->isLoggedIn()) {
                $app->response()->redirect($to);
            } elseif ($dir == 'out' && !$this->isLoggedIn()) {
                $app->response()->redirect($to);
            }
        } else {
            if (headers_sent($file, $line)) {
                throw new AclException(sprintf("Cannot use '%s()', headers already sent in %s:%s",
                    __method__, $file, $line));
            }

            header('Location: '. trim($to));
            if ($exit) {
                exit(0);
            }
        }
    }
public function redirectIf(string $dir, string $to = '/', bool $exit = true): void
    {
        if ($this->acl != null) {
            $app = $this->acl->getService()->getApp();
            if ($dir == 'in' && $this->isLoggedIn()) {
                $app->response()->redirect($to);
            } elseif ($dir == 'out' && !$this->isLoggedIn()) {
                $app->response()->redirect($to);
            }
        } else {
            if (headers_sent($file, $line)) {
                throw new AclException(sprintf("Cannot use '%s()', headers already sent in %s:%s",
                    __method__, $file, $line));
            }

            header('Location: '. trim($to));
            if ($exit) {
                exit(0);
            }
        }
    }
public function redirectIf ( string $ dir , string $ to = '/' , bool $ exit = true ) : void { if ( $ this -> acl != null ) { $ app = $ this -> acl -> getService ( ) -> getApp ( ) ; if ( $ dir == 'in' && $ this -> isLoggedIn ( ) ) { $ app -> response ( ) -> redirect ( $ to ) ; } elseif ( $ dir == 'out' && ! $ this -> isLoggedIn ( ) ) { $ app -> response ( ) -> redirect ( $ to ) ; } } else { if ( headers_sent ( $ file , $ line ) ) { throw new AclException ( sprintf ( "Cannot use '%s()', headers already sent in %s:%s" , __method__ , $ file , $ line ) ) ; } header ( 'Location: ' . trim ( $ to ) ) ; if ( $ exit ) { exit ( 0 ) ; } } }
Redirect if.
@param  string $dir In/out direction.
@param  string $to
@param  bool   $exit
@return void
Redirect if .