当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage::reset方法代码示例

本文整理汇总了PHP中Mage::reset方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage::reset方法的具体用法?PHP Mage::reset怎么用?PHP Mage::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage的用法示例。


在下文中一共展示了Mage::reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testReset

 /**
  * @magentoAppIsolation enabled
  */
 public function testReset()
 {
     Mage::setRoot(dirname(__FILE__));
     $this->assertNotNull(Mage::getRoot());
     Mage::reset();
     $this->assertNull(Mage::getRoot());
 }
开发者ID:nemphys,项目名称:magento2,代码行数:10,代码来源:MageTest.php

示例2: init

 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);
     }
 }
开发者ID:nhp,项目名称:Xtest,代码行数:12,代码来源:Xtest.php

示例3: tearDown

 public function tearDown()
 {
     parent::tearDown();
     // reset $_POST
     Mage::app()->getRequest()->setPost(array());
     // close connections
     Mage::getSingleton('core/resource')->getConnection(Mage_Core_Model_Resource_Setup::DEFAULT_SETUP_CONNECTION)->closeConnection();
     // reset session
     if (session_id()) {
         session_destroy();
     }
     // reset Magento
     Mage::reset();
 }
开发者ID:liip,项目名称:liip-magento-shared,代码行数:14,代码来源:Magento.php

示例4: downloadPage

 /**
  * Method download choosen page by url in argument and retrieves
  * its contents.
  * @param string $url
  * @return string contents of downloaded page
  */
 function downloadPage($url)
 {
     if ($this->isReady()) {
         /* remember Magento state and reset Magento */
         $prevURI = $_SERVER['REQUEST_URI'];
         $state = Mage::getStaticState();
         Mage::reset();
         /* start catching output */
         ob_start();
         /* run new Magento */
         $_SERVER['REQUEST_URI'] = preg_replace('/http(s){0,1}:\\/\\/[^\\/]*/', '', $url);
         Mage::run();
         /* get output */
         $html = ob_get_contents();
         /* end catching output */
         ob_end_clean();
         /* restore Magento state */
         Mage::restoreState($state);
         return $html;
     }
     return '';
 }
开发者ID:AmineCherrai,项目名称:rostanvo,代码行数:28,代码来源:Direct.php

示例5: reinitMissingCacheEntry

 /**
  * @test
  * @author Luke Rodgers <lr@amp.co>
  */
 public function reinitMissingCacheEntry()
 {
     /**
      * Initialise Mage and warm the cache
      */
     Mage::app();
     Mage::reset();
     /**
      * Get a copy of the admin configuration from the warmed up cache
      */
     $before = Mage::app()->getCacheInstance()->load('config_global_stores');
     $before = new Varien_Simplexml_Element($before);
     $before = $before->descend('admin')->asXML();
     /**
      * Initialise Mage and remove config_global from the cache, to simulate hitting a fake cache lock
      */
     Mage::reset();
     Mage::app()->getCacheInstance()->remove('config_global');
     /**
      * Recall init, which calls Mage_Core_Model_Config:;init,
      * useCache is still true, but we have the hit the fake cache lock on config_global.
      */
     Mage::app()->init(Mage_Core_Model_App::ADMIN_STORE_ID, 'store');
     /**
      * Get a copy of the admin configuration from the corrupted cache
      */
     Mage::reset();
     $after = Mage::app()->getCacheInstance()->load('config_global_stores');
     $after = new Varien_Simplexml_Element($after);
     $after = $after->descend('admin')->asXML();
     $this->assertEquals($before, $after);
 }
开发者ID:AQuackenbos,项目名称:magento-ce-ee-config-corruption-bug,代码行数:36,代码来源:ConfigurationTest.php

示例6: resetApp

 /**
  * Reset application global state
  */
 public function resetApp()
 {
     /** @var $objectManager Magento_Test_ObjectManager */
     $objectManager = Mage::getObjectManager();
     $objectManager->clearCache();
     $resource = Mage::registry('_singleton/Mage_Core_Model_Resource');
     Mage::reset();
     Varien_Data_Form::setElementRenderer(null);
     Varien_Data_Form::setFieldsetRenderer(null);
     Varien_Data_Form::setFieldsetElementRenderer(null);
     if ($resource) {
         Mage::register('_singleton/Mage_Core_Model_Resource', $resource);
     }
 }
开发者ID:natxetee,项目名称:magento2,代码行数:17,代码来源:Bootstrap.php

