protected function getAccountVirtual()
    {
        $accountIdVirtual  = (int) Post::getInstance()->get('editAccountIdVirtual');
        $accountUserMapper = new AccountUserMapper(Database::get('money'));
        $accountMapper     = new AccountMapper(Database::get('money'));

        //~ Update virtual account if necessary
        if ($accountIdVirtual <= 0) {
            return $accountMapper->newDataInstance();
        }

        $accountUser = $accountUserMapper->findByKeys([
            'account_id' => $accountIdVirtual,
            'user_id'    => Session::getInstance()->get('id'),
        ]);

        if ($accountUser->getUserId() !== Session::getInstance()->get('id')) {
            throw new \Exception('Not Allowed!');
        }

        $account = $accountUser->getAccount();

        if (!$account->isVirtual()) {
            return $accountMapper->newDataInstance();
        }

        return $account;
    }
protected function getAccountVirtual()
    {
        $accountIdVirtual  = (int) Post::getInstance()->get('editAccountIdVirtual');
        $accountUserMapper = new AccountUserMapper(Database::get('money'));
        $accountMapper     = new AccountMapper(Database::get('money'));

        //~ Update virtual account if necessary
        if ($accountIdVirtual <= 0) {
            return $accountMapper->newDataInstance();
        }

        $accountUser = $accountUserMapper->findByKeys([
            'account_id' => $accountIdVirtual,
            'user_id'    => Session::getInstance()->get('id'),
        ]);

        if ($accountUser->getUserId() !== Session::getInstance()->get('id')) {
            throw new \Exception('Not Allowed!');
        }

        $account = $accountUser->getAccount();

        if (!$account->isVirtual()) {
            return $accountMapper->newDataInstance();
        }

        return $account;
    }
protected function getAccountVirtual ( ) { $ accountIdVirtual = ( int ) Post :: getInstance ( ) -> get ( 'editAccountIdVirtual' ) ; $ accountUserMapper = new AccountUserMapper ( Database :: get ( 'money' ) ) ; $ accountMapper = new AccountMapper ( Database :: get ( 'money' ) ) ; //~ Update virtual account if necessary if ( $ accountIdVirtual <= 0 ) { return $ accountMapper -> newDataInstance ( ) ; } $ accountUser = $ accountUserMapper -> findByKeys ( [ 'account_id' => $ accountIdVirtual , 'user_id' => Session :: getInstance ( ) -> get ( 'id' ) , ] ) ; if ( $ accountUser -> getUserId ( ) !== Session :: getInstance ( ) -> get ( 'id' ) ) { throw new \ Exception ( 'Not Allowed!' ) ; } $ account = $ accountUser -> getAccount ( ) ; if ( ! $ account -> isVirtual ( ) ) { return $ accountMapper -> newDataInstance ( ) ; } return $ account ; }
Get virtual account. Return empty account instance if no account id virtual is given.

@return  Account
@throws \Exception
Get virtual account . Return empty account instance if no account id virtual is given .