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


PHP Mage::getObjectManager方法代码示例

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


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

示例1: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     self::$_objectManager = Mage::getObjectManager();
     // get list of not existing tables
     /** @var $application Mage_Core_Model_App */
     $application = self::$_objectManager->get('Mage_Core_Model_App');
     /** @var $categoryResource Mage_Catalog_Model_Resource_Category_Flat */
     $categoryResource = self::$_objectManager->create('Mage_Catalog_Model_Resource_Category_Flat');
     /** @var $setupModel Mage_Core_Model_Resource_Setup */
     $setupModel = self::$_objectManager->create('Mage_Core_Model_Resource_Setup', array('resourceName' => Mage_Core_Model_Resource_Setup::DEFAULT_SETUP_CONNECTION));
     $stores = $application->getStores();
     /** @var $store Mage_Core_Model_Store */
     foreach ($stores as $store) {
         $tableName = $categoryResource->getMainStoreTable($store->getId());
         if (!$setupModel->getConnection()->isTableExists($tableName)) {
             self::$_indexerTables[] = $tableName;
         }
     }
     // create flat tables
     /** @var $indexer Mage_Catalog_Model_Category_Indexer_Flat */
     $indexer = self::$_objectManager->create('Mage_Catalog_Model_Category_Indexer_Flat');
     $indexer->reindexAll();
     // set real time indexer mode
     $process = self::_getCategoryIndexerProcess();
     self::$_indexerMode = $process->getMode();
     $process->setMode(Mage_Index_Model_Process::MODE_REAL_TIME);
     $process->save();
 }
开发者ID:natxetee,项目名称:magento2,代码行数:28,代码来源:CategoryTest.php

示例2: setUp

 protected function setUp()
 {
     $this->_helper = Mage::helper('Mage_Catalog_Helper_Product_View');
     $request = new Magento_Test_Request();
     $request->setRouteName('catalog')->setControllerName('product')->setActionName('view');
     $this->_controller = Mage::getModel('Mage_Catalog_ProductController', array($request, new Magento_Test_Response(), 'frontend', Mage::getObjectManager(), Mage::getObjectManager()->get('Mage_Core_Controller_Varien_Front'), Mage::getObjectManager()->get('Mage_Core_Model_Layout_Factory')));
 }
开发者ID:natxetee,项目名称:magento2,代码行数:7,代码来源:ViewTest.php

示例3: testGetUrl

 public function testGetUrl()
 {
     $action = Mage::getModel('Mage_Core_Controller_Front_Action', array(new Magento_Test_Request(), new Magento_Test_Response(), 'frontend', Mage::getObjectManager(), Mage::getObjectManager()->get('Mage_Core_Controller_Varien_Front'), Mage::getObjectManager()->get('Mage_Core_Model_Layout_Factory')));
     Mage::app()->getFrontController()->setAction($action);
     // done in action's constructor
     $this->assertStringEndsWith('/?cat%5B0%5D=valuePart1&cat%5B1%5D=valuePart2', $this->_model->getUrl());
 }
开发者ID:natxetee,项目名称:magento2,代码行数:7,代码来源:ItemTest.php

示例4: setUp

 protected function setUp()
 {
     $this->_block = Mage::getObjectManager()->create('Mage_Catalog_Block_Product_View');
     $this->_product = Mage::getModel('Mage_Catalog_Model_Product');
     $this->_product->load(1);
     Mage::unregister('product');
     Mage::register('product', $this->_product);
 }
开发者ID:natxetee,项目名称:magento2,代码行数:8,代码来源:ViewTest.php

示例5: testGetListUrl

 /**
  * @magentoDataFixture Mage/Catalog/_files/multiple_products.php
  */
 public function testGetListUrl()
 {
     /** @var $empty Mage_Catalog_Helper_Product_Compare */
     $empty = Mage::getObjectManager()->create('Mage_Catalog_Helper_Product_Compare');
     $this->assertContains('/catalog/product_compare/index/', $empty->getListUrl());
     $this->_populateCompareList();
     $this->assertRegExp('#/catalog/product_compare/index/items/(?:10,11|11,10)/#', $this->_helper->getListUrl());
 }
