Example #1
0
File: Xtest.php Project: nhp/Xtest
 protected static function init($code)
 {
     Mage::$headersSentThrowsException = false;
     $options = array();
     $options['config_model'] = 'Codex_Xtest_Model_Core_Config';
     $options['cache_dir'] = Mage::getBaseDir('var') . DS . 'cache' . DS . 'xtest';
     Mage::reset();
     Mage::app($code, 'store', $options);
     if ($disableDouble = (bool) self::getArg('disable_double', false)) {
         self::getConfig()->setDisableDoubles($disableDouble);
     }
 }
Example #2
0
File: api.php Project: Vedariy/test
if (!file_exists($mageFilename)) {
    echo 'Mage file not found';
    exit;
}
require $mageFilename;
if (!Mage::isInstalled()) {
    echo 'Application is not installed yet, please complete install wizard first.';
    exit;
}
if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
    Mage::setIsDeveloperMode(true);
}
#ini_set('display_errors', 1);
// emulate index.php entry point for correct URLs generation in API
Mage::register('custom_entry_point', true);
Mage::$headersSentThrowsException = false;
Mage::init('admin');
Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS);
Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_ADMINHTML, Mage_Core_Model_App_Area::PART_EVENTS);
// query parameter "type" is set by .htaccess rewrite rule
$apiAlias = Mage::app()->getRequest()->getParam('type');
// check request could be processed by API2
if (in_array($apiAlias, Mage_Api2_Model_Server::getApiTypes())) {
    /** @var $server Mage_Api2_Model_Server */
    $server = Mage::getSingleton('api2/server');
    $server->run();
} else {
    /* @var $server Mage_Api_Model_Server */
    $server = Mage::getSingleton('api/server');
    $adapterCode = $server->getAdapterCodeByAlias($apiAlias);
    // if no adapters found in aliases - find it by default, by code
Example #3
0
 protected function _initTaxAndCurrency($paramsArray)
 {
     // Order tax percent
     // -------------------------------------
     $this->_taxPercent = $paramsArray['taxPercent'];
     // -------------------------------------
     // Order tax amount
     // -------------------------------------
     $this->_taxAmount = $paramsArray['taxAmount'];
     // -------------------------------------
     // Has tax on shipping
     // -------------------------------------
     $this->_taxIncludesShipping = (bool) (int) $paramsArray['taxIncludesShipping'];
     // -------------------------------------
     // Hack for cron
     // -------------------------------------
     $tempHeadersSentThrowsException = Mage::$headersSentThrowsException;
     Mage::$headersSentThrowsException = false;
     // -------------------------------------
     // Set store current currency
     // -------------------------------------
     $this->_quote->getStore()->setCurrentCurrencyCode($this->_orderCurrencyCode);
     // -------------------------------------
     // Hack for cron
     // -------------------------------------
     Mage::$headersSentThrowsException = $tempHeadersSentThrowsException;
     // -------------------------------------
 }
Example #4
0
 /**
  * Initialize an already installed Magento application
  */
 public function initialize()
 {
     Mage::setIsDeveloperMode($this->_isDeveloperMode);
     Mage_Core_Utility_Theme::registerDesignMock();
     Mage::$headersSentThrowsException = false;
     Mage::app('', 'store', $this->_options);
 }
Example #5
0
 /**
  * Initialize an already installed Magento application
  */
 public function initialize()
 {
     $resource = Mage::registry('_singleton/Mage_Core_Model_Resource');
     $this->_resetApp();
     if ($resource) {
         Mage::register('_singleton/Mage_Core_Model_Resource', $resource);
     }
     Mage::setIsDeveloperMode($this->_developerMode);
     Mage::$headersSentThrowsException = false;
     Mage::app('', 'store', $this->_options);
 }
Example #6
0
 public function setUp()
 {
     parent::setUp();
     Mage::$headersSentThrowsException = false;
 }
Example #7
0
 protected function _doDispatch(Codex_Xtest_Model_Core_Controller_Request_Http $request, $postData = null)
 {
     Mage::app()->getStore()->setConfig('web/session/use_frontend_sid', true);
     if ($postData) {
         $request->setMethod(self::METHOD_POST);
         if (!isset($postData['form_key'])) {
             $postData['form_key'] = Mage::getSingleton('core/session')->getFormKey();
         }
         $request->setPost($postData);
     }
     Mage::$headersSentThrowsException = false;
     Mage::app()->setRequest($request);
     $dispatcher = new Codex_Xtest_Model_Core_Controller_Varien_Front();
     $dispatcher->setRouter(Mage::app()->getFrontController()->getRouters());
     $dispatcher->dispatch();
     foreach ($dispatcher->getResponse()->getHeaders() as $header) {
         if ($header['value'] == '404 Not Found') {
             Mage::throwException('404');
         }
     }
 }