src/ShopCurrencyBundle/objects/db/TPkgShopCurrency.class.php
public function SetAsActive()
    {
        $sCurrencyId = $this->id;

        /** @var Request $request */
        $request = ServiceLocator::get('request_stack')->getCurrentRequest();
        $request->getSession()->set(TdbPkgShopCurrency::SESSION_NAME, $sCurrencyId);

        $sDomain = $request->getHost();
        if ('www.' == substr($sDomain, 0, 4)) {
            $sDomain = substr($sDomain, 4);
        }
        setcookie(TdbPkgShopCurrency::SESSION_NAME, base64_encode($sCurrencyId), time() + 60 * 60 * 24 * 365, '/', '.'.$sDomain, false, true);
        $oUser = TdbDataExtranetUser::GetInstance();

        if (!is_null($oUser->id) && !empty($oUser->id) && array_key_exists('pkg_shop_currency_id', $oUser->sqlData) && $oUser->sqlData['pkg_shop_currency_id'] != $sCurrencyId && $oUser->IsLoggedIn()) {
            $oUser->SaveFieldsFast(array('pkg_shop_currency_id' => $sCurrencyId));
        } else {
            $oUser->sqlData['pkg_shop_currency_id'] = $sCurrencyId;
            $oUser->fieldPkgShopCurrencyId = $sCurrencyId;
        }
        TdbPkgShopCurrency::GetActiveInstance(true);

        $this->getEventDispatcher()->dispatch(
            ShopCurrencyEvents::CURRENCY_CHANGED,
            new CurrencyChangedEvent($sCurrencyId)
        );
        // also mark basket as "requires recalculation"
        $oBasket = TShopBasket::GetInstance();
        $oBasket->SetBasketRecalculationFlag(true);
    }
public function SetAsActive()
    {
        $sCurrencyId = $this->id;

        /** @var Request $request */
        $request = ServiceLocator::get('request_stack')->getCurrentRequest();
        $request->getSession()->set(TdbPkgShopCurrency::SESSION_NAME, $sCurrencyId);

        $sDomain = $request->getHost();
        if ('www.' == substr($sDomain, 0, 4)) {
            $sDomain = substr($sDomain, 4);
        }
        setcookie(TdbPkgShopCurrency::SESSION_NAME, base64_encode($sCurrencyId), time() + 60 * 60 * 24 * 365, '/', '.'.$sDomain, false, true);
        $oUser = TdbDataExtranetUser::GetInstance();

        if (!is_null($oUser->id) && !empty($oUser->id) && array_key_exists('pkg_shop_currency_id', $oUser->sqlData) && $oUser->sqlData['pkg_shop_currency_id'] != $sCurrencyId && $oUser->IsLoggedIn()) {
            $oUser->SaveFieldsFast(array('pkg_shop_currency_id' => $sCurrencyId));
        } else {
            $oUser->sqlData['pkg_shop_currency_id'] = $sCurrencyId;
            $oUser->fieldPkgShopCurrencyId = $sCurrencyId;
        }
        TdbPkgShopCurrency::GetActiveInstance(true);

        $this->getEventDispatcher()->dispatch(
            ShopCurrencyEvents::CURRENCY_CHANGED,
            new CurrencyChangedEvent($sCurrencyId)
        );
        // also mark basket as "requires recalculation"
        $oBasket = TShopBasket::GetInstance();
        $oBasket->SetBasketRecalculationFlag(true);
    }
public function SetAsActive ( ) { $ sCurrencyId = $ this -> id ; /** @var Request $request */ $ request = ServiceLocator :: get ( 'request_stack' ) -> getCurrentRequest ( ) ; $ request -> getSession ( ) -> set ( TdbPkgShopCurrency :: SESSION_NAME , $ sCurrencyId ) ; $ sDomain = $ request -> getHost ( ) ; if ( 'www.' == substr ( $ sDomain , 0 , 4 ) ) { $ sDomain = substr ( $ sDomain , 4 ) ; } setcookie ( TdbPkgShopCurrency :: SESSION_NAME , base64_encode ( $ sCurrencyId ) , time ( ) + 60 * 60 * 24 * 365 , '/' , '.' . $ sDomain , false , true ) ; $ oUser = TdbDataExtranetUser :: GetInstance ( ) ; if ( ! is_null ( $ oUser -> id ) && ! empty ( $ oUser -> id ) && array_key_exists ( 'pkg_shop_currency_id' , $ oUser -> sqlData ) && $ oUser -> sqlData [ 'pkg_shop_currency_id' ] != $ sCurrencyId && $ oUser -> IsLoggedIn ( ) ) { $ oUser -> SaveFieldsFast ( array ( 'pkg_shop_currency_id' => $ sCurrencyId ) ) ; } else { $ oUser -> sqlData [ 'pkg_shop_currency_id' ] = $ sCurrencyId ; $ oUser -> fieldPkgShopCurrencyId = $ sCurrencyId ; } TdbPkgShopCurrency :: GetActiveInstance ( true ) ; $ this -> getEventDispatcher ( ) -> dispatch ( ShopCurrencyEvents :: CURRENCY_CHANGED , new CurrencyChangedEvent ( $ sCurrencyId ) ) ; // also mark basket as "requires recalculation" $ oBasket = TShopBasket :: GetInstance ( ) ; $ oBasket -> SetBasketRecalculationFlag ( true ) ; }
set this currency object as the active object.
set this currency object as the active object .