Logo.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * PayPal online logo with additional options
  8. */
  9. namespace Magento\Paypal\Block;
  10. /**
  11. * @api
  12. * @since 100.0.2
  13. */
  14. class Logo extends \Magento\Framework\View\Element\Template
  15. {
  16. /**
  17. * @var \Magento\Paypal\Model\Config
  18. */
  19. protected $_paypalConfig;
  20. /**
  21. * @var \Magento\Framework\Locale\ResolverInterface
  22. */
  23. protected $_localeResolver;
  24. /**
  25. * @param \Magento\Framework\View\Element\Template\Context $context
  26. * @param \Magento\Paypal\Model\Config $paypalConfig
  27. * @param \Magento\Framework\Locale\ResolverInterface $localeResolver
  28. * @param array $data
  29. */
  30. public function __construct(
  31. \Magento\Framework\View\Element\Template\Context $context,
  32. \Magento\Paypal\Model\Config $paypalConfig,
  33. \Magento\Framework\Locale\ResolverInterface $localeResolver,
  34. array $data = []
  35. ) {
  36. $this->_paypalConfig = $paypalConfig;
  37. $this->_localeResolver = $localeResolver;
  38. parent::__construct($context, $data);
  39. }
  40. /**
  41. * Return URL for Paypal Landing page
  42. *
  43. * @return string
  44. */
  45. public function getAboutPaypalPageUrl()
  46. {
  47. return $this->_getConfig()->getPaymentMarkWhatIsPaypalUrl($this->_localeResolver);
  48. }
  49. /**
  50. * Getter for paypal config
  51. *
  52. * @return \Magento\Paypal\Model\Config
  53. */
  54. protected function _getConfig()
  55. {
  56. return $this->_paypalConfig;
  57. }
  58. /**
  59. * Disable block output if logo turned off
  60. *
  61. * @return string
  62. */
  63. protected function _toHtml()
  64. {
  65. $type = $this->getLogoType();
  66. // assigned in layout etc.
  67. $logoUrl = $this->_getConfig()->getAdditionalOptionsLogoUrl($this->_localeResolver->getLocale(), $type);
  68. if (!$logoUrl) {
  69. return '';
  70. }
  71. $this->setLogoImageUrl($logoUrl);
  72. return parent::_toHtml();
  73. }
  74. }