Index.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Dotdigitalgroup\Email\Controller\Adminhtml\Studio;
  3. class Index extends \Magento\Backend\App\AbstractAction
  4. {
  5. /**
  6. * Authorization level of a basic admin session
  7. *
  8. * @see _isAllowed()
  9. */
  10. const ADMIN_RESOURCE = 'Dotdigitalgroup_Email::studio';
  11. /**
  12. * Execute method.
  13. */
  14. public function execute()
  15. {
  16. //not connected - redirect to connect settings page
  17. $adminUser = $this->_auth->getUser();
  18. $refreshToken = $adminUser->getRefreshToken();
  19. if (! $refreshToken) {
  20. $resultRedirect = $this->resultRedirectFactory->create();
  21. $this->messageManager->addNoticeMessage('Please enter OAUTH creds and click Connect.');
  22. //Redirect to developer section config
  23. $resultRedirect->setPath('adminhtml/system_config/edit', ['section' => 'connector_developer_settings']);
  24. return $resultRedirect;
  25. }
  26. //Load and render layout if there is $refreshToken
  27. $this->_view->loadLayout();
  28. $this->_view->renderLayout();
  29. }
  30. }