本文整理汇总了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);
}
示例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());
}
示例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;
}
示例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;
}
示例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'));
}
示例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;
}
示例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);
}