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

PHP Result\RawFactory类代码示例

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

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



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

示例1: execute

 /**
  * Forward request for a graph image to the web-service
  *
  * This is done in order to include the image to a HTTPS-page regardless of web-service settings
  *
  * @return  \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $error = __('invalid request');
     $httpCode = 400;
     $gaData = $this->_request->getParam('ga');
     $gaHash = $this->_request->getParam('h');
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     if ($gaData && $gaHash) {
         /** @var $helper \Magento\Backend\Helper\Dashboard\Data */
         $helper = $this->_objectManager->get('Magento\\Backend\\Helper\\Dashboard\\Data');
         $newHash = $helper->getChartDataHash($gaData);
         if ($newHash == $gaHash) {
             $params = json_decode(base64_decode(urldecode($gaData)), true);
             if ($params) {
                 try {
                     /** @var $httpClient \Magento\Framework\HTTP\ZendClient */
                     $httpClient = $this->_objectManager->create('Magento\\Framework\\HTTP\\ZendClient');
                     $response = $httpClient->setUri(\Magento\Backend\Block\Dashboard\Graph::API_URL)->setParameterGet($params)->setConfig(['timeout' => 5])->request('GET');
                     $headers = $response->getHeaders();
                     $resultRaw->setHeader('Content-type', $headers['Content-type'])->setContents($response->getBody());
                     return $resultRaw;
                 } catch (\Exception $e) {
                     $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
                     $error = __('see error log for details');
                     $httpCode = 503;
                 }
             }
         }
     }
     $resultRaw->setHeader('Content-Type', 'text/plain; charset=UTF-8')->setHttpResponseCode($httpCode)->setContents(__('Service unavailable: %1', $error));
     return $resultRaw;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:40,代码来源:Tunnel.php


示例2: execute

 /**
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     try {
         $uploader = $this->_objectManager->create('Magento\\MediaStorage\\Model\\File\\Uploader', ['fileId' => 'image']);
         $uploader->setAllowedExtensions(['jpg', 'jpeg', 'gif', 'png']);
         /** @var \Magento\Framework\Image\Adapter\AdapterInterface $imageAdapter */
         $imageAdapter = $this->_objectManager->get('Magento\\Framework\\Image\\AdapterFactory')->create();
         $uploader->addValidateCallback('catalog_product_image', $imageAdapter, 'validateUploadFile');
         $uploader->setAllowRenameFiles(true);
         $uploader->setFilesDispersion(true);
         /** @var \Magento\Framework\Filesystem\Directory\Read $mediaDirectory */
         $mediaDirectory = $this->_objectManager->get('Magento\\Framework\\Filesystem')->getDirectoryRead(DirectoryList::MEDIA);
         $config = $this->_objectManager->get('Magento\\Catalog\\Model\\Product\\Media\\Config');
         $result = $uploader->save($mediaDirectory->getAbsolutePath($config->getBaseTmpMediaPath()));
         $this->_eventManager->dispatch('catalog_product_gallery_upload_image_after', ['result' => $result, 'action' => $this]);
         unset($result['tmp_name']);
         unset($result['path']);
         $result['url'] = $this->_objectManager->get('Magento\\Catalog\\Model\\Product\\Media\\Config')->getTmpMediaUrl($result['file']);
         $result['file'] = $result['file'] . '.tmp';
     } catch (\Exception $e) {
         $result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()];
     }
     /** @var \Magento\Framework\Controller\Result\Raw $response */
     $response = $this->resultRawFactory->create();
     $response->setHeader('Content-type', 'text/plain');
     $response->setContents(json_encode($result));
     return $response;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:31,代码来源:Upload.php


