本文整理汇总了PHP中Magento\Framework\ObjectManager\ObjectManager::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager::get方法的具体用法?PHP ObjectManager::get怎么用?PHP ObjectManager::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\ObjectManager\ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
try {
/** @var \Magento\Framework\Component\ComponentRegistrar $componentRegistrar */
$componentRegistrar = $this->objectManager->get('Magento\\Framework\\Component\\ComponentRegistrar');
/** @var \Magento\Framework\Component\DirSearch $dirSearch */
$dirSearch = $this->objectManager->get('Magento\\Framework\\Component\\DirSearch');
/** @var \Magento\Framework\View\Design\Theme\ThemePackageList $themePackageList */
$themePackageList = $this->objectManager->get('Magento\\Framework\\View\\Design\\Theme\\ThemePackageList');
Files::setInstance(new Files($componentRegistrar, $dirSearch, $themePackageList));
$this->buildReport($input->getOption(self::INPUT_KEY_OUTPUT));
$output->writeln('<info>Report successfully processed.</info>');
} catch (\Exception $e) {
$output->writeln('<error>Please check the path you provided. Dependencies report generator failed with error: ' . $e->getMessage() . '</error>');
}
}
示例2: methodInjection
/**
* @param Object $object
* @param string $methodName
*/
public function methodInjection($object, $methodName, ObjectManager $objectManager)
{
$parameters = $this->getMethod($object, $methodName);
$argumentsToInject = [];
foreach ($parameters as $parameter) {
$argumentsToInject[] = $objectManager->get($parameter[1]);
}
call_user_func_array([$object, $methodName], $argumentsToInject);
}
示例3: wrap
/**
* @param string $param
* @return mixed
*/
public function wrap($param)
{
$beforeFunc = __FUNCTION__ . 'Before';
if (isset($this->_pluginList[$beforeFunc])) {
foreach ($this->_pluginList[$beforeFunc] as $plugin) {
$param = $this->_objectManager->get($plugin)->{$beforeFunc}($param);
}
}
$insteadFunc = __FUNCTION__;
if (isset($this->_pluginList[$insteadFunc])) {
$first = reset($this->_pluginList[$insteadFunc]);
$returnValue = $this->_objectManager->get($first)->{$insteadFunc}();
} else {
$returnValue = $this->_getSubject()->wrap($param);
}
$afterFunc = __FUNCTION__ . 'After';
if (isset($this->_pluginList[$afterFunc])) {
foreach (array_reverse($this->_pluginList[$afterFunc]) as $plugin) {
$returnValue = $this->_objectManager->get($plugin)->{$afterFunc}($returnValue);
}
}
return $returnValue;
}
示例4: testGetIgnoresFirstSlash
public function testGetIgnoresFirstSlash()
{
$this->assertSame($this->_object->get('Magento\\Test\\Di\\Child'), $this->_object->get('Magento\\Test\\Di\\Child'));
}