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

PHP Result\JsonFactory类代码示例

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

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



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

示例1: execute

 /**
  * Global Search Action
  *
  * @return \Magento\Framework\Controller\Result\Json
  */
 public function execute()
 {
     $items = [];
     if (!$this->_authorization->isAllowed('Magento_Backend::global_search')) {
         $items[] = ['id' => 'error', 'type' => __('Error'), 'name' => __('Access Denied'), 'description' => __('You need more permissions to do this.')];
     } else {
         if (empty($this->_searchModules)) {
             $items[] = ['id' => 'error', 'type' => __('Error'), 'name' => __('No search modules were registered'), 'description' => __('Please make sure that all global admin search modules are installed and activated.')];
         } else {
             $start = $this->getRequest()->getParam('start', 1);
             $limit = $this->getRequest()->getParam('limit', 10);
             $query = $this->getRequest()->getParam('query', '');
             foreach ($this->_searchModules as $searchConfig) {
                 if ($searchConfig['acl'] && !$this->_authorization->isAllowed($searchConfig['acl'])) {
                     continue;
                 }
                 $className = $searchConfig['class'];
                 if (empty($className)) {
                     continue;
                 }
                 $searchInstance = $this->_objectManager->create($className);
                 $results = $searchInstance->setStart($start)->setLimit($limit)->setQuery($query)->load()->getResults();
                 $items = array_merge_recursive($items, $results);
             }
         }
     }
     /** @var \Magento\Framework\Controller\Result\Json $resultJson */
     $resultJson = $this->resultJsonFactory->create();
     return $resultJson->setData($items);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:35,代码来源:GlobalSearch.php


示例2: 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


示例3: setUp

 protected function setUp()
 {
     $this->productBuilder = $this->getMock('Magento\\Catalog\\Controller\\Adminhtml\\Product\\Builder', ['build'], [], '', false);
     $this->product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['addData', 'getSku', 'getTypeId', 'getStoreId', '__sleep', '__wakeup', 'getAttributes', 'setAttributeSetId'])->getMock();
     $this->product->expects($this->any())->method('getTypeId')->will($this->returnValue('simple'));
     $this->product->expects($this->any())->method('getStoreId')->will($this->returnValue('1'));
     $this->product->expects($this->any())->method('getAttributes')->will($this->returnValue([]));
     $this->productBuilder->expects($this->any())->method('build')->will($this->returnValue($this->product));
     $this->resultPage = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Page')->disableOriginalConstructor()->getMock();
     $resultPageFactory = $this->getMockBuilder('Magento\\Framework\\View\\Result\\PageFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $resultPageFactory->expects($this->any())->method('create')->willReturn($this->resultPage);
     $this->resultForward = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Forward')->disableOriginalConstructor()->getMock();
     $resultForwardFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\ForwardFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $resultForwardFactory->expects($this->any())->method('create')->willReturn($this->resultForward);
     $this->resultPage->expects($this->any())->method('getLayout')->willReturn($this->layout);
     $this->resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', ['create'], [], '', false);
     $this->resultRedirect = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect);
     $this->initializationHelper = $this->getMock('Magento\\Catalog\\Controller\\Adminhtml\\Product\\Initialization\\Helper', [], [], '', false);
     $this->productFactory = $this->getMockBuilder('Magento\\Catalog\\Model\\ProductFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->productFactory->expects($this->any())->method('create')->willReturn($this->product);
     $this->resultJson = $this->getMock('Magento\\Framework\\Controller\\Result\\Json', [], [], '', false);
     $this->resultJsonFactory = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\JsonFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->resultJsonFactory->expects($this->any())->method('create')->willReturn($this->resultJson);
     $additionalParams = ['resultRedirectFactory' => $this->resultRedirectFactory];
     $this->action = (new ObjectManagerHelper($this))->getObject('Magento\\Catalog\\Controller\\Adminhtml\\Product\\Validate', ['context' => $this->initContext($additionalParams), 'productBuilder' => $this->productBuilder, 'resultPageFactory' => $resultPageFactory, 'resultForwardFactory' => $resultForwardFactory, 'initializationHelper' => $this->initializationHelper, 'resultJsonFactory' => $this->resultJsonFactory, 'productFactory' => $this->productFactory]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:27,代码来源:ValidateTest.php


示例4: execute

 /**
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function execute()
 {
     $response = new \Magento\Framework\Object();
     $response->setError(false);
     $attributeCode = $this->getRequest()->getParam('attribute_code');
     $frontendLabel = $this->getRequest()->getParam('frontend_label');
     $attributeCode = $attributeCode ?: $this->generateCode($frontendLabel[0]);
     $attributeId = $this->getRequest()->getParam('attribute_id');
     $attribute = $this->_objectManager->create('Magento\\Catalog\\Model\\Resource\\Eav\\Attribute')->loadByCode($this->_entityTypeId, $attributeCode);
     if ($attribute->getId() && !$attributeId) {
         if (strlen($this->getRequest()->getParam('attribute_code'))) {
             $response->setAttributes(['attribute_code' => __('An attribute with this code already exists.')]);
         } else {
             $response->setAttributes(['attribute_label' => __('Attribute with the same code (%1) already exists.', $attributeCode)]);
         }
         $response->setError(true);
     }
     if ($this->getRequest()->has('new_attribute_set_name')) {
         $setName = $this->getRequest()->getParam('new_attribute_set_name');
         /** @var $attributeSet \Magento\Eav\Model\Entity\Attribute\Set */
         $attributeSet = $this->_objectManager->create('Magento\\Eav\\Model\\Entity\\Attribute\\Set');
         $attributeSet->setEntityTypeId($this->_entityTypeId)->load($setName, 'attribute_set_name');
         if ($attributeSet->getId()) {
             $setName = $this->_objectManager->get('Magento\\Framework\\Escaper')->escapeHtml($setName);
             $this->messageManager->addError(__('Attribute Set with name \'%1\' already exists.', $setName));
             $layout = $this->layoutFactory->create();
             $layout->initMessages();
             $response->setError(true);
             $response->setHtmlMessage($layout->getMessagesBlock()->getGroupedHtml());
         }
     }
     return $this->resultJsonFactory->create()->setJsonData($response->toJson());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:36,代码来源:Validate.php


示例5: aroundExecute

 /**
  * @param \Magento\Customer\Controller\Ajax\Login $subject
  * @param \Closure $proceed
  * @return $this
  * @throws \Zend_Json_Exception
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function aroundExecute(\Magento\Customer\Controller\Ajax\Login $subject, \Closure $proceed)
 {
     $captchaFormIdField = 'captcha_form_id';
     $captchaInputName = 'captcha_string';
     /** @var \Magento\Framework\App\RequestInterface $request */
     $request = $subject->getRequest();
     $loginParams = [];
     $content = $request->getContent();
     if ($content) {
         $loginParams = \Zend_Json::decode($content);
     }
     $username = isset($loginParams['username']) ? $loginParams['username'] : null;
     $captchaString = isset($loginParams[$captchaInputName]) ? $loginParams[$captchaInputName] : null;
     $loginFormId = isset($loginParams[$captchaFormIdField]) ? $loginParams[$captchaFormIdField] : null;
     foreach ($this->formIds as $formId) {
         $captchaModel = $this->helper->getCaptcha($formId);
         if ($captchaModel->isRequired($username) && !in_array($loginFormId, $this->formIds)) {
             $resultJson = $this->resultJsonFactory->create();
             return $resultJson->setData(['errors' => true, 'message' => __('Provided form does not exist')]);
         }
         if ($formId == $loginFormId) {
             $captchaModel->logAttempt($username);
             if (!$captchaModel->isCorrect($captchaString)) {
                 $this->sessionManager->setUsername($username);
                 /** @var \Magento\Framework\Controller\Result\Json $resultJson */
                 $resultJson = $this->resultJsonFactory->create();
                 return $resultJson->setData(['errors' => true, 'message' => __('Incorrect CAPTCHA')]);
             }
         }
     }
     return $proceed();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:40,代码来源:AjaxLogin.php


示例6: executeInternal

 /**
  * Attributes validation action
  *
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function executeInternal()
 {
     $response = $this->_objectManager->create('Magento\\Framework\\DataObject');
     $response->setError(false);
     $attributesData = $this->getRequest()->getParam('attributes', []);
     $data = $this->_objectManager->create('Magento\\Catalog\\Model\\Product');
     try {
         if ($attributesData) {
             foreach ($attributesData as $attributeCode => $value) {
                 $attribute = $this->_objectManager->get('Magento\\Eav\\Model\\Config')->getAttribute('catalog_product', $attributeCode);
                 if (!$attribute->getAttributeId()) {
                     unset($attributesData[$attributeCode]);
                     continue;
                 }
                 $data->setData($attributeCode, $value);
                 $attribute->getBackend()->validate($data);
             }
         }
     } catch (\Magento\Eav\Model\Entity\Attribute\Exception $e) {
         $response->setError(true);
         $response->setAttribute($e->getAttributeCode());
         $response->setMessage($e->getMessage());
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $response->setError(true);
         $response->setMessage($e->getMessage());
     } catch (\Exception $e) {
         $this->messageManager->addException($e, __('Something went wrong while updating the product(s) attributes.'));
         $layout = $this->layoutFactory->create();
         $layout->initMessages();
         $response->setError(true);
         $response->setHtmlMessage($layout->getMessagesBlock()->getGroupedHtml());
     }
     return $this->resultJsonFactory->create()->setJsonData($response->toJson());
 }
开发者ID:nblair,项目名称:magescotch,代码行数:39,代码来源:Validate.php


示例7: setUp

 public function setUp()
 {
     if (!function_exists('libxml_set_external_entity_loader')) {
         $this->markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033');
     }
     $this->customer = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\CustomerInterface', [], '', false, true, true);
     $this->customer->expects($this->once())->method('getWebsiteId')->willReturn(2);
     $this->customerDataFactory = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterfaceFactory', ['create'], [], '', false);
     $this->customerDataFactory->expects($this->once())->method('create')->willReturn($this->customer);
     $this->form = $this->getMock('Magento\\Customer\\Model\\Metadata\\Form', [], [], '', false);
     $this->request = $this->getMockForAbstractClass('Magento\\Framework\\App\\RequestInterface', [], '', false, true, true, ['getPost']);
     $this->response = $this->getMockForAbstractClass('Magento\\Framework\\App\\ResponseInterface', [], '', false);
     $this->formFactory = $this->getMock('Magento\\Customer\\Model\\Metadata\\FormFactory', ['create'], [], '', false);
     $this->formFactory->expects($this->atLeastOnce())->method('create')->willReturn($this->form);
     $this->extensibleDataObjectConverter = $this->getMock('Magento\\Framework\\Api\\ExtensibleDataObjectConverter', [], [], '', false);
     $this->dataObjectHelper = $this->getMock('Magento\\Framework\\Api\\DataObjectHelper', [], [], '', false);
     $this->dataObjectHelper->expects($this->once())->method('populateWithArray');
     $this->customerAccountManagement = $this->getMockForAbstractClass('Magento\\Customer\\Api\\AccountManagementInterface', [], '', false, true, true);
     $this->resultJson = $this->getMock('Magento\\Framework\\Controller\\Result\\Json', [], [], '', false);
     $this->resultJson->expects($this->once())->method('setData');
     $this->resultJsonFactory = $this->getMock('Magento\\Framework\\Controller\\Result\\JsonFactory', ['create'], [], '', false);
     $this->resultJsonFactory->expects($this->once())->method('create')->willReturn($this->resultJson);
     $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->controller = $objectHelper->getObject('Magento\\Customer\\Controller\\Adminhtml\\Index\\Validate', ['request' => $this->request, 'response' => $this->response, 'customerDataFactory' => $this->customerDataFactory, 'formFactory' => $this->formFactory, 'extensibleDataObjectConverter' => $this->extensibleDataObjectConverter, 'customerAccountManagement' => $this->customerAccountManagement, 'resultJsonFactory' => $this->resultJsonFactory, 'dataObjectHelper' => $this->dataObjectHelper]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:ValidateTest.php


示例8: 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


示例9: execute

 /**
  * Add attribute to attribute set
  *
  * @return \Magento\Framework\Controller\Result\Json
  */
 public function execute()
 {
     $request = $this->getRequest();
     $resultJson = $this->resultJsonFactory->create();
     try {
         /** @var \Magento\Eav\Model\Entity\Attribute $attribute */
         $attribute = $this->_objectManager->create('Magento\\Eav\\Model\\Entity\\Attribute')->load($request->getParam('attribute_id'));
         $attributeSet = $this->_objectManager->create('Magento\\Eav\\Model\\Entity\\Attribute\\Set')->load($request->getParam('template_id'));
         /** @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\Collection $attributeGroupCollection */
         $attributeGroupCollection = $this->_objectManager->get('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Group\\Collection');
         $attributeGroupCollection->setAttributeSetFilter($attributeSet->getId());
         $attributeGroupCollection->addFilter('attribute_group_code', $request->getParam('group'));
         $attributeGroupCollection->setPageSize(1);
         $attributeGroup = $attributeGroupCollection->getFirstItem();
         $attribute->setAttributeSetId($attributeSet->getId())->loadEntityAttributeIdBySet();
         $attribute->setAttributeSetId($request->getParam('template_id'))->setAttributeGroupId($attributeGroup->getId())->setSortOrder('0')->save();
         $resultJson->setJsonData($attribute->toJson());
     } catch (\Exception $e) {
         $response = new \Magento\Framework\DataObject();
         $response->setError(false);
         $response->setMessage($e->getMessage());
         $resultJson->setJsonData($response->toJson());
     }
     return $resultJson;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:30,代码来源:AddAttributeToTemplate.php


示例10: execute

 /**
  * Check whether vat is valid
  *
  * @return \Magento\Framework\Controller\Result\Json
  */
 public function execute()
 {
     $result = $this->_validate();
     /** @var \Magento\Framework\Controller\Result\Json $resultJson */
     $resultJson = $this->resultJsonFactory->create();
     return $resultJson->setData(['valid' => (int) $result->getIsValid(), 'message' => $result->getRequestMessage()]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:Validate.php


示例11: 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


示例12: execute

 /**
  * Customer logout action
  *
  * @return \Magento\Framework\Controller\Result\Json
  */
 public function execute()
 {
     $lastCustomerId = $this->customerSession->getId();
     $this->customerSession->logout()->setBeforeAuthUrl($this->_redirect->getRefererUrl())->setLastCustomerId($lastCustomerId);
     /** @var \Magento\Framework\Controller\Result\Json $resultJson */
     $resultJson = $this->resultJsonFactory->create();
     return $resultJson->setData(['message' => 'Logout Successful']);
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:13,代码来源:Logout.php


示例13: execute

 /**
  * AJAX category validation action
  *
  * @return \Magento\Framework\Controller\Result\Json
  */
 public function execute()
 {
     $response = new \Magento\Framework\DataObject();
     $response->setError(0);
     $resultJson = $this->resultJsonFactory->create();
     $resultJson->setData($response);
     return $resultJson;
 }
开发者ID:Zash22,项目名称:magento,代码行数:13,代码来源:Validate.php


示例14: execute

 /**
  * Retrieve synchronize process state and it's parameters in json format
  *
  * @return \Magento\Framework\Controller\Result\Json
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function execute()
 {
     $result = [];
     $flag = $this->_getSyncFlag();
     if ($flag) {
         $state = $flag->getState();
         switch ($state) {
             case \Magento\MediaStorage\Model\File\Storage\Flag::STATE_INACTIVE:
                 $flagData = $flag->getFlagData();
                 if (is_array($flagData)) {
                     if (isset($flagData['destination']) && !empty($flagData['destination'])) {
                         $result['destination'] = $flagData['destination'];
                     }
                 }
                 $state = \Magento\MediaStorage\Model\File\Storage\Flag::STATE_INACTIVE;
                 break;
             case \Magento\MediaStorage\Model\File\Storage\Flag::STATE_RUNNING:
                 if (!$flag->getLastUpdate() || time() <= strtotime($flag->getLastUpdate()) + \Magento\MediaStorage\Model\File\Storage\Flag::FLAG_TTL) {
                     $flagData = $flag->getFlagData();
                     if (is_array($flagData) && isset($flagData['source']) && !empty($flagData['source']) && isset($flagData['destination']) && !empty($flagData['destination'])) {
                         $result['message'] = __('Synchronizing %1 to %2', $flagData['source'], $flagData['destination']);
                     } else {
                         $result['message'] = __('Synchronizing...');
                     }
                     break;
                 } else {
                     $flagData = $flag->getFlagData();
                     if (is_array($flagData) && !(isset($flagData['timeout_reached']) && $flagData['timeout_reached'])) {
                         $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical(new \Magento\Framework\Exception(__('The timeout limit for response from synchronize process was reached.')));
                         $state = \Magento\MediaStorage\Model\File\Storage\Flag::STATE_FINISHED;
                         $flagData['has_errors'] = true;
                         $flagData['timeout_reached'] = true;
                         $flag->setState($state)->setFlagData($flagData)->save();
                     }
                 }
                 // fall-through intentional
             // fall-through intentional
             case \Magento\MediaStorage\Model\File\Storage\Flag::STATE_FINISHED:
             case \Magento\MediaStorage\Model\File\Storage\Flag::STATE_NOTIFIED:
                 $flagData = $flag->getFlagData();
                 if (!isset($flagData['has_errors'])) {
                     $flagData['has_errors'] = false;
                 }
                 $result['has_errors'] = $flagData['has_errors'];
                 break;
             default:
                 $state = \Magento\MediaStorage\Model\File\Storage\Flag::STATE_INACTIVE;
                 break;
         }
     } else {
         $state = \Magento\MediaStorage\Model\File\Storage\Flag::STATE_INACTIVE;
     }
     $result['state'] = $state;
     /** @var \Magento\Framework\Controller\Result\Json $resultJson */
     $resultJson = $this->resultJsonFactory->create();
     return $resultJson->setData($result);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:63,代码来源:Status.php


示例15: executeInternal

 /**
  * Build response for refresh input element 'path' in form
  *
  * @return \Magento\Framework\Controller\Result\Json
  */
 public function executeInternal()
 {
     $categoryId = (int) $this->getRequest()->getParam('id');
     if ($categoryId) {
         $category = $this->_objectManager->create('Magento\\Catalog\\Model\\Category')->load($categoryId);
         /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         return $resultJson->setData(['id' => $categoryId, 'path' => $category->getPath()]);
     }
 }
开发者ID:nblair,项目名称:magescotch,代码行数:15,代码来源:RefreshPath.php


示例16: execute

 /**
  * Build response for refresh input element 'path' in form
  *
  * @return \Magento\Framework\Controller\Result\Json
  */
 public function execute()
 {
     $categoryId = (int) $this->getRequest()->getParam('category_id');
     if ($categoryId) {
         $category = $this->categoryFactory->create()->load($categoryId);
         /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         return $resultJson->setData(['id' => $categoryId, 'path' => $category->getPath()]);
     }
 }
开发者ID:mageplaza,项目名称:magento-2-blog-extension,代码行数:15,代码来源:RefreshPath.php


示例17: 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


示例18: testExecute

 public function testExecute()
 {
     $this->requestMock->expects($this->any())->method('getParam')->willReturnMap([['frontend_label', null, 'test_frontend_label'], ['attribute_code', null, 'test_attribute_code'], ['new_attribute_set_name', null, 'test_attribute_set_name']]);
     $this->objectManagerMock->expects($this->exactly(2))->method('create')->willReturnMap([['Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute', [], $this->attributeMock], ['Magento\\Eav\\Model\\Entity\\Attribute\\Set', [], $this->attributeSetMock]]);
     $this->attributeMock->expects($this->once())->method('loadByCode')->willReturnSelf();
     $this->requestMock->expects($this->once())->method('has')->with('new_attribute_set_name')->willReturn(true);
     $this->attributeSetMock->expects($this->once())->method('setEntityTypeId')->willReturnSelf();
     $this->attributeSetMock->expects($this->once())->method('load')->willReturnSelf();
     $this->attributeSetMock->expects($this->once())->method('getId')->willReturn(false);
     $this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($this->resultJson);
     $this->resultJson->expects($this->once())->method('setJsonData')->willReturnSelf();
     $this->assertInstanceOf(ResultJson::class, $this->getModel()->execute());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:ValidateTest.php


示例19: execute

 /**
  * @return $this
  */
 public function execute()
 {
     $result = $this->_resultJsonFactory->create();
     $productId = $this->getRequest()->getParam('id');
     if (empty($productId)) {
         return $result->setData(['error' => true, 'message' => 'Product ID has not been supplied']);
     }
     $pageViewResult = $this->_productView->processViews($productId);
     if (!$pageViewResult) {
         return $result->setData(['error' => true, 'message' => 'There was an error processing the product view.']);
     }
     return $result->setData(['success' => true, 'message' => 'Product view logged in PredictionIO']);
 }
开发者ID:richdynamix,项目名称:personalised-products,代码行数:16,代码来源:productView.php


示例20: execute

 /**
  * Send request to PayfloPro gateway for get Secure Token
  *
  * @return ResultInterface
  */
 public function execute()
 {
     $this->sessionTransparent->setQuoteId($this->sessionManager->getQuote()->getId());
     $token = $this->secureTokenService->requestToken($this->sessionManager->getQuote());
     $result = [];
     $result[$this->transparent->getCode()]['fields'] = $token->getData();
     $result['success'] = $token->getSecuretoken() ? true : false;
     if (!$result['success']) {
         $result['error'] = true;
         $result['error_messages'] = __('Secure Token Error. Try again.');
     }
     return $this->resultJsonFactory->create()->setData($result);
 }
开发者ID:nja78,项目名称:magento2,代码行数:18,代码来源:RequestSecureToken.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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