示例3: execute

 /**
  * Login registered users and initiate a session.
  *
  * Expects a POST. ex for JSON {"username":"[email protected]", "password":"userpassword"}
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     $credentials = null;
     $httpBadRequestCode = 400;
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     try {
         $credentials = $this->helper->jsonDecode($this->getRequest()->getContent());
     } catch (\Exception $e) {
         return $resultRaw->setHttpResponseCode($httpBadRequestCode);
     }
     if (!$credentials || $this->getRequest()->getMethod() !== 'POST' || !$this->getRequest()->isXmlHttpRequest()) {
         return $resultRaw->setHttpResponseCode($httpBadRequestCode);
     }
     $response = ['errors' => false, 'message' => __('Login successful.')];
     try {
         $customer = $this->customerAccountManagement->authenticate($credentials['username'], $credentials['password']);
         $this->customerSession->setCustomerDataAsLoggedIn($customer);
         $this->customerSession->regenerateId();
     } catch (EmailNotConfirmedException $e) {
         $response = ['errors' => true, 'message' => $e->getMessage()];
     } catch (InvalidEmailOrPasswordException $e) {
         $response = ['errors' => true, 'message' => $e->getMessage()];
     } catch (\Exception $e) {
         $response = ['errors' => true, 'message' => __('Something went wrong while validating the login and password.')];
     }
     /** @var \Magento\Framework\Controller\Result\Json $resultJson */
     $resultJson = $this->resultJsonFactory->create();
     return $resultJson->setData($response);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:37,代码来源:Login.php


