當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。