View.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\ProductAlert\Block\Product;
  7. /**
  8. * Product view price and stock alerts
  9. */
  10. class View extends \Magento\Framework\View\Element\Template
  11. {
  12. /**
  13. * @var \Magento\Framework\Registry
  14. */
  15. protected $_registry;
  16. /**
  17. * Helper instance
  18. *
  19. * @var \Magento\ProductAlert\Helper\Data
  20. */
  21. protected $_helper;
  22. /**
  23. * @var \Magento\Framework\Data\Helper\PostHelper
  24. */
  25. protected $coreHelper;
  26. /**
  27. * @param \Magento\Framework\View\Element\Template\Context $context
  28. * @param \Magento\ProductAlert\Helper\Data $helper
  29. * @param \Magento\Framework\Registry $registry
  30. * @param \Magento\Framework\Data\Helper\PostHelper $coreHelper
  31. * @param array $data
  32. */
  33. public function __construct(
  34. \Magento\Framework\View\Element\Template\Context $context,
  35. \Magento\ProductAlert\Helper\Data $helper,
  36. \Magento\Framework\Registry $registry,
  37. \Magento\Framework\Data\Helper\PostHelper $coreHelper,
  38. array $data = []
  39. ) {
  40. parent::__construct($context, $data);
  41. $this->_registry = $registry;
  42. $this->_helper = $helper;
  43. $this->coreHelper = $coreHelper;
  44. }
  45. /**
  46. * Retrieve currently edited product object
  47. *
  48. * @return \Magento\Catalog\Model\Product|boolean
  49. */
  50. protected function getProduct()
  51. {
  52. $product = $this->_registry->registry('current_product');
  53. if ($product && $product->getId()) {
  54. return $product;
  55. }
  56. return false;
  57. }
  58. /**
  59. * Retrieve post action config
  60. *
  61. * @return string
  62. */
  63. public function getPostAction()
  64. {
  65. return $this->coreHelper->getPostData($this->getSignupUrl());
  66. }
  67. }