Converter.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Page layout Config Converter
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Theme\Model\Layout\Config;
  9. class Converter implements \Magento\Framework\Config\ConverterInterface
  10. {
  11. /**
  12. * {@inheritdoc}
  13. */
  14. public function convert($source)
  15. {
  16. $pageLayouts = [];
  17. $xpath = new \DOMXPath($source);
  18. /** @var $layout DOMNode */
  19. foreach ($xpath->query('/page_layouts/layout') as $layout) {
  20. $layoutAttributes = $layout->attributes;
  21. $id = $layoutAttributes->getNamedItem('id')->nodeValue;
  22. $pageLayouts[$id]['code'] = $id;
  23. /** @var $layoutSubNode DOMNode */
  24. foreach ($layout->childNodes as $layoutSubNode) {
  25. switch ($layoutSubNode->nodeName) {
  26. case 'label':
  27. $pageLayouts[$id][$layoutSubNode->nodeName] = $layoutSubNode->nodeValue;
  28. break;
  29. default:
  30. break;
  31. }
  32. }
  33. }
  34. return $pageLayouts;
  35. }
  36. }