• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP App\ObjectManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Magento\Framework\App\ObjectManager的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager类的具体用法?PHP ObjectManager怎么用?PHP ObjectManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ObjectManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: setUp

 protected function setUp()
 {
     $this->context = $this->getMock('Magento\\Framework\\View\\Element\\Template\\Context', [], [], '', false, false);
     $this->orderCollectionFactory = $this->getMockBuilder('Magento\\Sales\\Model\\ResourceModel\\Order\\CollectionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->orderCollectionFactoryInterface = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface::class)->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false);
     $this->objectManager->expects($this->any())->method('get')->will($this->returnValue($this->orderCollectionFactoryInterface));
     \Magento\Framework\App\ObjectManager::setInstance($this->objectManager);
     $this->customerSession = $this->getMockBuilder('Magento\\Customer\\Model\\Session')->setMethods(['getCustomerId'])->disableOriginalConstructor()->getMock();
     $this->orderConfig = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Config')->setMethods(['getVisibleOnFrontStatuses'])->disableOriginalConstructor()->getMock();
     $this->pageConfig = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->disableOriginalConstructor()->getMock();
     $this->pageTitleMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->disableOriginalConstructor()->getMock();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:HistoryTest.php


示例2: getDataPersistor

 /**
  * Get Data Persistor
  *
  * @return DataPersistorInterface
  */
 private function getDataPersistor()
 {
     if ($this->dataPersistor === null) {
         $this->dataPersistor = ObjectManager::getInstance()->get(DataPersistorInterface::class);
     }
     return $this->dataPersistor;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:CheckContactUsFormObserver.php


示例3: getOptionRepository

 /**
  * @return Option\Repository
  */
 private function getOptionRepository()
 {
     if (null === $this->optionRepository) {
         $this->optionRepository = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\\Catalog\\Model\\Product\\Option\\Repository');
     }
     return $this->optionRepository;
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:10,代码来源:Copier.php


示例4: getAnchorUrlRewriteGenerator

 /**
  * @return AnchorUrlRewriteGenerator
  *
  * @deprecated
  */
 private function getAnchorUrlRewriteGenerator()
 {
     if ($this->anchorUrlRewriteGenerator === null) {
         $this->anchorUrlRewriteGenerator = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\\CatalogUrlRewrite\\Model\\Product\\AnchorUrlRewriteGenerator');
     }
     return $this->anchorUrlRewriteGenerator;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:ProductUrlRewriteGenerator.php


示例5: _construct

 protected function _construct()
 {
     if ($this->checkConfig()) {
         $page = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\\Framework\\View\\Page\\Config');
         $page->addPageAsset('Mageplaza_Blog::css/index/mp.css');
     }
 }
开发者ID:mageplaza,项目名称:magento-2-blog-extension,代码行数:7,代码来源:Init.php


示例6: execute

 public function execute()
 {
     $result = $this->resultJsonFactory->create();
     $data = array();
     try {
         $params = $this->getRequest()->getParams();
         if (isset($params['lastid']) && isset($params['limit'])) {
             $lastId = $params['lastid'];
             $limit = $params['limit'];
             $isadmin = isset($params['isadmin']) ? $params['isadmin'] : false;
             $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
             $raaDataHelper = $objectManager->create('Retail\\Analytics\\Helper\\Data');
             $width = $raaDataHelper->getImageWidth();
             $height = $raaDataHelper->getImageHeight();
             $imagetype = "small_image";
             if (isset($params['width']) && $params['width'] != null && $params['width'] != "") {
                 $width = $params['width'];
             }
             if (isset($params['height']) && $params['height'] != null && $params['height'] != "") {
                 $height = $params['height'];
             }
             if (isset($params['imagetype']) && $params['imagetype'] != null && $params['imagetype'] != "") {
                 $imagetype = $params['imagetype'];
             }
             $producCollection = new \Retail\Analytics\Model\Product();
             $data = $producCollection->getProductFinalPrice($lastId, $limit, $imagetype, $width, $height, $isadmin);
             return $result->setData($data);
         }
     } catch (Exception $e) {
         return $result->setData($data);
     }
 }
开发者ID:niransingh,项目名称:magento2,代码行数:32,代码来源:RaaProductFinalPrice.php


示例7: __wakeup

 /**
  * {@inheritdoc}
  */
 public function __wakeup()
 {
     parent::__wakeup();
     $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
     $this->_resource = $objectManager->get('Magento\\Authorization\\Model\\ResourceModel\\Role');
     $this->_resourceCollection = $objectManager->get('Magento\\Authorization\\Model\\ResourceModel\\Role\\Collection');
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:Role.php


示例8: getHttpClientFactory

 /**
  * Get HttpClientFactory dependency
  *
  * @return \Magento\Framework\HTTP\ZendClientFactory
  *
  * @deprecated
  */
 private function getHttpClientFactory()
 {
     if ($this->httpClientFactory === null) {
         $this->httpClientFactory = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\\Framework\\HTTP\\ZendClientFactory');
     }
     return $this->httpClientFactory;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:14,代码来源:Webservicex.php


示例9: createTestimonialAction

 public function createTestimonialAction()
 {
     $data = $this->getRequest()->getPost();
     $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
     $testimonial = $objectManager->get('V3N0m21\\Testimonials\\Model\\Testimonial');
     $testimonial->setId();
 }
开发者ID:V3N0m21,项目名称:test-example,代码行数:7,代码来源:Index.php


示例10: testSetSaveHandler

 /**
  * Tests that the session handler is correctly set when object is created.
  *
  * @dataProvider saveHandlerProvider
  * @param string $deploymentConfigHandler
  * @param string $iniHandler
  */
 public function testSetSaveHandler($deploymentConfigHandler, $iniHandler)
 {
     // Set expected session.save_handler config
     if ($deploymentConfigHandler) {
         if ($deploymentConfigHandler !== 'files') {
             $expected = 'user';
         } else {
             $expected = $deploymentConfigHandler;
         }
     } else {
         if ($iniHandler) {
             $expected = $iniHandler;
         } else {
             $expected = SaveHandlerInterface::DEFAULT_HANDLER;
         }
     }
     // Set ini configuration
     if ($iniHandler) {
         ini_set('session.save_handler', $iniHandler);
     }
     /** @var DeploymentConfig | \PHPUnit_Framework_MockObject_MockObject $deploymentConfigMock */
     $deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class)->disableOriginalConstructor()->getMock();
     $deploymentConfigMock->expects($this->once())->method('get')->with(Config::PARAM_SESSION_SAVE_METHOD, SaveHandlerInterface::DEFAULT_HANDLER)->willReturn($deploymentConfigHandler ?: SaveHandlerInterface::DEFAULT_HANDLER);
     new SaveHandler(ObjectManager::getInstance()->get(SaveHandlerFactory::class), $deploymentConfigMock);
     // Test expectation
     $this->assertEquals($expected, ObjectManager::getInstance()->get(ConfigInterface::class)->getOption('session.save_handler'));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:34,代码来源:SaveHandlerTest.php


示例11: _prepareForm

 /**
  * Prepare form fields
  *
  * @return \Magento\Backend\Block\Widget\Form
  */
 protected function _prepareForm()
 {
     $form = $this->_formFactory->create();
     $form->setHtmlIdPrefix('manufacturer_');
     $form->setFieldNameSuffix('manufacturer');
     $model = $this->_coreRegistry->registry('manufacturer_manufacturer');
     $om = \Magento\Framework\App\ObjectManager::getInstance();
     $reader = $om->get('Magento\\Eav\\Model\\Config')->getAttribute('catalog_product', 'manufacturer');
     $attributeOptions = $reader->getSource()->getAllOptions(true, true);
     $default = array('value' => '', 'label' => 'Choose Brand');
     $i = 0;
     $manufacturer[$i] = $default;
     foreach ($attributeOptions as $key => $value) {
         $i++;
         if ($key != 0) {
             $manufacturer[$i] = $value;
             //$name[$i] = $value['label'];
         }
     }
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('General')]);
     if ($model->getId()) {
         $fieldset->addField('id', 'hidden', ['name' => 'id']);
     }
     $fieldset->addField('mfc_id', 'select', ['name' => 'mfc_id', 'label' => __('Manufacturer'), 'required' => true, 'values' => $manufacturer]);
     $fieldset->addField('status', 'select', ['name' => 'status', 'label' => __('Status'), 'options' => $this->_manufacturerStatus->toOptionArray()]);
     $fieldset->addField('position', 'textarea', ['name' => 'position', 'label' => __('Position'), 'required' => true, 'style' => 'height: 15em; width: 30em;']);
     $fieldset->addField('image_path', 'image', array('name' => 'image_path', 'label' => __('Image'), 'title' => __('Image')));
     $wysiwygConfig = $this->_wysiwygConfig->getConfig();
     $fieldset->addField('description', 'editor', ['name' => 'description', 'label' => __('Description'), 'required' => true, 'config' => $wysiwygConfig]);
     $data = $model->getData();
     $form->setValues($data);
     $this->setForm($form);
     return parent::_prepareForm();
 }
开发者ID:rushvisilk,项目名称:mage2-helloworld,代码行数:39,代码来源:Info.php


示例12: getImageUploader

 /**
  * Get image uploader
  *
  * @return \Magento\Catalog\Model\ImageUploader
  *
  * @deprecated
  */
 private function getImageUploader()
 {
     if ($this->imageUploader === null) {
         $this->imageUploader = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\\Catalog\\CategoryImageUpload');
     }
     return $this->imageUploader;
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:14,代码来源:Image.php


示例13: getItmeProductThumbnailUrl

 public function getItmeProductThumbnailUrl()
 {
     $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
     $thumbnailHelper = $objectManager->get('Magento\\Catalog\\Helper\\Image');
     $thumbnail = $thumbnailHelper->init($this->getItmeProduct(), 'thumbnail')->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)->setImageFile($this->getItmeProduct()->getImage())->resize('160', '160')->getUrl();
     return $thumbnail;
 }
开发者ID:mengento,项目名称:Magento2_Order_Item_Thumbnail,代码行数:7,代码来源:Thumbnail.php


示例14: getAttributeHelper

 /**
  * The getter function to get the attributeHelper for real application code
  *
  * @deprecated
  *
  * @return Attribute
  */
 private function getAttributeHelper()
 {
     if ($this->attributeHelper === null) {
         $this->attributeHelper = ObjectManager::getInstance()->get('Magento\\Eav\\Model\\Entity\\Attribute');
     }
     return $this->attributeHelper;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:Config.php


示例15: getCookieMetadataFactory

 /**
  * Retrieve cookie metadata factory
  *
  * @deprecated
  * @return CookieMetadataFactory
  */
 private function getCookieMetadataFactory()
 {
     if (!$this->cookieMetadataFactory) {
         $this->cookieMetadataFactory = ObjectManager::getInstance()->get(CookieMetadataFactory::class);
     }
     return $this->cookieMetadataFactory;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:Logout.php


示例16: getNameFinder

 /**
  * The getter function to get the new NameFinder dependency
  *
  * @return NameFinder
  *
  * @deprecated
  */
 private function getNameFinder()
 {
     if ($this->nameFinder === null) {
         $this->nameFinder = \Magento\Framework\App\ObjectManager::getInstance()->get('\\Magento\\Framework\\Reflection\\NameFinder');
     }
     return $this->nameFinder;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:TypeProcessor.php


示例17: getValidator

 /**
  * Get config validator
  *
  * @return Design\Config\Validator
  *
  * @deprecated
  */
 private function getValidator()
 {
     if (null === $this->validator) {
         $this->validator = \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Theme\Model\Design\Config\Validator::class);
     }
     return $this->validator;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:DesignConfigRepository.php


示例18: __wakeup

 public function __wakeup()
 {
     $this->pluginLocator = \Magento\Framework\App\ObjectManager::getInstance();
     $this->pluginList = $this->pluginLocator->get('Magento\\Framework\\Interception\\PluginList');
     $this->chain = $this->pluginLocator->get('Magento\\Framework\\Interception\\Chain');
     $this->subjectType = get_parent_class($this);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:7,代码来源:SourceClassWithNamespaceInterceptor.php


示例19: isAuthorized

 public function isAuthorized()
 {
     $om = \Magento\Framework\App\ObjectManager::getInstance();
     $session = $om->get('Magento\\Framework\\App\\Http\\Context');
     $isLoggedIn = $session->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);
     return $isLoggedIn;
 }
开发者ID:V3N0m21,项目名称:test-example,代码行数:7,代码来源:TestimonialList.php


示例20: getRuleFactory

 /**
  * The getter function to get the new RuleFactory dependency
  *
  * @return \Magento\SalesRule\Model\RuleFactory
  *
  * @deprecated
  */
 private function getRuleFactory()
 {
     if ($this->ruleFactory === null) {
         $this->ruleFactory = ObjectManager::getInstance()->get('Magento\\SalesRule\\Model\\RuleFactory');
     }
     return $this->ruleFactory;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:Conditions.php



注:本文中的Magento\Framework\App\ObjectManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP App\RequestInterface类代码示例发布时间:2022-05-23
下一篇:
PHP App\Filesystem类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap