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


PHP ObjectManager::configure方法代碼示例

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


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

示例1: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     $config = new \Magento\Framework\ObjectManager\Config\Config();
     $factory = new \Magento\Framework\ObjectManager\Factory\Factory($config);
     self::$_objectManager = new \Magento\Framework\ObjectManager\ObjectManager($factory, $config);
     self::$_objectManager->configure(array('preferences' => array(self::TEST_INTERFACE => self::TEST_INTERFACE_IMPLEMENTATION)));
     $factory->setObjectManager(self::$_objectManager);
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:8,代碼來源:ObjectManagerTest.php

示例2: testProcess

 /**
  * @magentoConfigFixture current_store catalog/productalert/allow_price 1
  *
  * @magentoDataFixture Magento/ProductAlert/_files/product_alert.php
  */
 public function testProcess()
 {
     $this->_objectManager->configure(['Magento\\ProductAlert\\Model\\Observer' => ['arguments' => ['transportBuilder' => ['instance' => 'Magento\\TestFramework\\Mail\\Template\\TransportBuilderMock']]], 'Magento\\ProductAlert\\Model\\Email' => ['arguments' => ['transportBuilder' => ['instance' => 'Magento\\TestFramework\\Mail\\Template\\TransportBuilderMock']]], 'preferences' => ['Magento\\Framework\\Mail\\TransportInterface' => 'Magento\\TestFramework\\Mail\\TransportInterfaceMock', 'Magento\\TestFramework\\Mail\\Template\\TransportBuilder' => 'Magento\\TestFramework\\Mail\\Template\\TransportBuilderMock']]);
     \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND);
     $observer = $this->_objectManager->get('Magento\\ProductAlert\\Model\\Observer');
     $observer->process();
     /** @var \Magento\TestFramework\Mail\Template\TransportBuilderMock $transportBuilder */
     $transportBuilder = $this->_objectManager->get('Magento\\TestFramework\\Mail\\Template\\TransportBuilderMock');
     $this->assertStringMatchesFormat('%AHello %A' . $this->_customerViewHelper->getCustomerName($this->_customerSession->getCustomerDataObject()) . ',%A', $transportBuilder->getSentMessage()->getBodyHtml()->getContent());
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:15,代碼來源:ObserverTest.php

示例3: launch

 /**
  * Run application
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     $areaCode = 'install';
     $this->_state->setAreaCode($areaCode);
     $this->_objectManager->configure($this->_loader->load($areaCode));
     if (isset($this->_arguments['uninstall'])) {
         $sessionConsole = $this->_objectManager->create('\\Magento\\Framework\\Session\\SessionConsole');
         $installerModel = $this->_objectManager->create('Magento\\Install\\Model\\Installer', ['session' => $sessionConsole]);
         $installer = $this->_installerFactory->create(['installArgs' => $this->_arguments, 'installer' => $installerModel]);
     } else {
         $installer = $this->_installerFactory->create(array('installArgs' => $this->_arguments));
     }
     if (isset($this->_arguments['show_locales'])) {
         $this->_output->readableOutput($this->_output->prepareArray($installer->getAvailableLocales()));
     } elseif (isset($this->_arguments['show_currencies'])) {
         $this->_output->readableOutput($this->_output->prepareArray($installer->getAvailableCurrencies()));
     } elseif (isset($this->_arguments['show_timezones'])) {
         $this->_output->readableOutput($this->_output->prepareArray($installer->getAvailableTimezones()));
     } elseif (isset($this->_arguments['show_install_options'])) {
         $this->_output->readableOutput(PHP_EOL . 'Required parameters:');
         $this->_output->readableOutput($this->_output->alignArrayKeys($installer->getRequiredParams()));
         $this->_output->readableOutput(PHP_EOL . 'Optional parameters:');
         $this->_output->readableOutput($this->_output->alignArrayKeys($installer->getOptionalParams()));
         $this->_output->readableOutput(PHP_EOL . 'Flag values are considered positive if set to 1, y, true or yes.' . 'Any other value is considered as negative.' . PHP_EOL);
     } else {
         $this->_handleInstall($installer);
     }
     $this->_response->setCode(0);
     return $this->_response;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:35,代碼來源:Console.php

示例4: launch

 /**
  * Run application
  *
  * @return ResponseInterface
  */
 public function launch()
 {
     $areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName());
     $this->_state->setAreaCode($areaCode);
     $this->_objectManager->configure($this->_configLoader->load($areaCode));
     $this->_response = $this->_objectManager->get('Magento\\Framework\\App\\FrontControllerInterface')->dispatch($this->_request);
     // This event gives possibility to launch something before sending output (allow cookie setting)
     $eventParams = array('request' => $this->_request, 'response' => $this->_response);
     $this->_eventManager->dispatch('controller_front_send_response_before', $eventParams);
     return $this->_response;
 }
開發者ID:pavelnovitsky,項目名稱:magento2,代碼行數:16,代碼來源:Http.php

示例5: configure

 /**
  * Configure Object Manager
  * This method is static to have the ability to configure multiple instances of Object manager when needed
  *
  * @param MagentoObjectManager $objectManager
  */
 public static function configure(MagentoObjectManager $objectManager)
 {
     $objectManager->configure($objectManager->get('Mtf\\ObjectManager\\ConfigLoader\\Primary')->load());
     $objectManager->configure($objectManager->get('Mtf\\ObjectManager\\ConfigLoader\\Module')->load());
     $objectManager->configure($objectManager->get('Mtf\\ObjectManager\\ConfigLoader\\Module')->load('etc/ui'));
     $objectManager->configure($objectManager->get('Mtf\\ObjectManager\\ConfigLoader\\Module')->load('etc/curl'));
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:13,代碼來源:ObjectManagerFactory.php

示例6: replaceClassName

 /**
  * Replace name of url model
  *
  * @param string $className
  * @return $this
  */
 public function replaceClassName($className)
 {
     $this->_objectManager->configure(array('preferences' => array(self::CLASS_NAME => $className)));
     return $this;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:11,代碼來源:Factory.php

示例7: emulateLayoutArea

 /**
  * @param string $areaCode
  * @return void
  */
 public function emulateLayoutArea($areaCode)
 {
     $configuration = array('Magento\\Framework\\View\\Layout' => array('arguments' => array('area' => $areaCode)));
     $this->_objectManager->configure($configuration);
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:9,代碼來源:AreaEmulator.php


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