Footer.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Theme\Block\Html;
  7. use Magento\Customer\Model\Context;
  8. /**
  9. * Html page footer block
  10. *
  11. * @api
  12. * @since 100.0.2
  13. */
  14. class Footer extends \Magento\Framework\View\Element\Template implements \Magento\Framework\DataObject\IdentityInterface
  15. {
  16. /**
  17. * Copyright information
  18. *
  19. * @var string
  20. */
  21. protected $_copyright;
  22. /**
  23. * Miscellaneous HTML information
  24. *
  25. * @var string
  26. */
  27. private $miscellaneousHtml;
  28. /**
  29. * @var \Magento\Framework\App\Http\Context
  30. */
  31. protected $httpContext;
  32. /**
  33. * @param \Magento\Framework\View\Element\Template\Context $context
  34. * @param \Magento\Framework\App\Http\Context $httpContext
  35. * @param array $data
  36. */
  37. public function __construct(
  38. \Magento\Framework\View\Element\Template\Context $context,
  39. \Magento\Framework\App\Http\Context $httpContext,
  40. array $data = []
  41. ) {
  42. $this->httpContext = $httpContext;
  43. parent::__construct($context, $data);
  44. }
  45. /**
  46. * Set footer data
  47. *
  48. * @return void
  49. */
  50. protected function _construct()
  51. {
  52. $this->addData(
  53. [
  54. 'cache_tags' => [\Magento\Store\Model\Store::CACHE_TAG, \Magento\Cms\Model\Block::CACHE_TAG],
  55. ]
  56. );
  57. }
  58. /**
  59. * Get cache key informative items
  60. *
  61. * @return array
  62. */
  63. public function getCacheKeyInfo()
  64. {
  65. return [
  66. 'PAGE_FOOTER',
  67. $this->_storeManager->getStore()->getId(),
  68. (int)$this->_storeManager->getStore()->isCurrentlySecure(),
  69. $this->_design->getDesignTheme()->getId(),
  70. $this->httpContext->getValue(Context::CONTEXT_AUTH),
  71. $this->getTemplateFile(),
  72. 'template' => $this->getTemplate()
  73. ];
  74. }
  75. /**
  76. * Retrieve copyright information
  77. *
  78. * @return string
  79. */
  80. public function getCopyright()
  81. {
  82. if (!$this->_copyright) {
  83. $this->_copyright = $this->_scopeConfig->getValue(
  84. 'design/footer/copyright',
  85. \Magento\Store\Model\ScopeInterface::SCOPE_STORE
  86. );
  87. }
  88. return __($this->_copyright);
  89. }
  90. /**
  91. * Retrieve Miscellaneous HTML information
  92. *
  93. * @return string
  94. * @since 100.1.0
  95. */
  96. public function getMiscellaneousHtml()
  97. {
  98. if ($this->miscellaneousHtml === null) {
  99. $this->miscellaneousHtml = $this->_scopeConfig->getValue(
  100. 'design/footer/absolute_footer',
  101. \Magento\Store\Model\ScopeInterface::SCOPE_STORE
  102. );
  103. }
  104. return $this->miscellaneousHtml;
  105. }
  106. /**
  107. * Return identifiers for produced content
  108. *
  109. * @return array
  110. */
  111. public function getIdentities()
  112. {
  113. return [\Magento\Store\Model\Store::CACHE_TAG, \Magento\Cms\Model\Block::CACHE_TAG];
  114. }
  115. /**
  116. * Get block cache life time
  117. *
  118. * @return int
  119. * @since 100.2.4
  120. */
  121. protected function getCacheLifetime()
  122. {
  123. return parent::getCacheLifetime() ?: 3600;
  124. }
  125. }