示例4: execute

 /**
  * Check whether vat is valid
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $result = $this->_validate();
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     return $resultRaw->setContents((int) $result->getIsValid());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:Validate.php


示例5: execute

 /**
  * Delete file from media storage
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     try {
         if (!$this->getRequest()->isPost()) {
             throw new \Exception('Wrong request.');
         }
         $files = $this->getRequest()->getParam('files');
         /** @var $helper \Magento\Cms\Helper\Wysiwyg\Images */
         $helper = $this->_objectManager->get('Magento\\Cms\\Helper\\Wysiwyg\\Images');
         $path = $this->getStorage()->getSession()->getCurrentPath();
         foreach ($files as $file) {
             $file = $helper->idDecode($file);
             /** @var \Magento\Framework\Filesystem $filesystem */
             $filesystem = $this->_objectManager->get('Magento\\Framework\\Filesystem');
             $dir = $filesystem->getDirectoryRead(DirectoryList::MEDIA);
             $filePath = $path . '/' . $file;
             if ($dir->isFile($dir->getRelativePath($filePath))) {
                 $this->getStorage()->deleteFile($filePath);
             }
         }
         return $this->resultRawFactory->create();
     } catch (\Exception $e) {
         $result = ['error' => true, 'message' => $e->getMessage()];
         /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         return $resultJson->setData($result);
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:33,代码来源:DeleteFiles.php


示例6: executeInternal

 /**
  * Update items qty action
  *
  * @return \Magento\Framework\Controller\Result\Json|\Magento\Framework\Controller\Result\Raw
  */
 public function executeInternal()
 {
     try {
         $this->creditmemoLoader->setOrderId($this->getRequest()->getParam('order_id'));
         $this->creditmemoLoader->setCreditmemoId($this->getRequest()->getParam('creditmemo_id'));
         $this->creditmemoLoader->setCreditmemo($this->getRequest()->getParam('creditmemo'));
         $this->creditmemoLoader->setInvoiceId($this->getRequest()->getParam('invoice_id'));
         $this->creditmemoLoader->load();
         $resultPage = $this->resultPageFactory->create();
         $response = $resultPage->getLayout()->getBlock('order_items')->toHtml();
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $response = ['error' => true, 'message' => $e->getMessage()];
     } catch (\Exception $e) {
         $response = ['error' => true, 'message' => __('We can\'t update the item\'s quantity right now.')];
     }
     if (is_array($response)) {
         $resultJson = $this->resultJsonFactory->create();
         $resultJson->setData($response);
         return $resultJson;
     } else {
         $resultRaw = $this->resultRawFactory->create();
         $resultRaw->setContents($response);
         return $resultRaw;
     }
 }
开发者ID:nblair,项目名称:magescotch,代码行数:30,代码来源:UpdateQty.php


示例7: execute

 /**
  * Get specified tab grid
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Products'));
     $this->productBuilder->build($this->getRequest());
     $block = $this->getRequest()->getParam('gridOnlyBlock');
     $blockClassSuffix = str_replace(' ', '_', ucwords(str_replace('_', ' ', $block)));
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     return $resultRaw->setContents($this->layoutFactory->create()->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Product\\Edit\\Tab\\' . $blockClassSuffix)->toHtml());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:GridOnly.php


示例8: execute

 /**
  * WYSIWYG editor action for ajax request
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $elementId = $this->getRequest()->getParam('element_id', md5(microtime()));
     $storeId = $this->getRequest()->getParam('store_id', 0);
     $storeMediaUrl = $this->_objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->getStore($storeId)->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
     $content = $this->layoutFactory->create()->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Helper\\Form\\Wysiwyg\\Content', '', ['data' => ['editor_element_id' => $elementId, 'store_id' => $storeId, 'store_media_url' => $storeMediaUrl]]);
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     return $resultRaw->setContents($content->toHtml());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Wysiwyg.php


示例9: execute

 /**
  * Save fieldset state through AJAX
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     if ($this->getRequest()->getParam('isAjax') && $this->getRequest()->getParam('container') != '' && $this->getRequest()->getParam('value') != '') {
         $configState = [$this->getRequest()->getParam('container') => $this->getRequest()->getParam('value')];
         $this->_saveState($configState);
         /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
         $resultRaw = $this->resultRawFactory->create();
         return $resultRaw->setContents('success');
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:State.php


示例10: execute

 /**
  * Chooser Source action
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $uniqId = $this->getRequest()->getParam('uniq_id');
     /** @var \Magento\Framework\View\Layout $layout */
     $layout = $this->layoutFactory->create();
     $pagesGrid = $layout->createBlock('Magento\\Cms\\Block\\Adminhtml\\Page\\Widget\\Chooser', '', ['data' => ['id' => $uniqId]]);
     $html = $pagesGrid->toHtml();
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     return $resultRaw->setContents($html);
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:16,代码来源:Chooser.php


示例11: execute

 /**
  * Show item update result from loadBlockAction
  * to prevent popup alert with resend data question
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     $session = $this->_objectManager->get('Magento\\Backend\\Model\\Session');
     if ($session->hasUpdateResult() && is_scalar($session->getUpdateResult())) {
         $resultRaw->setContents($session->getUpdateResult());
     }
     $session->unsUpdateResult();
     return $resultRaw;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:ShowUpdateResult.php


示例12: execute

 /**
  * Grid Action
  * Display list of products related to current category
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $category = $this->_initCategory(true);
     if (!$category) {
         /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
         $resultRedirect = $this->resultRedirectFactory->create();
         return $resultRedirect->setPath('catalog/*/', ['_current' => true, 'id' => null]);
     }
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     return $resultRaw->setContents($this->layoutFactory->create()->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Category\\Tab\\Product', 'category.product.grid')->toHtml());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:Grid.php


示例13: execute

 /**
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     $output = '';
     $blockTab = $this->getRequest()->getParam('block');
     $blockClassSuffix = str_replace(' ', '\\', ucwords(str_replace('_', ' ', $blockTab)));
     if (in_array($blockTab, ['tab_orders', 'tab_amounts', 'totals'])) {
         $output = $this->layoutFactory->create()->createBlock('Magento\\Backend\\Block\\Dashboard\\' . $blockClassSuffix)->toHtml();
     }
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     return $resultRaw->setContents($output);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:AjaxBlock.php


示例14: execute

 /**
  * Delete folder action
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     try {
         $path = $this->getStorage()->getCmsWysiwygImages()->getCurrentPath();
         $this->getStorage()->deleteDirectory($path);
         return $this->resultRawFactory->create();
     } catch (\Exception $e) {
         $result = ['error' => true, 'message' => $e->getMessage()];
         /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         return $resultJson->setData($result);
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:DeleteFolder.php


示例15: execute

 /**
  * Fire when select image
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     $helper = $this->_objectManager->get('Magento\\Cms\\Helper\\Wysiwyg\\Images');
     $storeId = $this->getRequest()->getParam('store');
     $filename = $this->getRequest()->getParam('filename');
     $filename = $helper->idDecode($filename);
     $asIs = $this->getRequest()->getParam('as_is');
     $this->_objectManager->get('Magento\\Catalog\\Helper\\Data')->setStoreId($storeId);
     $helper->setStoreId($storeId);
     $image = $helper->getImageHtmlDeclaration($filename, $asIs);
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     return $resultRaw->setContents($image);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:19,代码来源:OnInsert.php


示例16: execute

 /**
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 public function execute()
 {
     /** @var \Magento\Framework\Module\Dir\Reader $reader */
     $reader = $this->_objectManager->get('Magento\\Framework\\Module\\Dir\\Reader');
     $viewDir = $reader->getModuleDir(\Magento\Framework\Module\Dir::MODULE_VIEW_DIR, 'Owebia_AdvancedShippingSetting');
     $locale = $this->_localeResolver->getLocale();
     $defaultPath = $viewDir . '/doc_en_US.html';
     $localePath = str_replace('en_US', $locale, $defaultPath);
     /** @var Filesystem $filesystem */
     $filesystem = $this->_objectManager->get('Magento\\Framework\\Filesystem');
     $readInterface = $filesystem->getDirectoryRead(DirectoryList::ROOT);
     $docPath = $readInterface->isFile($localePath) ? $localePath : $defaultPath;
     $docRelativePath = $readInterface->getRelativePath($docPath);
     return $this->resultRawFactory->create()->setHttpResponseCode(200)->setHeader('Pragma', 'public', true)->setHeader('Content-type', 'text/html; charset=UTF-8', true)->setContents($readInterface->readFile($docRelativePath));
 }
