PermissionsDialog.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Integration\Controller\Adminhtml\Integration;
  8. use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
  9. use Magento\Framework\Exception\IntegrationException;
  10. class PermissionsDialog extends \Magento\Integration\Controller\Adminhtml\Integration implements HttpGetActionInterface
  11. {
  12. /**
  13. * Show permissions popup.
  14. *
  15. * @return void
  16. */
  17. public function execute()
  18. {
  19. $integrationId = (int)$this->getRequest()->getParam(self::PARAM_INTEGRATION_ID);
  20. if ($integrationId) {
  21. try {
  22. $integrationData = $this->_integrationService->get($integrationId)->getData();
  23. $this->_registry->register(self::REGISTRY_KEY_CURRENT_INTEGRATION, $integrationData);
  24. } catch (IntegrationException $e) {
  25. $this->messageManager->addError($e->getMessage());
  26. $this->_redirect('*/*/');
  27. return;
  28. } catch (\Exception $e) {
  29. $this->_logger->critical($e);
  30. $this->messageManager->addError(__('Internal error. Check exception log for details.'));
  31. $this->_redirect('*/*');
  32. return;
  33. }
  34. } else {
  35. $this->messageManager->addError(__('Integration ID is not specified or is invalid.'));
  36. $this->_redirect('*/*/');
  37. return;
  38. }
  39. /** Add handles of the tabs which are defined in other modules */
  40. $handleNodes = $this->_view->getLayout()->getUpdate()->getFileLayoutUpdatesXml()->xpath(
  41. '//referenceBlock[@name="integration.activate.permissions.tabs"]/../@id'
  42. );
  43. $handles = [];
  44. if (is_array($handleNodes)) {
  45. foreach ($handleNodes as $node) {
  46. $handles[] = (string)$node;
  47. }
  48. }
  49. $this->_view->loadLayout($handles);
  50. $this->_view->renderLayout();
  51. }
  52. }