StepsWizard.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Ui\Block\Component;
  7. /**
  8. * Multi steps wizard block
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class StepsWizard extends \Magento\Framework\View\Element\Template
  14. {
  15. /**
  16. * Wizard step template
  17. *
  18. * @var string
  19. */
  20. protected $_template = 'Magento_Ui::stepswizard.phtml';
  21. /**
  22. * @var array
  23. */
  24. protected $initData = [];
  25. /**
  26. * @var null|\Magento\Ui\Block\Component\StepsWizard\StepInterface[]
  27. */
  28. private $steps;
  29. /**
  30. * @return \Magento\Ui\Block\Component\StepsWizard\StepInterface[]
  31. */
  32. public function getSteps()
  33. {
  34. if ($this->steps === null) {
  35. foreach ($this->getLayout()->getChildBlocks($this->getNameInLayout()) as $step) {
  36. if ($step instanceof StepsWizard\StepInterface) {
  37. $this->steps[$step->getComponentName()] = $step;
  38. }
  39. }
  40. }
  41. return $this->steps;
  42. }
  43. // @codeCoverageIgnoreStart
  44. /**
  45. * @return array
  46. */
  47. public function getStepComponents()
  48. {
  49. return array_keys($this->getSteps());
  50. }
  51. /**
  52. * @return string
  53. */
  54. public function getComponentName()
  55. {
  56. return $this->getNameInLayout();
  57. }
  58. /**
  59. * @return array
  60. */
  61. public function getInitData()
  62. {
  63. return $this->initData;
  64. }
  65. /**
  66. * @param array $initData
  67. * @return $this
  68. */
  69. public function setInitData($initData)
  70. {
  71. $this->initData = $initData;
  72. return $this;
  73. }
  74. }