示例7: _cleanupMage

 /**
  * Clean the application, so next time it will load itself again (i.e. after uninstall)
  *
  * @return Magento_Application
  */
 protected function _cleanupMage()
 {
     Mage::reset();
     return $this;
 }
开发者ID:nickimproove,项目名称:magento2,代码行数:10,代码来源:Application.php

示例8: die

Mage::reset();
if (!Mage::app()->useCache('config')) {
    die("Config cache needs to be enabled.");
}
/**
 * Clearing every bit of cache I can get a hold of, to simulate an empty cache to begin with
 */
Mage::app()->getCacheInstance()->clean();
Mage::app()->getCacheInstance()->flush();
Mage::app()->getCache()->clean();
Mage::reset();
/**
 * Warming up the cache.
 */
Mage::app();
Mage::reset();
/**
 * Initialise mage app,
 * sets useCache = true
 *
 * Removes config_global to simulate a time sensitive cache hit on the config_global.lock cache entry
 */
Mage::app()->getCacheInstance()->remove('config_global');
/**
 * Recall init, which calls Mage_Core_Model_Config:;init,
 * useCache is still true, but we have the hit the fake cache lock on config_global.
 */
Mage::app()->init(Mage_Core_Model_App::ADMIN_STORE_ID, 'store');
/**
 * Reload a non FPC page, you should see a 100 router match iteration page / no 404 page
 */
开发者ID:AQuackenbos,项目名称:magento-ce-ee-config-corruption-bug,代码行数:31,代码来源:100-router-script.php

示例9: run


//.........这里部分代码省略.........
             } else {
                 printf("There aren't any actions tracked.\r\n");
             }
         } else {
             if ($id = $this->getArgs('r', 'run')) {
                 $this->_printHeader();
                 $pendingList = $this->_io->getPendingList();
                 if (count($pendingList)) {
                     $executed = 0;
                     $session = Mage::getSingleton('adminhtml/session');
                     foreach ($pendingList as $i => $row) {
                         if ($id > 0 && $i + 1 != $id) {
                             continue;
                         }
                         $actionExecutorClass = $row[PugMoRe_Mageploy_Model_Action_Abstract::INDEX_EXECUTOR_CLASS];
                         $actionExecutorVersion = $row[PugMoRe_Mageploy_Model_Action_Abstract::INDEX_VERSION];
                         $controllerModule = $row[PugMoRe_Mageploy_Model_Action_Abstract::INDEX_CONTROLLER_MODULE];
                         $controllerName = $row[PugMoRe_Mageploy_Model_Action_Abstract::INDEX_CONTROLLER_NAME];
                         $controllerClassName = $this->_getControllerClassName($controllerModule, $controllerName);
                         if (class_exists($actionExecutorClass)) {
                             $controllerFileName = $this->_getControllerClassPath($controllerModule, $controllerName);
                             if (file_exists($controllerFileName)) {
                                 include_once $controllerFileName;
                             } else {
                                 printf("Error: file '%s' not found!\r\n", $controllerFileName);
                             }
                             if (class_exists($controllerClassName)) {
                                 $actionExecutor = new $actionExecutorClass();
                                 $parameters = $row[PugMoRe_Mageploy_Model_Action_Abstract::INDEX_ACTION_PARAMS];
                                 try {
                                     $request = $actionExecutor->decode($parameters, $actionExecutorVersion);
                                     $controller = new $controllerClassName($request, new PugMoRe_Mageploy_Controller_Response_Http());
                                     $action = $row[PugMoRe_Mageploy_Model_Action_Abstract::INDEX_ACTION_NAME] . 'Action';
                                     $controller->preDispatch();
                                     $controller->{$action}();
                                     $controller->postDispatch();
                                 } catch (Zend_Controller_Response_Exception $e) {
                                     # do nothing: avoid "Headers already sent" error message
                                 } catch (Exception $e) {
                                     $session->addError($e->getMessage());
                                 }
                                 // Add messages in body response in case of Ajax requests
                                 $messages = $session->getMessages(true);
                                 if ($request && $request->getParam('isAjax', false)) {
                                     $body = $controller->getResponse()->getBody();
                                     $msg = Mage::getSingleton('core/message')->notice($body);
                                     $messages->add($msg);
                                 }
                                 foreach ($messages->getItems() as $message) {
                                     $messageType = $message->getType();
                                     switch ($messageType) {
                                         case Mage_Core_Model_Message::ERROR:
                                             $color = self::TERM_COLOR_RED;
                                             break;
                                         case Mage_Core_Model_Message::SUCCESS:
                                             $color = self::TERM_COLOR_GREEN;
                                             break;
                                         default:
                                             #break intentionally omitted
                                         #break intentionally omitted
                                         case Mage_Core_Model_Message::WARNING:
                                             #break intentionally omitted
                                         #break intentionally omitted
                                         case Mage_Core_Model_Message::NOTICE:
                                             $color = self::TERM_COLOR_YELLOW;
                                             break;
                                     }
                                     printf("Action ID #%d - %s %s\r\n", $i + 1, $this->__getColoredString($message->getType(), $color), $message->getText());
                                 }
                                 $executed++;
                                 // register executed action
                                 $this->_io->done($row);
                             } else {
                                 printf("Error: class '%s' not found!\r\n", $controllerClassName);
                             }
                         } else {
                             printf("Error: class '%s' not found!\r\n", $actionExecutorClass);
                         }
                         // Yes, PHP is Object Oriented but don't forget the
                         // Superglobals! After all PHP is not Java :-)
                         $_GET = array();
                         $_POST = array();
                         $_REQUEST = array();
                         // And don't forget to reinitialize Magento to avoid
                         // problems with already populated objects (i.e. registry)
                         Mage::reset();
                         Mage::init($this->_appCode, $this->_appType);
                     }
                     // end foreach
                     printf("\r\nExecuted actions: %d/%d\r\n", $executed, count($pendingList));
                 } else {
                     printf("There aren't any pending actions to execute.\r\n");
                 }
             } else {
                 echo $this->usageHelp($doTracking);
             }
         }
     }
     printf("\r\n");
 }
