SectionConfigConverter.php 985 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\CustomerData;
  7. class SectionConfigConverter implements \Magento\Framework\Config\ConverterInterface
  8. {
  9. /**
  10. * Invalidate all sections marker
  11. */
  12. const INVALIDATE_ALL_SECTIONS_MARKER = '*';
  13. /**
  14. * {@inheritdoc}
  15. */
  16. public function convert($source)
  17. {
  18. $sections = [];
  19. foreach ($source->getElementsByTagName('action') as $action) {
  20. $actionName = strtolower($action->getAttribute('name'));
  21. foreach ($action->getElementsByTagName('section') as $section) {
  22. $sections[$actionName][] = strtolower($section->getAttribute('name'));
  23. }
  24. if (!isset($sections[$actionName])) {
  25. $sections[$actionName] = self::INVALIDATE_ALL_SECTIONS_MARKER;
  26. }
  27. }
  28. return [
  29. 'sections' => $sections,
  30. ];
  31. }
  32. }