当前位置: 首页>>代码示例>>PHP>>正文


PHP Context::getObjectManager方法代码示例

本文整理汇总了PHP中Magento\Backend\App\Action\Context::getObjectManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::getObjectManager方法的具体用法?PHP Context::getObjectManager怎么用?PHP Context::getObjectManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Backend\App\Action\Context的用法示例。


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

示例1: execute

 /**
  * save product data
  *
  * @param $observer
  *
  * @return $this
  */
 public function execute(EventObserver $observer)
 {
     $downloads = $this->context->getRequest()->getFiles('downloads', -1);
     if ($downloads != '-1') {
         // Get current product
         $product = $this->coreRegistry->registry('product');
         $productId = $product->getId();
         // Loop through uploaded downlaods
         foreach ($downloads as $download) {
             // Upload file
             $uploadedDownload = $this->upload->uploadFile($download);
             if ($uploadedDownload) {
                 $objectManager = $this->context->getObjectManager();
                 // Store date in database
                 $download = $objectManager->create('Sebwite\\ProductDownloads\\Model\\Download');
                 $download->setDownloadUrl($uploadedDownload['file']);
                 $download->setDownloadFile($uploadedDownload['name']);
                 $download->setDownloadType($uploadedDownload['type']);
                 $download->setProductId($productId);
                 $download->save();
             }
         }
     }
     return $this;
 }
开发者ID:Sebwite,项目名称:Magento2-Product-Downloads,代码行数:32,代码来源:Observer.php

示例2: __construct

 /**
  * ApiValidate constructor.
  *
  * @param \Dotdigitalgroup\Email\Helper\Data           $data
  * @param \Magento\Backend\App\Action\Context          $context
  * @param \Magento\Framework\App\Config\Storage\Writer $writer
  */
 public function __construct(\Dotdigitalgroup\Email\Helper\Data $data, \Dotdigitalgroup\Email\Model\Apiconnector\Test $test, \Magento\Backend\App\Action\Context $context, \Magento\Framework\App\Config\Storage\Writer $writer)
 {
     $this->helper = $data;
     $this->test = $test;
     $this->context = $context;
     $this->messageManager = $context->getMessageManager();
     $this->objectManager = $context->getObjectManager();
     $this->writer = $writer;
 }
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:16,代码来源:ApiValidate.php

示例3: __construct

 /**
  * ApiValidate constructor.
  *
  * @param \Dotdigitalgroup\Email\Model\ContactFactory  $contactFactory
  * @param \Dotdigitalgroup\Email\Helper\Data           $data
  * @param \Magento\Backend\App\Action\Context          $context
  * @param \Magento\Store\Model\StoreManagerInterface   $storeManagerInterface
  * @param \Magento\Framework\App\Config\Storage\Writer $writer
  */
 public function __construct(\Dotdigitalgroup\Email\Model\ContactFactory $contactFactory, \Dotdigitalgroup\Email\Helper\Data $data, \Magento\Backend\App\Action\Context $context, \Magento\Store\Model\StoreManagerInterface $storeManagerInterface, \Magento\Framework\App\Config\Storage\Writer $writer)
 {
     $this->_helper = $data;
     $this->_context = $context;
     $this->_contactFactory = $contactFactory;
     $this->_request = $context->getRequest();
     $this->_storeManager = $storeManagerInterface;
     $this->messageManager = $context->getMessageManager();
     $this->_objectManager = $context->getObjectManager();
     $this->_writer = $writer;
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:20,代码来源:ApiValidate.php


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