开发者ID:ngreimel,项目名称:mageploy,代码行数:101,代码来源:mageploy.php

示例10: run

 /**
  * Runs the WebApplication
  *
  * @param \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest The request instance
  *
  * @return string The web applications content
  */
 public function run(HttpServletRequestInterface $servletRequest)
 {
     try {
         // register the Magento autoloader as FIRST autoloader
         spl_autoload_register(array(new \Varien_Autoload(), 'autoload'), true, true);
         // Varien_Profiler::enable();
         if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
             \Mage::setIsDeveloperMode(true);
         }
         ini_set('display_errors', 1);
         umask(0);
         // store or website code
         $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
         // run store or run website
         $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
         // set headers sent to false and start output caching
         appserver_set_headers_sent(false);
         ob_start();
         // reset and run Magento
         \Mage::reset();
         \Mage::register('ServletRequest', $servletRequest);
         \Mage::run();
         // write the session back after the request
         session_write_close();
         // We need to init the session anew, so PHP session handling will work like it would in a clean environment
         appserver_session_init();
         // grab the contents generated by Magento
         $content = ob_get_clean();
     } catch (\Exception $e) {
         error_log($content = $e->__toString());
     }
     // return the content
     return $content;
 }
开发者ID:appserver-io-lab,项目名称:mage-servlet,代码行数:41,代码来源:MageServlet.php

示例11: testReset

 /**
  * @magentoAppIsolation enabled
  */
 public function testReset()
 {
     Mage::setIsDeveloperMode(true);
     $this->assertTrue(Mage::getIsDeveloperMode());
     Mage::reset();
     $this->assertFalse(Mage::getIsDeveloperMode());
 }
开发者ID:natxetee,项目名称:magento2,代码行数:10,代码来源:MageTest.php

示例12: _cleanUpProcess

 /**
  * clean up runtime details
  */
 protected function _cleanUpProcess()
 {
     Mage::reset();
     Mage::app('admin', 'store');
     $entityCode = $this->getEntityTypeCode();
     $this->_entityTypeId = Mage::getSingleton('eav/config')->getEntityType($entityCode)->getEntityTypeId();
     $this->_connection = Mage::getSingleton('core/resource')->getConnection('write');
 }
开发者ID:tschifftner,项目名称:Magento-MEP,代码行数:11,代码来源:Product.php

示例13: initialize

 /**
  * Initialize an already installed Magento application
  *
  * @param string $scopeCode
  * @param string $scopeType
  */
 public function initialize($scopeCode = '', $scopeType = 'store')
 {
     if (!class_exists('Mage', false)) {
         require_once $this->_magentoDir . '/app/bootstrap.php';
     } else {
         $resource = Mage::registry('_singleton/Mage_Core_Model_Resource');
         Mage::reset();
         if ($resource) {
             Mage::register('_singleton/Mage_Core_Model_Resource', $resource);
         }
     }
     $this->_options = array('etc_dir' => $this->_installEtcDir, 'var_dir' => $this->_installDir, 'tmp_dir' => $this->_installDir . DIRECTORY_SEPARATOR . 'tmp', 'cache_dir' => $this->_installDir . DIRECTORY_SEPARATOR . 'cache', 'log_dir' => $this->_installDir . DIRECTORY_SEPARATOR . 'log', 'session_dir' => $this->_installDir . DIRECTORY_SEPARATOR . 'session', 'media_dir' => $this->_installDir . DIRECTORY_SEPARATOR . 'media', 'upload_dir' => $this->_installDir . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'upload');
     Mage::setIsDeveloperMode($this->_developerMode);
     Mage::app($scopeCode, $scopeType, $this->_options);
 }
开发者ID:relue,项目名称:magento2,代码行数:21,代码来源:Bootstrap.php

示例14: _resetApp

 /**
  * Reset application global state
  */
 protected function _resetApp()
 {
     /** @var $layout Mage_Core_Model_Layout */
     $layout = Mage::registry('_singleton/Mage_Core_Model_Layout');
     if ($layout) {
         /* Force to cleanup circular references */
         $layout->__destruct();
     }
     Mage::reset();
     Varien_Data_Form::setElementRenderer(null);
     Varien_Data_Form::setFieldsetRenderer(null);
     Varien_Data_Form::setFieldsetElementRenderer(null);
 }
开发者ID:nemphys,项目名称:magento2,代码行数:16,代码来源:Bootstrap.php

示例15: saveOrder

 public function saveOrder($code, $products)
 {
     $customer = $this->getCustomer($code);
     $orderData = $this->orderDefaults;
     if (!count($customer->getData())) {
         return false;
     }
     $orderData['session']['customer_id'] = $customer->getId();
     $orderData['session']['store_id'] = $this->getStoreId();
     $session = $this->getSessionModel();
     $session->setCustomerId($customer->getId());
     $session->setStoreId($this->getStoreId());
     $orderData['order']['account']['email'] = $customer->getEmail();
     $billingAddressId = $customer->getDefaultBilling();
     $shippingAddressId = $customer->getDefaultShipping();
     $orderData['order']['billing_address'] = $this->getAddress($billingAddressId);
     $orderData['order']['shipping_address'] = $this->getAddress($shippingAddressId);
     $orderData['add_products'] = $products;
     $order = $this->getOrderModel();
     \Mage::unregister('config');
     \Mage::reset();
     \Mage::app();
     if (count($order->getQuote()->getAllItems())) {
         $quote = $order->getQuote();
         $items = $quote->getAllItems();
         foreach ($items as $item) {
             $quote->removeItem($item->getItemId());
         }
         $quote->save();
         $order->setQuote($quote);
     }
     \Mage::unregister('config');
     \Mage::reset();
     \Mage::app();
     $order->importPostData($orderData['order']);
     \Mage::unregister('rule_data');
     $addedProducts = false;
     foreach ($orderData['add_products'] as $sku => $_data) {
         $price = $_data['price'];
         unset($_data['price']);
         $product = $this->getProductBySku($sku);
         if (!$product) {
             continue;
         }
         $order->getQuote()->addProduct($product, new \Varien_Object(['qty' => $_data['qty']]))->setOriginalCustomPrice($price);
         $addedProducts = true;
     }
     if (!$addedProducts) {
         return false;
     }
     $order->collectShippingRates();
     $order->getQuote()->getPayment()->addData($orderData['payment']);
     $order->initRuleData()->saveQuote();
     $order->setPaymentData($orderData['payment']);
     $order->getQuote()->getPayment()->addData($orderData['payment']);
     \Mage::app()->getStore()->setConfig(\Mage_Sales_Model_Order::XML_PATH_EMAIL_ENABLED, "0");
     $increment_id = false;
     try {
         $increment_id = $order->importPostData($orderData['order'])->createOrder()->getIncrementId();
     } catch (Exception $e) {
         print_r($e);
     }
     \Mage::unregister('config');
     \Mage::reset();
     \Mage::app();
     if (count($order->getQuote()->getAllItems())) {
         $quote = $order->getQuote();
         $items = $quote->getAllItems();
         foreach ($items as $item) {
             $quote->removeItem($item->getItemId());
         }
         $quote->save();
         $order->setQuote($quote);
     }
     \Mage::unregister('config');
     \Mage::reset();
     \Mage::app();
     return $increment_id;
 }
开发者ID:razzman,项目名称:magentoimport,代码行数:79,代码来源:MagentoImporter.php


注:本文中的Mage::reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。