Images.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Cms\Controller\Adminhtml\Wysiwyg;
  7. /**
  8. * Images manage controller for Cms WYSIWYG editor
  9. *
  10. * @author Magento Core Team <core@magentocommerce.com>
  11. */
  12. abstract class Images extends \Magento\Backend\App\Action
  13. {
  14. /**
  15. * Authorization level of a basic admin session
  16. *
  17. * @see _isAllowed()
  18. */
  19. const ADMIN_RESOURCE = 'Magento_Cms::media_gallery';
  20. /**
  21. * Core registry
  22. *
  23. * @var \Magento\Framework\Registry
  24. */
  25. protected $_coreRegistry = null;
  26. /**
  27. * @param \Magento\Backend\App\Action\Context $context
  28. * @param \Magento\Framework\Registry $coreRegistry
  29. */
  30. public function __construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry)
  31. {
  32. $this->_coreRegistry = $coreRegistry;
  33. parent::__construct($context);
  34. }
  35. /**
  36. * Init storage
  37. *
  38. * @return $this
  39. */
  40. protected function _initAction()
  41. {
  42. $this->getStorage();
  43. return $this;
  44. }
  45. /**
  46. * Register storage model and return it
  47. *
  48. * @return \Magento\Cms\Model\Wysiwyg\Images\Storage
  49. */
  50. public function getStorage()
  51. {
  52. if (!$this->_coreRegistry->registry('storage')) {
  53. $storage = $this->_objectManager->create(\Magento\Cms\Model\Wysiwyg\Images\Storage::class);
  54. $this->_coreRegistry->register('storage', $storage);
  55. }
  56. return $this->_coreRegistry->registry('storage');
  57. }
  58. }