开发者ID:natxetee,项目名称:magento2,代码行数:11,代码来源:CompareTest.php

示例6: testGetMoneybookersLogoSrc

 /**
  * @dataProvider getMoneybookersLogoSrcDataProvider
  */
 public function testGetMoneybookersLogoSrc($localeCode, $expectedFile)
 {
     Mage::app()->getLocale()->setLocale($localeCode);
     /** @var $blockFactory Mage_Core_Model_BlockFactory */
     $blockFactory = Mage::getObjectManager()->get('Mage_Core_Model_BlockFactory');
     $block = $blockFactory->createBlock('Phoenix_Moneybookers_Block_Payment');
     $this->assertStringEndsWith($expectedFile, $block->getMoneybookersLogoSrc());
 }
开发者ID:natxetee,项目名称:magento2,代码行数:11,代码来源:PaymentTest.php

示例7: setUp

 protected function setUp()
 {
     Mage_Core_Utility_Theme::registerDesignMock();
     Mage::getDesign()->setDefaultDesignTheme();
     $this->_mail = $this->getMock('Zend_Mail', array('send', 'addTo', 'addBcc', 'setReturnPath', 'setReplyTo'), array('utf-8'));
     $this->_model = $this->getMockBuilder('Mage_Core_Model_Email_Template')->setMethods(array('_getMail'))->setConstructorArgs(array($this->getMockBuilder('Mage_Core_Model_Event_Manager')->disableOriginalConstructor()->getMock(), $this->getMockBuilder('Mage_Core_Model_Cache')->disableOriginalConstructor()->getMock(), Mage::getObjectManager()->create('Magento_Filesystem')))->getMock();
     $this->_model->expects($this->any())->method('_getMail')->will($this->returnCallback(array($this, 'getMail')));
     $this->_model->setSenderName('sender')->setSenderEmail('sender@example.com')->setTemplateSubject('Subject');
 }
开发者ID:natxetee,项目名称:magento2,代码行数:9,代码来源:TemplateTest.php

示例8: setUp

 /**
  * Bootstrap application before eny test
  *
  * @return void
  */
 protected function setUp()
 {
     $this->_objectManager = Mage::getObjectManager();
     /**
      * Use run options from bootstrap
      */
     $this->_runOptions = $this->_getBootstrap()->getAppOptions();
     $this->_runOptions['request'] = $this->getRequest();
     $this->_runOptions['response'] = $this->getResponse();
 }
开发者ID:natxetee,项目名称:magento2,代码行数:15,代码来源:ControllerAbstract.php

示例9: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     $mediaDir = Mage::app()->getConfig()->getOptions()->getMediaDir();
     $filesystem = Mage::getObjectManager()->create('Magento_Filesystem');
     $filesystem->delete($mediaDir . '/theme/frontend');
     $filesystem->delete($mediaDir . '/theme/_merged');
     $ioAdapter = new Varien_Io_File();
     $ioAdapter->cp(Mage::app()->getConfig()->getOptions()->getJsDir() . '/prototype/prototype.js', Mage::app()->getConfig()->getOptions()->getJsDir() . '/prototype/prototype.min.js');
     self::$_developerMode = Mage::getIsDeveloperMode();
 }
开发者ID:natxetee,项目名称:magento2,代码行数:10,代码来源:PackageTest.php

示例10: getMaxUploadSizeMessage

 /**
  * Get maximum upload size message
  *
  * @return string
  */
 public function getMaxUploadSizeMessage()
 {
     $maxImageSize = Mage::getObjectManager()->get('Magento_File_Size')->getMaxFileSizeInMb();
     if ($maxImageSize) {
         $message = $this->__('Total size of uploadable files must not exceed %sM', $maxImageSize);
     } else {
         $message = $this->__('System doesn\'t allow to get file upload settings');
     }
     return $message;
 }
开发者ID:natxetee,项目名称:magento2,代码行数:15,代码来源:Data.php

