Wordpress.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved.
  4. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
  5. *
  6. * Glory to Ukraine! Glory to the heroes!
  7. */
  8. namespace Magefan\Blog\Block\Adminhtml\Import;
  9. use Magento\Store\Model\ScopeInterface;
  10. /**
  11. * Wordpress import block
  12. */
  13. class Wordpress extends \Magento\Backend\Block\Widget\Form\Container
  14. {
  15. /**
  16. * Initialize wordpress import block
  17. *
  18. * @return void
  19. */
  20. protected function _construct()
  21. {
  22. $this->_objectId = 'id';
  23. $this->_blockGroup = 'Magefan_Blog';
  24. $this->_controller = 'adminhtml_import';
  25. $this->_mode = 'wordpress';
  26. parent::_construct();
  27. if (!$this->_isAllowedAction('Magefan_Blog::import')) {
  28. $this->buttonList->remove('save');
  29. } else {
  30. $this->updateButton(
  31. 'save', 'label', __('Start Import')
  32. );
  33. }
  34. $this->buttonList->remove('delete');
  35. }
  36. /**
  37. * Check permission for passed action
  38. *
  39. * @param string $resourceId
  40. * @return bool
  41. */
  42. protected function _isAllowedAction($resourceId)
  43. {
  44. return $this->_authorization->isAllowed($resourceId);
  45. }
  46. /**
  47. * Get form save URL
  48. *
  49. * @see getFormActionUrl()
  50. * @return string
  51. */
  52. public function getSaveUrl()
  53. {
  54. return $this->getUrl('*/*/run', ['_current' => true]);
  55. }
  56. }