當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Transaction::getInstance方法代碼示例

本文整理匯總了PHP中Transaction::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Transaction::getInstance方法的具體用法?PHP Transaction::getInstance怎麽用?PHP Transaction::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Transaction的用法示例。


在下文中一共展示了Transaction::getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUpBeforeClass

 /**
  * This method is called before the first test is executed.
  */
 public static function setUpBeforeClass()
 {
     $transaction = \Transaction::getInstance();
     $user = new \User();
     $user->setTimezone("Europe/Paris");
     $transaction->setUser($user);
 }
開發者ID:fruition-sciences,項目名稱:phpfw,代碼行數:10,代碼來源:MeasureTextboxTest.php

示例2: startExperiment

 /**
  * Initialize the experiment and set all required tracking things
  *
  * @param string $experimentName
  * @param array $experimentConfig
  */
 private static function startExperiment($experimentName, array $experimentConfig)
 {
     wfDebug(sprintf("%s[%s] using %s class with %s params\n", __METHOD__, $experimentName, $experimentConfig['handler'], json_encode($experimentConfig['params'])));
     new $experimentConfig['handler']($experimentConfig['params'] ?: []);
     // mark a transaction with an experiment name
     \Transaction::getInstance()->set(\Transaction::PARAM_AB_PERFORMANCE_TEST, $experimentName);
     // set a global JS variable with an experiment name
     global $wgHooks;
     $wgHooks['WikiaSkinTopScripts'][] = function (array &$vars, &$scripts) use($experimentName) {
         $vars['wgABPerformanceTest'] = $experimentName;
         return true;
     };
     /*
      * Start the session to bypass CDN cache
      *
      * We don't want to polute the CDN cache with the A/B performance testing tracking data.
      * As the test are run for only a small subset of the traffic, start the session for client
      * that are in the test groups to bypass the CDN cache.
      */
     if (session_id() == '') {
         wfSetupSession();
         wfDebug(__METHOD__ . " - session started\n");
         // log started sessions
         global $wgUser;
         WikiaLogger::instance()->info(__METHOD__, ['experiment' => $experimentName, 'session_id' => session_id(), 'is_anon' => $wgUser->isAnon()]);
     }
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:33,代碼來源:Hooks.class.php

示例3: getInstance

 /**
  * Returns the formatter instance. Creates a new one if doesn't exist yet.
  * Uses the timezone of the user of the current transaction.
  * 
  * @return Formatter
  */
 public static function getInstance()
 {
     if (!self::$theInstance) {
         $user = Transaction::getInstance()->getUser();
         self::$theInstance = new Formatter($user->getTimezone(), $user->getLocale());
     }
     return self::$theInstance;
 }
開發者ID:fruition-sciences,項目名稱:phpfw,代碼行數:14,代碼來源:Formatter.php

示例4: setUpBeforeClass

 /**
  * This method is called before the first test is executed.
  */
 public static function setUpBeforeClass()
 {
     $transaction = \Transaction::getInstance();
     $user = new \User();
     $user->setTimezone("Europe/Paris");
     $transaction->setUser($user);
     $zend_locale = new \Zend_Locale("en_US");
     \Zend_Registry::set('Zend_Locale', $zend_locale);
 }
開發者ID:fruition-sciences,項目名稱:phpfw,代碼行數:12,代碼來源:DataConverterTest.php

示例5: getInstance

 /**
  * Returns the DataConverter instance. Creates a new one if doesn't exist yet.
  * Uses the timezone of the user of the current transaction.
  * @return DataConverter
  */
 public static function getInstance()
 {
     if (!self::$theInstance) {
         $timezone = Transaction::getInstance()->getUser()->getTimezone();
         $locale = Transaction::getInstance()->getUser()->getLocale();
         self::$theInstance = new DataConverter($timezone, $locale);
     }
     return self::$theInstance;
 }
開發者ID:fruition-sciences,項目名稱:phpfw,代碼行數:14,代碼來源:DataConverter.php

示例6: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     $transaction = \Transaction::getInstance();
     $user = new \User();
     $user->setTimezone("America/Los_Angeles");
     $user->setLocale("en_US");
     $user->setIsAdmin(true);
     $transaction->setUser($user);
 }
開發者ID:fruition-sciences,項目名稱:phpfw,代碼行數:9,代碼來源:MenuTest.php

示例7: getItems

 public function getItems()
 {
     $user = Transaction::getInstance()->getUser();
     $items = array();
     foreach ($this->xml->item as $element) {
         $item = new MenuItem($this, $element);
         if ($item->getId() == $this->mainMenuId) {
             $item->setSelected(true);
         }
         if (!$item->isAdminOnly() || $user->isAdmin()) {
             $items[] = $item;
         }
     }
     return $items;
 }
開發者ID:fruition-sciences,項目名稱:phpfw,代碼行數:15,代碼來源:Menu.php

