本文整理匯總了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'));
}