本文整理汇总了PHP中Magento\Framework\ObjectManagerInterface::configure方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManagerInterface::configure方法的具体用法?PHP ObjectManagerInterface::configure怎么用?PHP ObjectManagerInterface::configure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\ObjectManagerInterface
的用法示例。
在下文中一共展示了ObjectManagerInterface::configure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
* @throws \Magento\Framework\Exception\LocalizedException
* @return null|int null or 0 if everything went fine, or an error code
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$omParams = $_SERVER;
$omParams[StoreManager::PARAM_RUN_CODE] = 'admin';
$omParams[Store::CUSTOM_ENTRY_POINT_PARAM] = true;
$this->objectManager = $this->objectManagerFactory->create($omParams);
$area = FrontNameResolver::AREA_CODE;
/** @var \Magento\Framework\App\State $appState */
$appState = $this->objectManager->get('Magento\\Framework\\App\\State');
$appState->setAreaCode($area);
$configLoader = $this->objectManager->get('Magento\\Framework\\ObjectManager\\ConfigLoaderInterface');
$this->objectManager->configure($configLoader->load($area));
$output->writeln('Import started');
$time = microtime(true);
/** @var \FireGento\FastSimpleImport\Model\Importer $importerModel */
$importerModel = $this->objectManager->create('FireGento\\FastSimpleImport\\Model\\Importer');
$productsArray = $this->getEntities();
$importerModel->setBehavior($this->getBehavior());
$importerModel->setEntityCode($this->getEntityCode());
$adapterFactory = $this->objectManager->create('FireGento\\FastSimpleImport\\Model\\Adapters\\NestedArrayAdapterFactory');
$importerModel->setImportAdapterFactory($adapterFactory);
try {
$importerModel->processImport($productsArray);
} catch (\Exception $e) {
$output->writeln($e->getMessage());
}
$output->write($importerModel->getLogTrace());
$output->write($importerModel->getErrorMessages());
$output->writeln('Import finished. Elapsed time: ' . round(microtime(true) - $time, 2) . 's' . "\n");
$this->afterFinishImport();
}
示例2: setUp
protected function setUp()
{
$autoloadWrapper = \Magento\Framework\Autoload\AutoloaderRegistry::getAutoloader();
$autoloadWrapper->addPsr4('Magento\\Wonderland\\', realpath(__DIR__ . '/_files/Magento/Wonderland'));
$this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->_objectManager->configure(['preferences' => ['Magento\\Wonderland\\Api\\Data\\FakeAddressInterface' => 'Magento\\Wonderland\\Model\\FakeAddress', 'Magento\\Wonderland\\Api\\Data\\FakeRegionInterface' => 'Magento\\Wonderland\\Model\\FakeRegion']]);
}
示例3: setUpBeforeClass
public static function setUpBeforeClass()
{
$config = new \Magento\Framework\ObjectManager\Config\Config();
$factory = new Factory\Dynamic\Developer($config);
self::$_objectManager = new \Magento\Framework\ObjectManager\ObjectManager($factory, $config);
self::$_objectManager->configure(['preferences' => [self::TEST_INTERFACE => self::TEST_INTERFACE_IMPLEMENTATION]]);
$factory->setObjectManager(self::$_objectManager);
}
示例4: get
/**
* Retrieve object manager.
*
* @return ObjectManagerInterface
* @throws \Magento\Setup\Exception
*/
public function get()
{
if (null === $this->objectManager) {
$initParams = $this->serviceLocator->get(InitParamListener::BOOTSTRAP_PARAM);
$factory = Bootstrap::createObjectManagerFactory(BP, $initParams);
$this->objectManager = $factory->create($initParams);
$this->objectManager->configure(['Magento\\Framework\\Stdlib\\DateTime\\Timezone' => ['arguments' => ['scopeType' => \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT]]]);
}
return $this->objectManager;
}
示例5: launch
/**
* {@inheritdoc}
**/
public function launch()
{
$areaCode = 'adminhtml';
$this->appState->setAreaCode($areaCode);
$this->objectManager->configure($this->configLoader->load($areaCode));
/** @var \Magento\Tools\SampleData\Logger $sampleDataLogger */
$sampleDataLogger = $this->objectManager->get('Magento\\Tools\\SampleData\\Logger');
$sampleDataLogger->setSubject($this->objectManager->get('Magento\\Setup\\Model\\ConsoleLogger'));
$this->installer->run($this->userFactory->create()->loadByUsername($this->adminUserName));
return $this->response;
}
示例6: launch
/**
* Run application
*
* @return ResponseInterface
*/
public function launch()
{
$this->_state->setAreaCode(Area::AREA_CRONTAB);
$configLoader = $this->objectManager->get('Magento\\Framework\\ObjectManager\\ConfigLoaderInterface');
$this->objectManager->configure($configLoader->load(Area::AREA_CRONTAB));
/** @var \Magento\Framework\Event\ManagerInterface $eventManager */
$eventManager = $this->objectManager->get('Magento\\Framework\\Event\\ManagerInterface');
$eventManager->dispatch('default');
$this->_response->setCode(0);
return $this->_response;
}
示例7: getObjectManager
/**
* Gets initialized object manager
*
* @return ObjectManagerInterface
*/
protected function getObjectManager()
{
if (null == $this->objectManager) {
$area = FrontNameResolver::AREA_CODE;
$this->objectManager = $this->objectManagerFactory->create($_SERVER);
/** @var \Magento\Framework\App\State $appState */
$appState = $this->objectManager->get('Magento\\Framework\\App\\State');
$appState->setAreaCode($area);
$configLoader = $this->objectManager->get('Magento\\Framework\\ObjectManager\\ConfigLoaderInterface');
$this->objectManager->configure($configLoader->load($area));
}
return $this->objectManager;
}
示例8: execute
/**
* {@inheritdoc}
* @throws \InvalidArgumentException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$locale = $input->getOption(self::LOCALE_OPTION);
if (!$this->validator->isValid($locale)) {
throw new \InvalidArgumentException($locale . ' argument has invalid value, please run info:language:list for list of available locales');
}
$area = $input->getOption(self::AREA_OPTION);
$theme = $input->getOption(self::THEME_OPTION);
$type = $input->getArgument(self::TYPE_ARGUMENT);
$this->state->setAreaCode($area);
$this->objectManager->configure($this->configLoader->load($area));
$sourceFileGenerator = $this->sourceFileGeneratorPool->create($type);
foreach ($input->getArgument(self::FILE_ARGUMENT) as $file) {
$file .= '.' . $type;
$output->writeln("<info>Gathering {$file} sources.</info>");
$asset = $this->assetRepo->createAsset($file, ['area' => $area, 'theme' => $theme, 'locale' => $locale]);
$rootDir = $this->filesystem->getDirectoryWrite(DirectoryList::ROOT);
$sourceFile = $this->assetSource->findSource($asset);
$relativePath = $rootDir->getRelativePath($sourceFile);
$content = $rootDir->readFile($relativePath);
$chain = $this->chainFactory->create(['asset' => $asset, 'origContent' => $content, 'origContentType' => $asset->getContentType(), 'origAssetPath' => $relativePath]);
$processedCoreFile = $sourceFileGenerator->generateFileTree($chain);
$targetDir = $this->filesystem->getDirectoryWrite(DirectoryList::STATIC_VIEW);
$source = $rootDir->getRelativePath($processedCoreFile);
$destination = $asset->getPath();
$rootDir->copyFile($source, $destination, $targetDir);
$output->writeln("<info>Successfully processed dynamic stylesheet into CSS</info>");
}
}
示例9: launch
/**
* Launch application
*
* @return \Magento\Framework\App\ResponseInterface
*/
public function launch()
{
$this->objectManager->configure(['preferences' => ['Magento\\Tools\\Di\\Compiler\\Config\\WriterInterface' => 'Magento\\Tools\\Di\\Compiler\\Config\\Writer\\Filesystem', 'Magento\\Tools\\Di\\Compiler\\Log\\Writer\\WriterInterface' => 'Magento\\Tools\\Di\\Compiler\\Log\\Writer\\Console'], 'Magento\\Tools\\Di\\Compiler\\Config\\ModificationChain' => ['arguments' => ['modificationsList' => ['BackslashTrim' => ['instance' => 'Magento\\Tools\\Di\\Compiler\\Config\\Chain\\BackslashTrim'], 'PreferencesResolving' => ['instance' => 'Magento\\Tools\\Di\\Compiler\\Config\\Chain\\PreferencesResolving'], 'InterceptorSubstitution' => ['instance' => 'Magento\\Tools\\Di\\Compiler\\Config\\Chain\\InterceptorSubstitution'], 'InterceptionPreferencesResolving' => ['instance' => 'Magento\\Tools\\Di\\Compiler\\Config\\Chain\\PreferencesResolving'], 'ArgumentsSerialization' => ['instance' => 'Magento\\Tools\\Di\\Compiler\\Config\\Chain\\ArgumentsSerialization']]]], 'Magento\\Tools\\Di\\Code\\Generator\\PluginList' => ['arguments' => ['cache' => ['instance' => 'Magento\\Framework\\App\\Interception\\Cache\\CompiledConfig']]], 'Magento\\Tools\\Di\\Code\\Reader\\ClassesScanner' => ['arguments' => ['excludePatterns' => $this->excludedPathsList]]]);
$operations = [Task\OperationFactory::REPOSITORY_GENERATOR => ['path' => $this->compiledPathsList['application'], 'filePatterns' => ['di' => '/\\/etc\\/([a-zA-Z_]*\\/di|di)\\.xml$/']], Task\OperationFactory::APPLICATION_CODE_GENERATOR => [$this->compiledPathsList['application'], $this->compiledPathsList['library'], $this->compiledPathsList['generated_helpers']], Task\OperationFactory::INTERCEPTION => ['intercepted_paths' => [$this->compiledPathsList['application'], $this->compiledPathsList['library'], $this->compiledPathsList['generated_helpers']], 'path_to_store' => $this->compiledPathsList['generated_helpers']], Task\OperationFactory::AREA_CONFIG_GENERATOR => [$this->compiledPathsList['application'], $this->compiledPathsList['library'], $this->compiledPathsList['generated_helpers']], Task\OperationFactory::INTERCEPTION_CACHE => [$this->compiledPathsList['application'], $this->compiledPathsList['library'], $this->compiledPathsList['generated_helpers']]];
$responseCode = Response::SUCCESS;
try {
foreach ($operations as $operationCode => $arguments) {
$this->taskManager->addOperation($operationCode, $arguments);
}
$this->taskManager->process();
} catch (Task\OperationException $e) {
$responseCode = Response::ERROR;
$this->response->setBody($e->getMessage());
}
$this->response->setCode($responseCode);
return $this->response;
}
示例10: getObjectManager
/**
* Getter for ObjectManager
*
* @return \Magento\Framework\ObjectManagerInterface
*/
public function getObjectManager()
{
if (!$this->objectManager) {
$this->objectManager = $this->initObjectManager();
}
$this->objectManager->configure(['preferences' => ['Migration\\App\\ProgressBar\\LogLevelProcessor' => 'Migration\\TestFramework\\ProgressBar'], 'Migration\\Logger\\Logger' => ['arguments' => ['handlers' => ['quiet' => ['instance' => '\\Migration\\TestFramework\\QuietLogHandler']]]]]);
return $this->objectManager;
}
示例11: _setAreaCode
/**
* Sets area code to start a session for replication.
* TODO: move \Praxigento\App\Generic2\Console\Command\Init\Base into the Core
*/
private function _setAreaCode()
{
/* Magento related config (Object Manager) */
/** @var \Magento\Framework\App\State $appState */
$appState = $this->_manObj->get(\Magento\Framework\App\State::class);
try {
/* area code should be set only once */
$appState->getAreaCode();
} catch (\Magento\Framework\Exception\LocalizedException $e) {
/* exception will be thrown if no area code is set */
$areaCode = 'adminhtml';
$appState->setAreaCode($areaCode);
/** @var \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader */
$configLoader = $this->_manObj->get(\Magento\Framework\ObjectManager\ConfigLoaderInterface::class);
$config = $configLoader->load($areaCode);
$this->_manObj->configure($config);
}
}
示例12: setAreaCode
/**
* Sets area code to start a session for database backup and rollback
*
* @return void
*/
private function setAreaCode()
{
$areaCode = 'adminhtml';
/** @var \Magento\Framework\App\State $appState */
$appState = $this->objectManager->get('Magento\\Framework\\App\\State');
$appState->setAreaCode($areaCode);
/** @var \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader */
$configLoader = $this->objectManager->get('Magento\\Framework\\ObjectManager\\ConfigLoaderInterface');
$this->objectManager->configure($configLoader->load($areaCode));
}
示例13: launch
/**
* Finds requested resource and provides it to the client
*
* @return \Magento\Framework\App\ResponseInterface
* @throws \Exception
*/
public function launch()
{
// disabling profiling when retrieving static resource
\Magento\Framework\Profiler::reset();
$appMode = $this->state->getMode();
if ($appMode == \Magento\Framework\App\State::MODE_PRODUCTION) {
$this->response->setHttpResponseCode(404);
} else {
$path = $this->request->get('resource');
$params = $this->parsePath($path);
$this->state->setAreaCode($params['area']);
$this->objectManager->configure($this->configLoader->load($params['area']));
$file = $params['file'];
unset($params['file']);
$asset = $this->assetRepo->createAsset($file, $params);
$this->response->setFilePath($asset->getSourceFile());
$this->publisher->publish($asset);
}
return $this->response;
}
示例14: configure
/**
* Sets area code to start a adminhtml session and configure Object Manager.
*/
protected function configure()
{
parent::configure();
/* UI related config (Symfony) */
$this->setName($this->_cmdName);
$this->setDescription($this->_cmdDesc);
/* Magento related config (Object Manager) */
/** @var \Magento\Framework\App\State $appState */
$appState = $this->_manObj->get(\Magento\Framework\App\State::class);
try {
/* area code should be set only once */
$appState->getAreaCode();
} catch (\Magento\Framework\Exception\LocalizedException $e) {
/* exception will be thrown if no area code is set */
$areaCode = \Magento\Framework\App\Area::AREA_FRONTEND;
$appState->setAreaCode($areaCode);
/** @var \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader */
$configLoader = $this->_manObj->get(\Magento\Framework\ObjectManager\ConfigLoaderInterface::class);
$config = $configLoader->load($areaCode);
$this->_manObj->configure($config);
}
}
示例15: emulateApplicationArea
/**
* Emulate application area and various services that are necessary for populating files
*
* @param string $areaCode
* @return void
*/
private function emulateApplicationArea($areaCode)
{
$this->objectManager = $this->omFactory->create([\Magento\Framework\App\State::PARAM_MODE => \Magento\Framework\App\State::MODE_DEFAULT]);
/** @var \Magento\Framework\App\State $appState */
$appState = $this->objectManager->get('Magento\\Framework\\App\\State');
$appState->setAreaCode($areaCode);
/** @var \Magento\Framework\App\ObjectManager\ConfigLoader $configLoader */
$configLoader = $this->objectManager->get('Magento\\Framework\\App\\ObjectManager\\ConfigLoader');
$this->objectManager->configure($configLoader->load($areaCode));
$this->assetRepo = $this->objectManager->get('Magento\\Framework\\View\\Asset\\Repository');
$this->assetPublisher = $this->objectManager->create('Magento\\Framework\\App\\View\\Asset\\Publisher');
$this->htmlMinifier = $this->objectManager->get('Magento\\Framework\\View\\Template\\Html\\MinifierInterface');
$this->bundleManager = $this->objectManager->get('Magento\\Framework\\View\\Asset\\Bundle\\Manager');
}