开发者ID:owebia,项目名称:magento2-module-advanced-shipping-setting,代码行数:18,代码来源:Display.php


示例17: execute

 /**
  * Login registered users and initiate a session.
  *
  * Expects a POST. ex for JSON {"username":"[email protected]", "password":"userpassword"}
  *
  * @return \Magento\Framework\Controller\ResultInterface
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function execute()
 {
     $credentials = null;
     $httpBadRequestCode = 400;
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     try {
         $credentials = $this->helper->jsonDecode($this->getRequest()->getContent());
     } catch (\Exception $e) {
         return $resultRaw->setHttpResponseCode($httpBadRequestCode);
     }
     if (!$credentials || $this->getRequest()->getMethod() !== 'POST' || !$this->getRequest()->isXmlHttpRequest()) {
         return $resultRaw->setHttpResponseCode($httpBadRequestCode);
     }
     $response = ['errors' => false, 'message' => __('Login successful.')];
     try {
         $customer = $this->customerAccountManagement->authenticate($credentials['username'], $credentials['password']);
         $this->customerSession->setCustomerDataAsLoggedIn($customer);
         $this->customerSession->regenerateId();
         $redirectRoute = $this->getAccountRedirect()->getRedirectCookie();
         if (!$this->getScopeConfig()->getValue('customer/startup/redirect_dashboard') && $redirectRoute) {
             $response['redirectUrl'] = $this->_redirect->success($redirectRoute);
             $this->getAccountRedirect()->clearRedirectCookie();
         }
     } catch (EmailNotConfirmedException $e) {
         $response = ['errors' => true, 'message' => $e->getMessage()];
     } catch (InvalidEmailOrPasswordException $e) {
         $response = ['errors' => true, 'message' => $e->getMessage()];
     } catch (\Exception $e) {
         $response = ['errors' => true, 'message' => __('Invalid login or password.')];
     }
     /** @var \Magento\Framework\Controller\Result\Json $resultJson */
     $resultJson = $this->resultJsonFactory->create();
     return $resultJson->setData($response);
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:43,代码来源:Login.php


示例18: testExecute

 /**
  * Test execute
  *
  * @return void
  */
 public function testExecute()
 {
     $data = ['comment' => 'test comment'];
     $invoiceId = 2;
     $response = 'some result';
     $this->requestMock->expects($this->at(0))->method('getParam')->with('id')->willReturn($invoiceId);
     $this->requestMock->expects($this->at(1))->method('setParam');
     $this->requestMock->expects($this->at(2))->method('getPost')->with('comment')->willReturn($data);
     $this->requestMock->expects($this->at(3))->method('getParam')->with('invoice_id')->willReturn($invoiceId);
     $invoiceMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Invoice')->disableOriginalConstructor()->setMethods([])->getMock();
     $invoiceMock->expects($this->once())->method('addComment')->with($data['comment'], false, false);
     $invoiceMock->expects($this->once())->method('save');
     $invoiceMock->expects($this->once())->method('load')->willReturnSelf();
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Sales\\Model\\Order\\Invoice')->willReturn($invoiceMock);
     $commentsBlockMock = $this->getMockBuilder('Magento\\Sales\\Block\\Adminhtml\\Order\\Invoice\\View\\Comments')->disableOriginalConstructor()->setMethods([])->getMock();
     $commentsBlockMock->expects($this->once())->method('toHtml')->will($this->returnValue($response));
     $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout')->disableOriginalConstructor()->setMethods([])->getMock();
     $layoutMock->expects($this->once())->method('getBlock')->with('invoice_comments')->will($this->returnValue($commentsBlockMock));
     $this->resultPageFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->resultPageMock));
     $this->resultPageMock->expects($this->any())->method('getLayout')->will($this->returnValue($layoutMock));
     $this->commentSenderMock->expects($this->once())->method('send')->with($invoiceMock, false, $data['comment']);
     $resultRaw = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Raw')->disableOriginalConstructor()->setMethods([])->getMock();
     $resultRaw->expects($this->once())->method('setContents')->with($response);
     $this->resultRawFactoryMock->expects($this->once())->method('create')->will($this->returnValue($resultRaw));
     $this->assertSame($resultRaw, $this->controller->execute());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:31,代码来源:AddCommentTest.php


示例19: executeInternal

 /**
  * Chooser Source action
  *
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function executeInternal()
 {
     $uniqId = $this->getRequest()->getParam('uniq_id');
     $massAction = $this->getRequest()->getParam('use_massaction', false);
     $productTypeId = $this->getRequest()->getParam('product_type_id', null);
     $layout = $this->layoutFactory->create();
     $productsGrid = $layout->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Product\\Widget\\Chooser', '', ['data' => ['id' => $uniqId, 'use_massaction' => $massAction, 'product_type_id' => $productTypeId, 'category_id' => $this->getRequest()->getParam('category_id')]]);
     $html = $productsGrid->toHtml();
     if (!$this->getRequest()->getParam('products_grid')) {
         $categoriesTree = $layout->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Category\\Widget\\Chooser', '', ['data' => ['id' => $uniqId . 'Tree', 'node_click_listener' => $productsGrid->getCategoryClickListenerJs(), 'with_empty_node' => true]]);
         $html = $layout->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Product\\Widget\\Chooser\\Container')->setTreeHtml($categoriesTree->toHtml())->setGridHtml($html)->toHtml();
     }
     /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
     $resultRaw = $this->resultRawFactory->create();
     return $resultRaw->setContents($html);
 }
开发者ID:nblair,项目名称:magescotch,代码行数:21,代码来源:Chooser.php


示例20: execute

 /**
  * Add comment to creditmemo history
  *
  * @return \Magento\Framework\Controller\Result\Raw|\Magento\Framework\Controller\Result\Json
  */
 public function execute()
 {
     try {
         $this->getRequest()->setParam('creditmemo_id', $this->getRequest()->getParam('id'));
         $data = $this->getRequest()->getPost('comment');
         if (empty($data['comment'])) {
             throw new \Magento\Framework\Exception\LocalizedException(__('Please enter a comment.'));
         }
         $this->creditmemoLoader->setOrderId($this->getRequest()->getParam('order_id'));
         $this->creditmemoLoader->setCreditmemoId($this->getRequest()->getParam('creditmemo_id'));
         $this->creditmemoLoader->setCreditmemo($this->getRequest()->getParam('creditmemo'));
         $this->creditmemoLoader->setInvoiceId($this->getRequest()->getParam('invoice_id'));
         $creditmemo = $this->creditmemoLoader->load();
         $comment = $creditmemo->addComment($data['comment'], isset($data['is_customer_notified']), isset($data['is_visible_on_front']));
         $comment->save();
         $this->creditmemoCommentSender->send($creditmemo, !empty($data['is_customer_notified']), $data['comment']);
         $resultPage = $this->resultPageFactory->create();
         $response = $resultPage->getLayout()->getBlock('creditmemo_comments')->toHtml();
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $response = ['error' => true, 'message' => $e->getMessage()];
     } catch (\Exception $e) {
         $response = ['error' => true, 'message' => __('Cannot add new comment.')];
     }
     if (is_array($response)) {
         $resultJson = $this->resultJsonFactory->create();
         $resultJson->setData($response);
         return $resultJson;
     } else {
         $resultRaw = $this->resultRawFactory->create();
         $resultRaw->setContents($response);
         return $resultRaw;
     }
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:38,代码来源:AddComment.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Data\Collection类代码示例发布时间:2022-05-23
下一篇:
PHP Result\JsonFactory类代码示例发布时间: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