Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Integration.php
Go to the documentation of this file.
1 <?php
7 
9 use Magento\Integration\Api\OauthServiceInterface as IntegrationOauthService;
10 
16 abstract class Integration extends Action
17 {
23  const ADMIN_RESOURCE = 'Magento_Integration::integrations';
24 
26  const PARAM_INTEGRATION_ID = 'id';
27 
29  const PARAM_REAUTHORIZE = 'reauthorize';
30 
31  const REGISTRY_KEY_CURRENT_INTEGRATION = 'current_integration';
32 
34  const REGISTRY_KEY_CURRENT_RESOURCE = 'current_resource';
35 
39  protected $_registry;
40 
44  protected $_logger;
45 
50 
54  protected $_oauthService;
55 
59  protected $jsonHelper;
60 
64  protected $_integrationData;
65 
70 
74  protected $escaper;
75 
87  public function __construct(
88  \Magento\Backend\App\Action\Context $context,
89  \Magento\Framework\Registry $registry,
90  \Psr\Log\LoggerInterface $logger,
91  \Magento\Integration\Api\IntegrationServiceInterface $integrationService,
92  \Magento\Integration\Api\OauthServiceInterface $oauthService,
93  \Magento\Framework\Json\Helper\Data $jsonHelper,
94  \Magento\Integration\Helper\Data $integrationData,
95  \Magento\Framework\Escaper $escaper,
96  \Magento\Integration\Model\ResourceModel\Integration\Collection $integrationCollection
97  ) {
98  parent::__construct($context);
99  $this->_registry = $registry;
100  $this->_logger = $logger;
101  $this->_integrationService = $integrationService;
102  $this->_oauthService = $oauthService;
103  $this->jsonHelper = $jsonHelper;
104  $this->_integrationData = $integrationData;
105  $this->escaper = $escaper;
106  $this->_integrationCollection = $integrationCollection;
107  parent::__construct($context);
108  }
109 
117  protected function _redirect($path, $arguments = [])
118  {
119  if ($this->getRequest()->isXmlHttpRequest()) {
120  $this->getResponse()->representJson(
121  $this->jsonHelper->jsonEncode(['_redirect' => $this->getUrl($path, $arguments)])
122  );
123  return $this;
124  } else {
125  return parent::_redirect($path, $arguments);
126  }
127  }
128 
134  protected function restoreResourceAndSaveToRegistry()
135  {
136  $restoredFormData = $this->_getSession()->getIntegrationData();
137  if ($restoredFormData) {
138  $resource = isset($restoredFormData['resource']) ? $restoredFormData['resource'] : [];
139  $this->_registry->register(
140  self::REGISTRY_KEY_CURRENT_RESOURCE,
141  ['all_resources' => $restoredFormData['all_resources'], 'resource' => $resource]
142  );
143  }
144  }
145 }
$resource
Definition: bulk.php:12
$logger
__construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $registry, \Psr\Log\LoggerInterface $logger, \Magento\Integration\Api\IntegrationServiceInterface $integrationService, \Magento\Integration\Api\OauthServiceInterface $oauthService, \Magento\Framework\Json\Helper\Data $jsonHelper, \Magento\Integration\Helper\Data $integrationData, \Magento\Framework\Escaper $escaper, \Magento\Integration\Model\ResourceModel\Integration\Collection $integrationCollection)
Definition: Integration.php:87
$arguments