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


PHP ObjectManager::get方法代碼示例

本文整理匯總了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>');
     }
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:19,代碼來源:AbstractDependenciesCommand.php

示例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);
 }
開發者ID:ktomk,項目名稱:n98-magerun2,代碼行數:13,代碼來源:InjectionHelper.php

示例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;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:27,代碼來源:Interceptor.php

示例4: testGetIgnoresFirstSlash

 public function testGetIgnoresFirstSlash()
 {
     $this->assertSame($this->_object->get('Magento\\Test\\Di\\Child'), $this->_object->get('Magento\\Test\\Di\\Child'));
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:4,代碼來源:ObjectManagerTest.php


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