示例11: setUp

 protected function setUp()
 {
     $this->_objectManager = Mage::getObjectManager();
     $this->_model = $this->_objectManager->create('Mage_Index_Model_Process_File');
     /** @var $configuration Mage_Core_Model_Config */
     $configuration = $this->_objectManager->get('Mage_Core_Model_Config');
     $this->_fileDirectory = $configuration->getVarDir('locks');
     $fullFileName = $this->_fileDirectory . DIRECTORY_SEPARATOR . self::FILE_NAME;
     $this->_testFileHandler = fopen($fullFileName, 'w');
 }
开发者ID:nickimproove,项目名称:magento2,代码行数:10,代码来源:FileTest.php

示例12: testWidgetTemplates

 /**
  * Check if all the declared widget templates actually exist
  *
  * @param string $class
  * @param string $template
  * @dataProvider widgetTemplatesDataProvider
  */
 public function testWidgetTemplates($class, $template)
 {
     /** @var $blockFactory Mage_Core_Model_BlockFactory */
     $blockFactory = Mage::getObjectManager()->get('Mage_Core_Model_BlockFactory');
     /** @var Mage_Core_Block_Template $block */
     $block = $blockFactory->createBlock($class);
     $this->assertInstanceOf('Mage_Core_Block_Template', $block);
     $block->setTemplate((string) $template);
     $this->assertFileExists($block->getTemplateFile());
 }
开发者ID:natxetee,项目名称:magento2,代码行数:17,代码来源:TemplateFilesTest.php

示例13: testIsThemeSelected

 /**
  * @magentoDbIsolation enabled
  * @magentoAppIsolation enabled
  */
 public function testIsThemeSelected()
 {
     $themeOld = Mage::getObjectManager()->create('Mage_Core_Model_Theme')->setData($this->_getThemeSampleData())->setThemePath('a/b')->setThemeCode('b')->save();
     $themeNew = Mage::getObjectManager()->create('Mage_Core_Model_Theme')->setData($this->_getThemeSampleData())->setThemePath('c/d')->setThemeCode('d')->save();
     Mage::getDesign()->setDesignTheme($themeOld);
     $isSelected = $this->_block->isThemeSelected($themeOld->getId());
     $this->assertTrue($isSelected);
     Mage::getDesign()->setDesignTheme($themeNew);
     $isSelected = $this->_block->isThemeSelected($themeOld->getId());
     $this->assertFalse($isSelected);
 }
开发者ID:nickimproove,项目名称:magento2,代码行数:15,代码来源:ThemeTest.php

示例14: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     /* Point application to predefined layout fixtures */
     Mage::getConfig()->setOptions(array('design_dir' => realpath(__DIR__ . '/../../_files/design')));
     /** @var $themeRegistration Mage_Core_Model_Theme_Registration */
     $themeRegistration = Mage::getObjectManager()->create('Mage_Core_Model_Theme_Registration');
     $themeRegistration->register();
     Mage::getDesign()->setDesignTheme('test/default', 'adminhtml');
     /* Disable loading and saving layout cache */
     Mage::app()->getCacheInstance()->banUse('layout');
 }
开发者ID:nickimproove,项目名称:magento2,代码行数:11,代码来源:MassactionTest.php

示例15: testSetCustomerFilter

 public function testSetCustomerFilter()
 {
     $collection = new Mage_Customer_Model_Resource_Address_Collection();
     $select = $collection->getSelect();
     $this->assertSame($collection, $collection->setCustomerFilter(array(1, 2)));
     $customer = Mage::getObjectManager()->create('Mage_Customer_Model_Customer');
     $collection->setCustomerFilter($customer);
     $customer->setId(3);
     $collection->setCustomerFilter($customer);
     $this->assertStringMatchesFormat('%AWHERE%S(%Sparent_id%S IN(%S1%S, %S2%S))%SAND%S(%Sparent_id%S = %S-1%S)%SAND%S(%Sparent_id%S = %S3%S)%A', (string) $select);
 }
开发者ID:nickimproove,项目名称:magento2,代码行数:11,代码来源:CollectionTest.php


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