src/Form/Registration/RegistrationFormFlow.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Form\Registration;
  3. use Craue\FormFlowBundle\Form\FormFlow;
  4. use Symfony\Component\Form\FormInterface;
  5. use Craue\FormFlowBundle\Form\FormFlowInterface;
  6. class RegistrationFormFlow extends FormFlow
  7. {
  8. protected $allowDynamicStepNavigation = true;
  9. protected function loadStepsConfig(): array
  10. {
  11. return [
  12. [
  13. 'label' => 'Personal Info',
  14. 'form_type' => RegistrationBaseFormType::class,
  15. 'form_options' => [
  16. 'validation_groups' => function (FormInterface $form) {
  17. $data = $form->getData();
  18. if ($data->getCountry() == 'CA') {
  19. return ['Default', 'CA'];
  20. }
  21. return ['Default', 'US'];
  22. },
  23. ],
  24. ],
  25. [
  26. 'label' => 'Brand Info',
  27. 'form_type' => BrandInfoFormType::class,
  28. 'form_options' => [
  29. 'validation_groups' => ['Default'],
  30. ],
  31. 'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
  32. $user = $flow->getFormData();
  33. return $user->getId() !== null;
  34. },
  35. ],
  36. [
  37. 'label' => 'Retailer Info',
  38. 'form_type' => AddRetailerFormType::class,
  39. 'form_options' => [
  40. 'validation_groups' => ['Default'],
  41. ],
  42. 'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
  43. $user = $flow->getFormData();
  44. // Skip if user already has retailers (added after merging)
  45. if ($user->getUserRetailers()->count() > 0) {
  46. return true;
  47. }
  48. return false;
  49. // Skip for MK or Revelation brands
  50. # return $estimatedCurrentStepNumber > 2 && ($flow->getFormData()->brand && ($flow->getFormData()->brand->isMk() || $flow->getFormData()->brand->isRevelation()));
  51. # return !$user->getStoreId() && !$user->brand;
  52. },
  53. ],
  54. /*[
  55. 'label' => 'Invitation Code',
  56. 'form_type' => AddInvitationCodeFormType::class,
  57. 'form_options' => [
  58. 'validation_groups' => ['Default'],
  59. ],
  60. 'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
  61. $user = $flow->getFormData();
  62. return !$user->brand OR (!$flow->getFormData()->brand->isMk() AND !$flow->getFormData()->brand->isRevelation());
  63. return $user->getId() !== null || ($user->brand AND !$user->brand->isMk() AND !$user->brand->isRevelation());
  64. },
  65. ],*/
  66. [
  67. 'label' => 'Supplier Info',
  68. 'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
  69. $user = $flow->getFormData();
  70. return $user->getId() !== null;
  71. },
  72. ],
  73. [
  74. 'label' => 'Jewelry Rewards Program',
  75. 'form_type' => OptInFormType::class,
  76. 'form_options' => [
  77. 'validation_groups' => function($form){
  78. if($form->getData()->isOptOut()){
  79. return ['Default'];
  80. }
  81. return ['Default', 'OPT_IN'];
  82. },
  83. ],
  84. 'skip' => true
  85. ],
  86. [
  87. 'label' => 'Tax Info (US)',
  88. 'form_type' => W9FormType::class,
  89. 'form_options' => [
  90. 'validation_groups' => function($form){
  91. if($form->getData()->isOptOut()){
  92. return ['Default'];
  93. }
  94. return ['Default', 'OPT_IN'];
  95. },
  96. ],
  97. 'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
  98. return $flow->getFormData()->isOptOut() || $flow->getFormData()->getCountry() === 'CA';
  99. },
  100. ],
  101. [
  102. 'label' => 'Tax Info (Canada)',
  103. 'form_type' => W8FormType::class,
  104. 'form_options' => [
  105. 'validation_groups' => function($form){
  106. if($form->getData()->isOptOut()){
  107. return ['Default'];
  108. }
  109. return ['Default', 'OPT_IN'];
  110. },
  111. ],
  112. 'skip' => function($estimatedCurrentStepNumber, FormFlowInterface $flow) {
  113. return $flow->getFormData()->isOptOut() || $flow->getFormData()->getCountry() !== 'CA';
  114. },
  115. ],
  116. [
  117. 'label' => 'Terms & Conditions',
  118. 'form_type' => RegistrationTermsFormType::class,
  119. 'form_options' => [
  120. 'validation_groups' => ['Default'],
  121. ],
  122. ],
  123. [
  124. 'label' => 'Review and Register Below',
  125. ],
  126. ];
  127. }
  128. }