SectionConfig.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Block;
  7. /**
  8. * @api
  9. * @since 100.0.2
  10. */
  11. class SectionConfig extends \Magento\Framework\View\Element\Template
  12. {
  13. /**
  14. * @var \Magento\Framework\Config\DataInterface
  15. */
  16. protected $sectionConfig;
  17. /**
  18. * Client side section.
  19. * Sections that do not have server side providers
  20. *
  21. * @var string[]
  22. */
  23. protected $clientSideSections;
  24. /**
  25. * @param \Magento\Framework\View\Element\Template\Context $context
  26. * @param \Magento\Framework\Config\DataInterface $sectionConfig
  27. * @param array $data
  28. * @param string[] $clientSideSections
  29. */
  30. public function __construct(
  31. \Magento\Framework\View\Element\Template\Context $context,
  32. \Magento\Framework\Config\DataInterface $sectionConfig,
  33. array $data = [],
  34. array $clientSideSections = []
  35. ) {
  36. parent::__construct($context, $data);
  37. $this->sectionConfig = $sectionConfig;
  38. $this->clientSideSections = array_values($clientSideSections);
  39. }
  40. /**
  41. * Get list of sections for invalidation
  42. *
  43. * @return array
  44. */
  45. public function getSections()
  46. {
  47. return $this->sectionConfig->get('sections');
  48. }
  49. /**
  50. * Get list of client side sections
  51. * @return string[]
  52. */
  53. public function getClientSideSections()
  54. {
  55. return $this->clientSideSections;
  56. }
  57. }