/** * Returns object instance * * @return oxUtilsObject */ public static function getInstance() { // disable caching for test modules if (defined('OXID_PHP_UNIT')) { self::$_instance = null; } if (!self::$_instance instanceof UtilsObject) { // allow modules $oUtilsObject = new UtilsObject(); $classMapProvider = new ClassMapProvider(new EditionSelector()); $classNameProvider = new ClassNameProvider($classMapProvider->getOverridableClassMap()); $moduleVariablesCache = $oUtilsObject->oxNew('oxFileCache'); $shopIdCalculator = $oUtilsObject->oxNew('oxShopIdCalculator', $moduleVariablesCache); $subShopSpecific = $oUtilsObject->oxNew('oxSubShopSpecificFileCache', $shopIdCalculator); $moduleVariablesLocator = $oUtilsObject->oxNew('oxModuleVariablesLocator', $subShopSpecific, $shopIdCalculator); $moduleChainsGenerator = $oUtilsObject->oxNew('oxModuleChainsGenerator', $moduleVariablesLocator); self::$_instance = $oUtilsObject->oxNew('oxUtilsObject', $classNameProvider, $moduleChainsGenerator, $shopIdCalculator); } return self::$_instance; }
/** * Generates and saves vouchers. Returns number of saved records * * @param int $iCnt voucher counter offset * * @return int saved record count */ public function generateVoucher($iCnt) { $iAmount = abs((int) oxRegistry::getSession()->getVariable("voucherAmount")); // creating new vouchers if ($iCnt < $iAmount && ($oVoucherSerie = $this->_getVoucherSerie())) { if (!$this->_iGenerated) { $this->_iGenerated = $iCnt; } $blRandomNr = (bool) oxRegistry::getSession()->getVariable("randomVoucherNr"); $sVoucherNr = $blRandomNr ? \OxidEsales\Eshop\Core\UtilsObject::getInstance()->generateUID() : oxRegistry::getSession()->getVariable("voucherNr"); $oNewVoucher = oxNew("oxvoucher"); $oNewVoucher->oxvouchers__oxvoucherserieid = new oxField($oVoucherSerie->getId()); $oNewVoucher->oxvouchers__oxvouchernr = new oxField($sVoucherNr); $oNewVoucher->save(); $this->_iGenerated++; } return $this->_iGenerated; }