示例8: service

 public function service()
 {
     try {
         session_name($this->sessionName);
         Zend_Session::start();
         $transaction = Transaction::getInstance();
         $transaction->setUser($this->getContext()->getUser());
         self::initTranslator($this->getContext()->getUser()->getLocale());
         $this->validate();
         $this->invokeControllerMethod();
     } catch (Exception $e) {
         $this->handleException($e);
     }
     $logTimeEnabled = Config::getInstance()->getBoolean('webapp/logging/timeLog/enabled', false);
     if ($logTimeEnabled) {
         $this->timeLogger->end();
     }
 }
開發者ID:fruition-sciences,項目名稱:phpfw,代碼行數:18,代碼來源:Application.php

示例9: escapeString

 public static function escapeString($str, $withQuotes = true)
 {
     if ($str === null) {
         return "null";
     }
     $db = Transaction::getInstance()->getDB();
     $escaped = '';
     if (method_exists($db, 'getDB')) {
         $caller = self::getCallerFunction();
         Logger::warning("Depracated: Avoid SQLUtils::escapeString. Use prepared statement. Called by: {$caller}");
         $escaped = $db->getDB()->real_escape_string($str);
     } else {
         $escaped = mysql_real_escape_string($str);
     }
     if ($withQuotes) {
         $escaped = "'" . $escaped . "'";
     }
     return $escaped;
 }
開發者ID:fruition-sciences,項目名稱:phpfw,代碼行數:19,代碼來源:SQLUtils.php

示例10: convert

 /**
  * Get the unit from the form. If it's defined and different than the
  * display unit, convert the value and set it back into this control's value.
  * Then, format with proper number of digits.
  * 
  * Do not call this method more than once!
  */
 protected function convert()
 {
     $user = Transaction::getInstance()->getUser();
     if ($this->getValue() !== null && Zend_Locale_Format::isNumber($this->getValue(), array("locale" => $user->getLocale()))) {
         $form = $this->getForm();
         // Get the 'hidden' value, which indicates the unit of the current value.
         $unit = $form->getValue($this->getUnitFieldName());
         // If the unit is different, convert
         if ($unit && $unit != $this->displayUnit) {
             $measure = MeasureUtils::newMeasure($unit, $this->getValue(), $user->getLocale());
             $unitInfo = MeasureUtils::getUnitInfo($this->displayUnit);
             $measure->setType($unitInfo['constantName']);
             // Sets the new value without rounding and without formatting
             $this->setValue($measure->getValue(-1, $user->getLocale()));
         }
         $format = Formatter::getInstance();
         // Format and round the value
         $this->setValue($format->number($format->getNumber($this->getValue()), $this->decimalDigits));
     }
 }
開發者ID:fruition-sciences,項目名稱:phpfw,代碼行數:27,代碼來源:MeasureTextbox.php

示例11: makeDateFromTimestamp

 /**
  * Create a new DateTime object representing the current date/time in the
  * given timezone.
  *
  * @param $timezone (String) the timezone to evaluate the given time in. If
  *        null, the current user's account's timezone will be used.
  * @return DateTime
  */
 public static function makeDateFromTimestamp($timestamp, $timezone = null)
 {
     if (!$timezone) {
         $timezone = Transaction::getInstance()->getUser()->getTimezone();
     }
     $date = new DateTime("@{$timestamp}");
     $tz = new DateTimeZone($timezone);
     $date->setTimezone($tz);
     return $date;
 }
開發者ID:fruition-sciences,項目名稱:phpfw,代碼行數:18,代碼來源:DateUtils.php

示例12: startTransaction

 private function startTransaction()
 {
     $transaction = Transaction::getInstance();
     $user = new User();
     $timezone = Config::getInstance()->getString("properties/anonymousUserTimezone");
     $user->setTimezone($timezone);
     // TODO: set id to root.
     $user->setId(1);
     $transaction->setUser($user);
 }
開發者ID:fruition-sciences,項目名稱:phpfw,代碼行數:10,代碼來源:ExecutableApp.php

示例13: define

 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */
require_once '../../core.php';
//change to your gateway's name
define('GWNAME', 'othertestgateway');
define('INVOICE', (int) $_REQUEST['inv']);
define('AMOUNT', (int) $_REQUEST['received']);
define('KEY', $_REQUEST['secretkey']);
define('COMMENT', '');
$gm = GatewayModule::getInstance();
$curr = Currency::getInstance();
$service = Service::getInstance();
$invoice = Invoice::getInstance();
$tr = Transaction::getInstance();
//finding ID for this gateway
$gwid = $gm->GetID(GWNAME);
if (!$gwid) {
    die("This gateway is not activated and configured to accept payments");
}
$gmdata = $gm->FetchData($gwid);
$invdata = $invoice->FetchData(INVOICE);
$currency = $curr->FetchData($curr->GetID($gmdata['currency'], 'name'));
//$currency = $curr->GetCurrency('',$gmdata['currency']);
$gateway_data = unserialize($gmdata['data']);
if ($invdata['amount'] > AMOUNT * $currency['rate']) {
    echo "Received amount is not enough for this invoice";
    //send some notifications
    exit;
} elseif ($gateway_data['key'] != KEY) {
開發者ID:carriercomm,項目名稱:Multicabinet,代碼行數:31,代碼來源:testgatewayresult.php

示例14: ManageTrans

 public static function ManageTrans()
 {
     $xtpl = self::$xtpl;
     $user = User::getInstance();
     $gm = GatewayModule::getInstance();
     if (!is_numeric(self::$page)) {
         $page = 1;
     } else {
         $page = self::$page;
     }
     $xtpl->assign('FINCURR', 'current');
     $xtpl->assign('MANAGETRANS', 'current');
     $trans = Transaction::getInstance();
     $transbutch = $trans->GetButch(self::$per_page, 1, 'id', 'DESC', self::$per_page * $page - self::$per_page);
     if (count($transbutch) > 0) {
         for ($i = 0; $i < count($transbutch); $i++) {
             $username = '';
             $gatewayname = '';
             if (!is_numeric($transbutch[$i]['customerid']) || !is_string($username = $user->GetUsername($transbutch[$i]['customerid']))) {
                 self::add_message($xtpl, 'attention', 'User #' . $transbutch[$i]['customerid'] . ' not found for transaction #' . $transbutch[$i]['id']);
             } else {
                 $xtpl->assign('USERNAME', $username);
             }
             if (!is_numeric($transbutch[$i]['gatewayid']) || !is_string($gatewayname = $gm->GetName($transbutch[$i]['gatewayid']))) {
                 self::add_message($xtpl, 'attention', 'Payment gateway #' . $transbutch[$i]['gatewayid'] . ' not found for transaction #' . $transbutch[$i]['id']);
             } else {
                 $xtpl->assign('GATEWAYNAME', $gatewayname);
             }
             $xtpl->assign('TRANS', $transbutch[$i]);
             $xtpl->parse('main.managetrans.transtable.transrow');
         }
         for ($i = 1; $i <= self::count_pages($trans->Calculate()); $i++) {
             if ($page == $i) {
                 $xtpl->assign('CURRENT', 'current');
             } else {
                 $xtpl->assign('CURRENT', '');
             }
             $xtpl->assign('NUM', $i);
             if (preg_match('/page=[0-9]+/', self::$request_uri)) {
                 $link = preg_replace('/page=[0-9]+/', 'page=' . $i, self::$request_uri);
             } else {
                 $link = self::$request_uri . '&page=' . $i;
             }
             $xtpl->assign('LINK', $link);
             $xtpl->parse('main.managetrans.transtable.page');
         }
         $xtpl->parse('main.managetrans.transtable');
     } else {
         $xtpl->parse('main.managetrans.transinfo');
     }
     $xtpl->parse('main.managetrans');
     $xtpl->parse('main');
     $xtpl->out('main');
 }
開發者ID:carriercomm,項目名稱:Multicabinet,代碼行數:54,代碼來源:class.Page.php

示例15: getDatePickerLocalization

 /**
  * Localization array for the Jquery UI date time picker.
  * @return array
  */
 private function getDatePickerLocalization()
 {
     $daysArr = Zend_Locale_Data::getList(Transaction::getInstance()->getUser()->getLocale(), "days");
     $weekArr = Zend_Locale_Data::getList(Transaction::getInstance()->getUser()->getLocale(), "week");
     $firstDay = $daysArr['format']['narrow'][$weekArr["firstDay"]] - 1;
     $tr = Application::getTranslator();
     // Most i18n values come from dedicated jquery.ui.datepicker-<LANG>.js
     // Make sure to include this file on all pages.
     // The fields defined here are the ones used by the datetimepicker extension.
     $regional = array("closeText" => $tr->_('Done'), "dateFormat" => $tr->_('m/dd/yy'), "firstDay" => $firstDay, "isRTL" => false, "showMonthAfterYear" => false, "yearSuffix" => '');
     if ($this->showTime) {
         $regional["currentText"] = $tr->_('Now');
         $regional["amNames"] = array('AM', 'A');
         $regional["pmNames"] = array('PM', 'P');
         // Important: timeFormat must be compatible with pattern used by Formatter::datetime for each locale
         $regional["timeFormat"] = $tr->_('h:mm TT');
         $regional["timeSuffix"] = '';
         $regional["timeOnlyTitle"] = $tr->_('Choose Time');
         $regional["timeText"] = $tr->_('Time');
         $regional["hourText"] = $tr->_('Hour');
         $regional["minuteText"] = $tr->_('Minute');
         $regional["secondText"] = $tr->_('Second');
         $regional["millisecText"] = $tr->_('Millisecond');
         $regional["timezoneText"] = $tr->_('Time Zone');
     }
     return $regional;
 }
開發者ID:fruition-sciences,項目名稱:phpfw,代碼行數:31,代碼來源:Datebox.php


注:本文中的Transaction::getInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。