Completed
Branch FET/reg-form-v2 (f85ea5)
by
unknown
15:55 queued 12:55
created
core/domain/services/registration/form/v2/RegistrantForm.php 2 patches
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -15,105 +15,105 @@
 block discarded – undo
15 15
 class RegistrantForm extends BaseRegistrantForm
16 16
 {
17 17
 
18
-    /**
19
-     * @var EEM_Form_Element
20
-     */
21
-    protected $form_input_model;
18
+	/**
19
+	 * @var EEM_Form_Element
20
+	 */
21
+	protected $form_input_model;
22 22
 
23
-    /**
24
-     * @var EEM_Form_Section
25
-     */
26
-    public $form_section_model;
23
+	/**
24
+	 * @var EEM_Form_Section
25
+	 */
26
+	public $form_section_model;
27 27
 
28
-    /**
29
-     * @var RegistrantFormInput
30
-     */
31
-    public $reg_form_input_factory;
28
+	/**
29
+	 * @var RegistrantFormInput
30
+	 */
31
+	public $reg_form_input_factory;
32 32
 
33 33
 
34
-    /**
35
-     * RegistrantForm constructor.
36
-     *
37
-     * @param EE_Registration     $registration
38
-     * @param bool                $admin_request
39
-     * @param bool                $copy_attendee_info
40
-     * @param callable            $enablePrintCopyInfo
41
-     * @param RegistrantFormInput $reg_form_input_factory
42
-     * @param EEM_Form_Element    $form_input_model
43
-     * @param EEM_Form_Section    $form_section_model
44
-     * @throws EE_Error
45
-     * @throws ReflectionException
46
-     */
47
-    public function __construct(
48
-        EE_Registration $registration,
49
-        bool $admin_request,
50
-        bool $copy_attendee_info,
51
-        callable $enablePrintCopyInfo,
52
-        RegistrantFormInput $reg_form_input_factory,
53
-        EEM_Form_Element $form_input_model,
54
-        EEM_Form_Section $form_section_model
55
-    ) {
56
-        $this->reg_form_input_factory = $reg_form_input_factory;
57
-        $this->form_input_model       = $form_input_model;
58
-        $this->form_section_model     = $form_section_model;
59
-        parent::__construct(
60
-            $this->generateFormArgs($registration, $admin_request, $copy_attendee_info, $enablePrintCopyInfo)
61
-        );
62
-    }
34
+	/**
35
+	 * RegistrantForm constructor.
36
+	 *
37
+	 * @param EE_Registration     $registration
38
+	 * @param bool                $admin_request
39
+	 * @param bool                $copy_attendee_info
40
+	 * @param callable            $enablePrintCopyInfo
41
+	 * @param RegistrantFormInput $reg_form_input_factory
42
+	 * @param EEM_Form_Element    $form_input_model
43
+	 * @param EEM_Form_Section    $form_section_model
44
+	 * @throws EE_Error
45
+	 * @throws ReflectionException
46
+	 */
47
+	public function __construct(
48
+		EE_Registration $registration,
49
+		bool $admin_request,
50
+		bool $copy_attendee_info,
51
+		callable $enablePrintCopyInfo,
52
+		RegistrantFormInput $reg_form_input_factory,
53
+		EEM_Form_Element $form_input_model,
54
+		EEM_Form_Section $form_section_model
55
+	) {
56
+		$this->reg_form_input_factory = $reg_form_input_factory;
57
+		$this->form_input_model       = $form_input_model;
58
+		$this->form_section_model     = $form_section_model;
59
+		parent::__construct(
60
+			$this->generateFormArgs($registration, $admin_request, $copy_attendee_info, $enablePrintCopyInfo)
61
+		);
62
+	}
63 63
 
64 64
 
65
-    /**
66
-     * @param EE_Registration $registration
67
-     * @param bool            $admin_request
68
-     * @param bool            $copy_attendee_info
69
-     * @param callable        $enablePrintCopyInfo
70
-     * @return array
71
-     * @throws EE_Error
72
-     * @throws ReflectionException
73
-     */
74
-    private function generateFormArgs(
75
-        EE_Registration $registration,
76
-        bool $admin_request,
77
-        bool $copy_attendee_info,
78
-        callable $enablePrintCopyInfo
79
-    ): array {
80
-        static $attendee_nmbr = 1;
81
-        $this->form_args = [];
82
-        // verify that registration has valid event
83
-        if ($registration->event() instanceof EE_Event) {
84
-            $form_sections = $this->form_section_model->getFormSectionsForEvent($registration->event());
85
-            if ($form_sections) {
86
-                $all_form_inputs = $this->form_input_model->getAllFormElementsForFormSections($form_sections);
87
-                // array of params to pass to parent constructor
88
-                $this->form_args = $this->generateTopLevelFormArgs($registration, $admin_request, $attendee_nmbr);
89
-                foreach ($form_sections as $form_section) {
90
-                    if ($form_section instanceof EE_Form_Section) {
91
-                        // \EEH_Debug_Tools::printr($form_section->slug(), '$form_section->slug()', __FILE__, __LINE__);
92
-                        $form_inputs = $form_section->filterFormElements($all_form_inputs);
93
-                        if (empty($form_inputs)) {
94
-                            continue;
95
-                        }
96
-                        $form_section->setFormElements($form_inputs);
97
-                        $registrant_form_section                                 = LoaderFactory::getNew(
98
-                            RegistrantFormSection::class,
99
-                            [$registration, $form_section, $admin_request, $this->reg_form_input_factory]
100
-                        );
101
-                        $this->form_args['subsections'][ $form_section->slug() ] = apply_filters(
102
-                            'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
103
-                            $registrant_form_section,
104
-                            $registration,
105
-                            $form_section,
106
-                            $this
107
-                        );
108
-                    }
109
-                }
110
-                $this->addAdditionalAttendeeRegInfoInput($registration);
111
-                $this->enablePrintCopyInfo($attendee_nmbr, $copy_attendee_info, $enablePrintCopyInfo);
112
-                $this->addAdditionalPrimaryRegistrantInputs($registration);
113
-            }
114
-        }
115
-        $attendee_nmbr++;
116
-        $this->setHasQuestions();
117
-        return $this->form_args;
118
-    }
65
+	/**
66
+	 * @param EE_Registration $registration
67
+	 * @param bool            $admin_request
68
+	 * @param bool            $copy_attendee_info
69
+	 * @param callable        $enablePrintCopyInfo
70
+	 * @return array
71
+	 * @throws EE_Error
72
+	 * @throws ReflectionException
73
+	 */
74
+	private function generateFormArgs(
75
+		EE_Registration $registration,
76
+		bool $admin_request,
77
+		bool $copy_attendee_info,
78
+		callable $enablePrintCopyInfo
79
+	): array {
80
+		static $attendee_nmbr = 1;
81
+		$this->form_args = [];
82
+		// verify that registration has valid event
83
+		if ($registration->event() instanceof EE_Event) {
84
+			$form_sections = $this->form_section_model->getFormSectionsForEvent($registration->event());
85
+			if ($form_sections) {
86
+				$all_form_inputs = $this->form_input_model->getAllFormElementsForFormSections($form_sections);
87
+				// array of params to pass to parent constructor
88
+				$this->form_args = $this->generateTopLevelFormArgs($registration, $admin_request, $attendee_nmbr);
89
+				foreach ($form_sections as $form_section) {
90
+					if ($form_section instanceof EE_Form_Section) {
91
+						// \EEH_Debug_Tools::printr($form_section->slug(), '$form_section->slug()', __FILE__, __LINE__);
92
+						$form_inputs = $form_section->filterFormElements($all_form_inputs);
93
+						if (empty($form_inputs)) {
94
+							continue;
95
+						}
96
+						$form_section->setFormElements($form_inputs);
97
+						$registrant_form_section                                 = LoaderFactory::getNew(
98
+							RegistrantFormSection::class,
99
+							[$registration, $form_section, $admin_request, $this->reg_form_input_factory]
100
+						);
101
+						$this->form_args['subsections'][ $form_section->slug() ] = apply_filters(
102
+							'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
103
+							$registrant_form_section,
104
+							$registration,
105
+							$form_section,
106
+							$this
107
+						);
108
+					}
109
+				}
110
+				$this->addAdditionalAttendeeRegInfoInput($registration);
111
+				$this->enablePrintCopyInfo($attendee_nmbr, $copy_attendee_info, $enablePrintCopyInfo);
112
+				$this->addAdditionalPrimaryRegistrantInputs($registration);
113
+			}
114
+		}
115
+		$attendee_nmbr++;
116
+		$this->setHasQuestions();
117
+		return $this->form_args;
118
+	}
119 119
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -94,11 +94,11 @@
 block discarded – undo
94 94
                             continue;
95 95
                         }
96 96
                         $form_section->setFormElements($form_inputs);
97
-                        $registrant_form_section                                 = LoaderFactory::getNew(
97
+                        $registrant_form_section = LoaderFactory::getNew(
98 98
                             RegistrantFormSection::class,
99 99
                             [$registration, $form_section, $admin_request, $this->reg_form_input_factory]
100 100
                         );
101
-                        $this->form_args['subsections'][ $form_section->slug() ] = apply_filters(
101
+                        $this->form_args['subsections'][$form_section->slug()] = apply_filters(
102 102
                             'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
103 103
                             $registrant_form_section,
104 104
                             $registration,
Please login to merge, or discard this patch.
core/domain/services/registration/form/v2/FieldLengthCalculator.php 2 patches
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -17,103 +17,103 @@
 block discarded – undo
17 17
 class FieldLengthCalculator
18 18
 {
19 19
 
20
-    /**
21
-     * @var array
22
-     */
23
-    private $max_field_lengths
24
-        = [
25
-            'Attendee.fname'         => 45,
26
-            'Attendee.lname'         => 45,
27
-            'Attendee.email'         => 255,
28
-            'Attendee.email_confirm' => 255,
29
-            'Attendee.address'       => 255,
30
-            'Attendee.address2'      => 255,
31
-            'Attendee.city'          => 45,
32
-            'Attendee.zip'           => 12,
33
-            'Attendee.phone'         => 45,
34
-        ];
35
-
36
-    /**
37
-     * @var array
38
-     */
39
-    private $min_field_lengths
40
-        = [
41
-            'Attendee.fname'         => 2,
42
-            'Attendee.lname'         => 2,
43
-            'Attendee.email'         => 8,
44
-            'Attendee.email_confirm' => 8,
45
-            'Attendee.zip'           => 4,
46
-            'Attendee.phone'         => 4,
47
-        ];
48
-
49
-
50
-    /**
51
-     * Returns an array where keys are Model + Field names in dot notation; ex: Attendee.email,
52
-     * and values are the highest question max the admin can set on the question
53
-     * (aka the "max max"; eg, a site admin can change the zip question to have a max
54
-     * of 5, but no larger than 12)
55
-     *
56
-     * @return array
57
-     */
58
-    public function maxFieldLengths(): array
59
-    {
60
-        return $this->max_field_lengths;
61
-    }
62
-
63
-
64
-    /**
65
-     * @return array
66
-     */
67
-    public function minFieldLengths(): array
68
-    {
69
-        return $this->min_field_lengths;
70
-    }
71
-
72
-
73
-    /**
74
-     * @param string|null $model_field_name
75
-     * @return int|float
76
-     */
77
-    public function getMaxFieldLength(?string $model_field_name)
78
-    {
79
-        return $this->max_field_lengths[ $model_field_name ] ?? EE_INF;
80
-    }
81
-
82
-
83
-    /**
84
-     * @param string|null $model_field_name
85
-     * @return int|float
86
-     */
87
-    public function getMinFieldLength(?string $model_field_name)
88
-    {
89
-        return $this->min_field_lengths[ $model_field_name ] ?? 0;
90
-    }
91
-
92
-
93
-    /**
94
-     * @param EE_Form_Element $form_input
95
-     * @return int|float
96
-     * @throws EE_Error
97
-     * @throws ReflectionException
98
-     */
99
-    public function getMaxFieldLengthForInput(EE_Form_Element $form_input)
100
-    {
101
-        $max_field_length = $this->getMaxFieldLength($form_input->mapsTo());
102
-        $max_input_length = $form_input->getAttribute('max') ?: EE_INF;
103
-        return min($max_field_length, $max_input_length);
104
-    }
105
-
106
-
107
-    /**
108
-     * @param EE_Form_Element $form_input
109
-     * @return int|float
110
-     * @throws EE_Error
111
-     * @throws ReflectionException
112
-     */
113
-    public function getMinFieldLengthForInput(EE_Form_Element $form_input)
114
-    {
115
-        $min_field_length = $this->getMinFieldLength($form_input->mapsTo());
116
-        $min_input_length = $form_input->getAttribute('min') ?: 0;
117
-        return max($min_field_length, $min_input_length);
118
-    }
20
+	/**
21
+	 * @var array
22
+	 */
23
+	private $max_field_lengths
24
+		= [
25
+			'Attendee.fname'         => 45,
26
+			'Attendee.lname'         => 45,
27
+			'Attendee.email'         => 255,
28
+			'Attendee.email_confirm' => 255,
29
+			'Attendee.address'       => 255,
30
+			'Attendee.address2'      => 255,
31
+			'Attendee.city'          => 45,
32
+			'Attendee.zip'           => 12,
33
+			'Attendee.phone'         => 45,
34
+		];
35
+
36
+	/**
37
+	 * @var array
38
+	 */
39
+	private $min_field_lengths
40
+		= [
41
+			'Attendee.fname'         => 2,
42
+			'Attendee.lname'         => 2,
43
+			'Attendee.email'         => 8,
44
+			'Attendee.email_confirm' => 8,
45
+			'Attendee.zip'           => 4,
46
+			'Attendee.phone'         => 4,
47
+		];
48
+
49
+
50
+	/**
51
+	 * Returns an array where keys are Model + Field names in dot notation; ex: Attendee.email,
52
+	 * and values are the highest question max the admin can set on the question
53
+	 * (aka the "max max"; eg, a site admin can change the zip question to have a max
54
+	 * of 5, but no larger than 12)
55
+	 *
56
+	 * @return array
57
+	 */
58
+	public function maxFieldLengths(): array
59
+	{
60
+		return $this->max_field_lengths;
61
+	}
62
+
63
+
64
+	/**
65
+	 * @return array
66
+	 */
67
+	public function minFieldLengths(): array
68
+	{
69
+		return $this->min_field_lengths;
70
+	}
71
+
72
+
73
+	/**
74
+	 * @param string|null $model_field_name
75
+	 * @return int|float
76
+	 */
77
+	public function getMaxFieldLength(?string $model_field_name)
78
+	{
79
+		return $this->max_field_lengths[ $model_field_name ] ?? EE_INF;
80
+	}
81
+
82
+
83
+	/**
84
+	 * @param string|null $model_field_name
85
+	 * @return int|float
86
+	 */
87
+	public function getMinFieldLength(?string $model_field_name)
88
+	{
89
+		return $this->min_field_lengths[ $model_field_name ] ?? 0;
90
+	}
91
+
92
+
93
+	/**
94
+	 * @param EE_Form_Element $form_input
95
+	 * @return int|float
96
+	 * @throws EE_Error
97
+	 * @throws ReflectionException
98
+	 */
99
+	public function getMaxFieldLengthForInput(EE_Form_Element $form_input)
100
+	{
101
+		$max_field_length = $this->getMaxFieldLength($form_input->mapsTo());
102
+		$max_input_length = $form_input->getAttribute('max') ?: EE_INF;
103
+		return min($max_field_length, $max_input_length);
104
+	}
105
+
106
+
107
+	/**
108
+	 * @param EE_Form_Element $form_input
109
+	 * @return int|float
110
+	 * @throws EE_Error
111
+	 * @throws ReflectionException
112
+	 */
113
+	public function getMinFieldLengthForInput(EE_Form_Element $form_input)
114
+	{
115
+		$min_field_length = $this->getMinFieldLength($form_input->mapsTo());
116
+		$min_input_length = $form_input->getAttribute('min') ?: 0;
117
+		return max($min_field_length, $min_input_length);
118
+	}
119 119
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      */
77 77
     public function getMaxFieldLength(?string $model_field_name)
78 78
     {
79
-        return $this->max_field_lengths[ $model_field_name ] ?? EE_INF;
79
+        return $this->max_field_lengths[$model_field_name] ?? EE_INF;
80 80
     }
81 81
 
82 82
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public function getMinFieldLength(?string $model_field_name)
88 88
     {
89
-        return $this->min_field_lengths[ $model_field_name ] ?? 0;
89
+        return $this->min_field_lengths[$model_field_name] ?? 0;
90 90
     }
91 91
 
92 92
 
Please login to merge, or discard this patch.
core/domain/services/registration/form/v2/SystemInputFieldNames.php 2 patches
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -14,106 +14,106 @@
 block discarded – undo
14 14
 class SystemInputFieldNames implements SystemInputFieldNamesInterface
15 15
 {
16 16
 
17
-    /**
18
-     * ATTENDEE_FIELD_* constants are a 'balanced ternary' to simultaneously represent
19
-     * whether the requested field is a property and whether or not it has been set:
20
-     *
21
-     *  ATTENDEE_FIELD_SET (1)      indicates that the field IS an attendee field AND has been set
22
-     *  ATTENDEE_FIELD_NOT_SET (0)  indicates that the field IS an attendee field but has not yet been set
23
-     *  ATTENDEE_FIELD_UNKNOWN (-1) indicates that the field is NOT a known attendee field
24
-     */
25
-    const ATTENDEE_FIELD_SET     = 1;
17
+	/**
18
+	 * ATTENDEE_FIELD_* constants are a 'balanced ternary' to simultaneously represent
19
+	 * whether the requested field is a property and whether or not it has been set:
20
+	 *
21
+	 *  ATTENDEE_FIELD_SET (1)      indicates that the field IS an attendee field AND has been set
22
+	 *  ATTENDEE_FIELD_NOT_SET (0)  indicates that the field IS an attendee field but has not yet been set
23
+	 *  ATTENDEE_FIELD_UNKNOWN (-1) indicates that the field is NOT a known attendee field
24
+	 */
25
+	const ATTENDEE_FIELD_SET     = 1;
26 26
 
27
-    const ATTENDEE_FIELD_NOT_SET = 0;
27
+	const ATTENDEE_FIELD_NOT_SET = 0;
28 28
 
29
-    const ATTENDEE_FIELD_UNKNOWN = -1;
29
+	const ATTENDEE_FIELD_UNKNOWN = -1;
30 30
 
31 31
 
32
-    /**
33
-     * @var array
34
-     */
35
-    private $attendee_fields = [
36
-        'ATT_fname'     => null,
37
-        'ATT_lname'     => null,
38
-        'ATT_email'     => null,
39
-        'email_confirm' => null,
40
-        'ATT_address'   => null,
41
-        'ATT_address2'  => null,
42
-        'ATT_city'      => null,
43
-        'STA_ID'        => null,
44
-        'CNT_ISO'       => null,
45
-        'ATT_zip'       => null,
46
-        'ATT_phone'     => null,
47
-    ];
32
+	/**
33
+	 * @var array
34
+	 */
35
+	private $attendee_fields = [
36
+		'ATT_fname'     => null,
37
+		'ATT_lname'     => null,
38
+		'ATT_email'     => null,
39
+		'email_confirm' => null,
40
+		'ATT_address'   => null,
41
+		'ATT_address2'  => null,
42
+		'ATT_city'      => null,
43
+		'STA_ID'        => null,
44
+		'CNT_ISO'       => null,
45
+		'ATT_zip'       => null,
46
+		'ATT_phone'     => null,
47
+	];
48 48
 
49 49
 
50
-    /**
51
-     * @param string $field
52
-     * @return string
53
-     */
54
-    public function getInputName(string $field): string
55
-    {
56
-        switch ($field) {
57
-            case SystemInputFieldNamesInterface::FIRST_NAME && $this->attendeeFieldIsSet('ATT_fname'):
58
-                return $this->attendee_fields['ATT_fname'];
59
-            case SystemInputFieldNamesInterface::LAST_NAME && $this->attendeeFieldIsSet('ATT_lname'):
60
-                return $this->attendee_fields['ATT_lname'];
61
-            case SystemInputFieldNamesInterface::EMAIL && $this->attendeeFieldIsSet('ATT_email'):
62
-                return $this->attendee_fields['ATT_email'];
63
-            case SystemInputFieldNamesInterface::EMAIL_CONFIRM && $this->attendeeFieldIsSet('email_confirm'):
64
-                return $this->attendee_fields['email_confirm'];
65
-            case SystemInputFieldNamesInterface::ADDRESS && $this->attendeeFieldIsSet('ATT_address'):
66
-                return $this->attendee_fields['ATT_address'];
67
-            case SystemInputFieldNamesInterface::ADDRESS_2 && $this->attendeeFieldIsSet('ATT_address2'):
68
-                return $this->attendee_fields['ATT_address2'];
69
-            case SystemInputFieldNamesInterface::CITY && $this->attendeeFieldIsSet('ATT_city'):
70
-                return $this->attendee_fields['ATT_city'];
71
-            case SystemInputFieldNamesInterface::STATE && $this->attendeeFieldIsSet('STA_ID'):
72
-                return $this->attendee_fields['STA_ID'];
73
-            case SystemInputFieldNamesInterface::COUNTRY && $this->attendeeFieldIsSet('CNT_ISO'):
74
-                return $this->attendee_fields['CNT_ISO'];
75
-            case SystemInputFieldNamesInterface::POSTAL_CODE && $this->attendeeFieldIsSet('ATT_zip'):
76
-                return $this->attendee_fields['ATT_zip'];
77
-            case SystemInputFieldNamesInterface::PHONE && $this->attendeeFieldIsSet('ATT_phone'):
78
-                return $this->attendee_fields['ATT_phone'];
79
-        }
80
-        return $field;
81
-    }
50
+	/**
51
+	 * @param string $field
52
+	 * @return string
53
+	 */
54
+	public function getInputName(string $field): string
55
+	{
56
+		switch ($field) {
57
+			case SystemInputFieldNamesInterface::FIRST_NAME && $this->attendeeFieldIsSet('ATT_fname'):
58
+				return $this->attendee_fields['ATT_fname'];
59
+			case SystemInputFieldNamesInterface::LAST_NAME && $this->attendeeFieldIsSet('ATT_lname'):
60
+				return $this->attendee_fields['ATT_lname'];
61
+			case SystemInputFieldNamesInterface::EMAIL && $this->attendeeFieldIsSet('ATT_email'):
62
+				return $this->attendee_fields['ATT_email'];
63
+			case SystemInputFieldNamesInterface::EMAIL_CONFIRM && $this->attendeeFieldIsSet('email_confirm'):
64
+				return $this->attendee_fields['email_confirm'];
65
+			case SystemInputFieldNamesInterface::ADDRESS && $this->attendeeFieldIsSet('ATT_address'):
66
+				return $this->attendee_fields['ATT_address'];
67
+			case SystemInputFieldNamesInterface::ADDRESS_2 && $this->attendeeFieldIsSet('ATT_address2'):
68
+				return $this->attendee_fields['ATT_address2'];
69
+			case SystemInputFieldNamesInterface::CITY && $this->attendeeFieldIsSet('ATT_city'):
70
+				return $this->attendee_fields['ATT_city'];
71
+			case SystemInputFieldNamesInterface::STATE && $this->attendeeFieldIsSet('STA_ID'):
72
+				return $this->attendee_fields['STA_ID'];
73
+			case SystemInputFieldNamesInterface::COUNTRY && $this->attendeeFieldIsSet('CNT_ISO'):
74
+				return $this->attendee_fields['CNT_ISO'];
75
+			case SystemInputFieldNamesInterface::POSTAL_CODE && $this->attendeeFieldIsSet('ATT_zip'):
76
+				return $this->attendee_fields['ATT_zip'];
77
+			case SystemInputFieldNamesInterface::PHONE && $this->attendeeFieldIsSet('ATT_phone'):
78
+				return $this->attendee_fields['ATT_phone'];
79
+		}
80
+		return $field;
81
+	}
82 82
 
83 83
 
84
-    /**
85
-     * uses a "balanced ternary" to simultaneously represent
86
-     * whether the requested field is a property and whether or not it has been set:
87
-     *
88
-     *   1 indicates that the field IS an attendee field AND has been set
89
-     *   0 indicates that the field IS an attendee field but has not yet been set
90
-     *  -1 indicates that the field is NOT a known attendee field
91
-     *
92
-     * @param string $field
93
-     * @return int
94
-     */
95
-    public function attendeeFieldIsSet(string $field): int
96
-    {
97
-        if (! array_key_exists($field, $this->attendee_fields)) {
98
-            return self::ATTENDEE_FIELD_UNKNOWN;
99
-        }
100
-        return $this->attendee_fields[ $field ] !== null
101
-            ? self::ATTENDEE_FIELD_SET
102
-            : self::ATTENDEE_FIELD_NOT_SET;
103
-    }
84
+	/**
85
+	 * uses a "balanced ternary" to simultaneously represent
86
+	 * whether the requested field is a property and whether or not it has been set:
87
+	 *
88
+	 *   1 indicates that the field IS an attendee field AND has been set
89
+	 *   0 indicates that the field IS an attendee field but has not yet been set
90
+	 *  -1 indicates that the field is NOT a known attendee field
91
+	 *
92
+	 * @param string $field
93
+	 * @return int
94
+	 */
95
+	public function attendeeFieldIsSet(string $field): int
96
+	{
97
+		if (! array_key_exists($field, $this->attendee_fields)) {
98
+			return self::ATTENDEE_FIELD_UNKNOWN;
99
+		}
100
+		return $this->attendee_fields[ $field ] !== null
101
+			? self::ATTENDEE_FIELD_SET
102
+			: self::ATTENDEE_FIELD_NOT_SET;
103
+	}
104 104
 
105 105
 
106
-    /**
107
-     * @param string $field
108
-     * @param string $input_name
109
-     * @return bool
110
-     */
111
-    public function setAttendeeField(string $field, string $input_name): bool
112
-    {
113
-        if ($this->attendeeFieldIsSet($field) === self::ATTENDEE_FIELD_NOT_SET) {
114
-            $this->attendee_fields[ $field ] = $input_name;
115
-            return true;
116
-        }
117
-        return false;
118
-    }
106
+	/**
107
+	 * @param string $field
108
+	 * @param string $input_name
109
+	 * @return bool
110
+	 */
111
+	public function setAttendeeField(string $field, string $input_name): bool
112
+	{
113
+		if ($this->attendeeFieldIsSet($field) === self::ATTENDEE_FIELD_NOT_SET) {
114
+			$this->attendee_fields[ $field ] = $input_name;
115
+			return true;
116
+		}
117
+		return false;
118
+	}
119 119
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function attendeeFieldIsSet(string $field): int
96 96
     {
97
-        if (! array_key_exists($field, $this->attendee_fields)) {
97
+        if ( ! array_key_exists($field, $this->attendee_fields)) {
98 98
             return self::ATTENDEE_FIELD_UNKNOWN;
99 99
         }
100
-        return $this->attendee_fields[ $field ] !== null
100
+        return $this->attendee_fields[$field] !== null
101 101
             ? self::ATTENDEE_FIELD_SET
102 102
             : self::ATTENDEE_FIELD_NOT_SET;
103 103
     }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     public function setAttendeeField(string $field, string $input_name): bool
112 112
     {
113 113
         if ($this->attendeeFieldIsSet($field) === self::ATTENDEE_FIELD_NOT_SET) {
114
-            $this->attendee_fields[ $field ] = $input_name;
114
+            $this->attendee_fields[$field] = $input_name;
115 115
             return true;
116 116
         }
117 117
         return false;
Please login to merge, or discard this patch.
core/domain/services/registration/form/v2/FormSubmissionHandler.php 2 patches
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -14,114 +14,114 @@
 block discarded – undo
14 14
 class FormSubmissionHandler
15 15
 {
16 16
 
17
-    /**
18
-     * @var EE_Form_Submission
19
-     */
20
-    private $form_submission;
21
-
22
-    /**
23
-     * @var EE_Checkout
24
-     */
25
-    private $checkout;
26
-
27
-
28
-    /**
29
-     * @param EE_Checkout $checkout
30
-     */
31
-    public function __construct(EE_Checkout $checkout)
32
-    {
33
-        $this->checkout = $checkout;
34
-
35
-        add_action(
36
-            'AHEE__EE_Form_Section_Proper__receive_form_submission__end',
37
-            [$this]
38
-        );
39
-        /*
17
+	/**
18
+	 * @var EE_Form_Submission
19
+	 */
20
+	private $form_submission;
21
+
22
+	/**
23
+	 * @var EE_Checkout
24
+	 */
25
+	private $checkout;
26
+
27
+
28
+	/**
29
+	 * @param EE_Checkout $checkout
30
+	 */
31
+	public function __construct(EE_Checkout $checkout)
32
+	{
33
+		$this->checkout = $checkout;
34
+
35
+		add_action(
36
+			'AHEE__EE_Form_Section_Proper__receive_form_submission__end',
37
+			[$this]
38
+		);
39
+		/*
40 40
             $req_data,
41 41
             $this,
42 42
             $validate
43 43
         */
44
-    }
45
-
46
-
47
-    /**
48
-     * @return JsonDataAPI
49
-     * @throws EE_Error
50
-     * @throws ReflectionException
51
-     */
52
-    public function getFormDataAPI(): JsonDataAPI
53
-    {
54
-        $this->getFormSubmission();
55
-        $form_data = $this->form_submission instanceof EE_Form_Submission ? $this->form_submission->data() : '{}';
56
-        return new JsonDataAPI($form_data);
57
-    }
58
-
59
-
60
-    /**
61
-     * @return EE_Form_Submission
62
-     * @throws EE_Error
63
-     * @throws ReflectionException
64
-     */
65
-    public function getFormSubmission(): EE_Form_Submission
66
-    {
67
-        if (! $this->form_submission instanceof EE_Form_Submission) {
68
-            $form_submission = $this->getFormSubmissionForTransaction($this->checkout->transaction);
69
-            if ($form_submission instanceof EE_Form_Submission) {
70
-                $this->setFormSubmission($form_submission);
71
-            }
72
-        }
73
-        \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
74
-        \EEH_Debug_Tools::printr($this->form_submission->data(), '$this->form_submission->data()', __FILE__, __LINE__);
75
-        return $this->form_submission;
76
-    }
77
-
78
-
79
-    /**
80
-     * @param EE_Transaction $transaction
81
-     * @return EE_Form_Submission|null
82
-     * @throws EE_Error
83
-     * @throws ReflectionException
84
-     */
85
-    public function getFormSubmissionForTransaction(EE_Transaction $transaction): ?EE_Form_Submission
86
-    {
87
-        $form_submission = EEM_Form_Submission::instance()->getFormSubmissionForTransaction($transaction);
88
-        return $form_submission instanceof EE_Form_Submission ? $form_submission : null;
89
-        // if () {
90
-        // }
91
-        // return $this->generateFormSubmission($transaction);
92
-    }
93
-
94
-
95
-    /**
96
-     * @return EE_Form_Submission
97
-     * @throws EE_Error
98
-     * @throws ReflectionException
99
-     */
100
-    public function generateFormSubmission(): EE_Form_Submission
101
-    {
102
-        $TXN_ID = $this->checkout->transaction->ID();
103
-        $form_data = $this->checkout->registration_form->valid_data();
104
-        \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
105
-        \EEH_Debug_Tools::printr($TXN_ID, '$TXN_ID', __FILE__, __LINE__);
106
-        \EEH_Debug_Tools::printr($form_data, 'form data', __FILE__, __LINE__);
107
-        $form_submission = EE_Form_Submission::new_instance(
108
-            [
109
-                'FSB_UUID' => md5(uniqid($TXN_ID . time(), true)),
110
-                'FSC_UUID' => md5(uniqid($TXN_ID . time(), true)),
111
-                'FSB_data' => $form_data,
112
-                'TXN_ID'   => $TXN_ID,
113
-            ]
114
-        );
115
-        $form_submission->save();
116
-        return $form_submission;
117
-    }
118
-
119
-
120
-    /**
121
-     * @param EE_Form_Submission $form_submission
122
-     */
123
-    private function setFormSubmission(EE_Form_Submission $form_submission): void
124
-    {
125
-        $this->form_submission = $form_submission;
126
-    }
44
+	}
45
+
46
+
47
+	/**
48
+	 * @return JsonDataAPI
49
+	 * @throws EE_Error
50
+	 * @throws ReflectionException
51
+	 */
52
+	public function getFormDataAPI(): JsonDataAPI
53
+	{
54
+		$this->getFormSubmission();
55
+		$form_data = $this->form_submission instanceof EE_Form_Submission ? $this->form_submission->data() : '{}';
56
+		return new JsonDataAPI($form_data);
57
+	}
58
+
59
+
60
+	/**
61
+	 * @return EE_Form_Submission
62
+	 * @throws EE_Error
63
+	 * @throws ReflectionException
64
+	 */
65
+	public function getFormSubmission(): EE_Form_Submission
66
+	{
67
+		if (! $this->form_submission instanceof EE_Form_Submission) {
68
+			$form_submission = $this->getFormSubmissionForTransaction($this->checkout->transaction);
69
+			if ($form_submission instanceof EE_Form_Submission) {
70
+				$this->setFormSubmission($form_submission);
71
+			}
72
+		}
73
+		\EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
74
+		\EEH_Debug_Tools::printr($this->form_submission->data(), '$this->form_submission->data()', __FILE__, __LINE__);
75
+		return $this->form_submission;
76
+	}
77
+
78
+
79
+	/**
80
+	 * @param EE_Transaction $transaction
81
+	 * @return EE_Form_Submission|null
82
+	 * @throws EE_Error
83
+	 * @throws ReflectionException
84
+	 */
85
+	public function getFormSubmissionForTransaction(EE_Transaction $transaction): ?EE_Form_Submission
86
+	{
87
+		$form_submission = EEM_Form_Submission::instance()->getFormSubmissionForTransaction($transaction);
88
+		return $form_submission instanceof EE_Form_Submission ? $form_submission : null;
89
+		// if () {
90
+		// }
91
+		// return $this->generateFormSubmission($transaction);
92
+	}
93
+
94
+
95
+	/**
96
+	 * @return EE_Form_Submission
97
+	 * @throws EE_Error
98
+	 * @throws ReflectionException
99
+	 */
100
+	public function generateFormSubmission(): EE_Form_Submission
101
+	{
102
+		$TXN_ID = $this->checkout->transaction->ID();
103
+		$form_data = $this->checkout->registration_form->valid_data();
104
+		\EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
105
+		\EEH_Debug_Tools::printr($TXN_ID, '$TXN_ID', __FILE__, __LINE__);
106
+		\EEH_Debug_Tools::printr($form_data, 'form data', __FILE__, __LINE__);
107
+		$form_submission = EE_Form_Submission::new_instance(
108
+			[
109
+				'FSB_UUID' => md5(uniqid($TXN_ID . time(), true)),
110
+				'FSC_UUID' => md5(uniqid($TXN_ID . time(), true)),
111
+				'FSB_data' => $form_data,
112
+				'TXN_ID'   => $TXN_ID,
113
+			]
114
+		);
115
+		$form_submission->save();
116
+		return $form_submission;
117
+	}
118
+
119
+
120
+	/**
121
+	 * @param EE_Form_Submission $form_submission
122
+	 */
123
+	private function setFormSubmission(EE_Form_Submission $form_submission): void
124
+	{
125
+		$this->form_submission = $form_submission;
126
+	}
127 127
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      */
65 65
     public function getFormSubmission(): EE_Form_Submission
66 66
     {
67
-        if (! $this->form_submission instanceof EE_Form_Submission) {
67
+        if ( ! $this->form_submission instanceof EE_Form_Submission) {
68 68
             $form_submission = $this->getFormSubmissionForTransaction($this->checkout->transaction);
69 69
             if ($form_submission instanceof EE_Form_Submission) {
70 70
                 $this->setFormSubmission($form_submission);
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
         \EEH_Debug_Tools::printr($form_data, 'form data', __FILE__, __LINE__);
107 107
         $form_submission = EE_Form_Submission::new_instance(
108 108
             [
109
-                'FSB_UUID' => md5(uniqid($TXN_ID . time(), true)),
110
-                'FSC_UUID' => md5(uniqid($TXN_ID . time(), true)),
109
+                'FSB_UUID' => md5(uniqid($TXN_ID.time(), true)),
110
+                'FSC_UUID' => md5(uniqid($TXN_ID.time(), true)),
111 111
                 'FSB_data' => $form_data,
112 112
                 'TXN_ID'   => $TXN_ID,
113 113
             ]
Please login to merge, or discard this patch.
core/domain/services/registration/form/v2/RegFormDependencyHandler.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -7,69 +7,69 @@
 block discarded – undo
7 7
 
8 8
 class RegFormDependencyHandler extends DependencyHandler
9 9
 {
10
-    /**
11
-     * @return void
12
-     */
13
-    public function registerDependencies()
14
-    {
15
-        $reg_form_dependencies = [
16
-            'EventEspresso\core\domain\services\registration\form\v2\RegForm'                  => [
17
-                null,
18
-                'FormSubmissionHandler'  => EE_Dependency_Map::load_from_cache,
19
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
20
-            ],
21
-            'EventEspresso\core\domain\services\registration\form\v2\RegistrantForm'           => [
22
-                null,
23
-                null,
24
-                null,
25
-                null,
26
-                'EEM_Form_Element' => EE_Dependency_Map::load_from_cache,
27
-                'EEM_Form_Section' => EE_Dependency_Map::load_from_cache,
28
-            ],
29
-            'EventEspresso\core\domain\services\registration\form\v2\RegistrantFormSection'    => [
30
-                null,
31
-                null,
32
-                null,
33
-                'EventEspresso\core\domain\services\registration\form\v2\RegistrantFormInput' => EE_Dependency_Map::load_from_cache,
34
-            ],
35
-            'EventEspresso\core\domain\services\registration\form\base\CountryOptions'         => [
36
-                null,
37
-                'EEM_Answer'  => EE_Dependency_Map::load_from_cache,
38
-                'EEM_Country' => EE_Dependency_Map::load_from_cache,
39
-            ],
40
-            'EventEspresso\core\domain\services\registration\form\base\StateOptions'           => [
41
-                null,
42
-                'EEM_State' => EE_Dependency_Map::load_from_cache,
43
-            ],
44
-            'EventEspresso\core\domain\services\registration\form\v2\RegFormHandler'           => [
45
-                null,
46
-                'EventEspresso\core\domain\services\registration\form\base\RegistrantData'         => EE_Dependency_Map::load_from_cache,
47
-                'EE_Form_Section_Proper'                                                           => EE_Dependency_Map::load_from_cache,
48
-                'EventEspresso\core\domain\services\registration\form\base\RegFormAttendeeFactory' => EE_Dependency_Map::load_from_cache,
49
-                'EE_Registration_Processor'                                                        => EE_Dependency_Map::load_from_cache,
50
-            ],
51
-            'EventEspresso\core\domain\services\registration\form\v2\RegFormInputHandler'      => [
52
-                null,
53
-                null,
54
-                'EEM_Attendee'                                                                  => EE_Dependency_Map::load_from_cache,
55
-                'EventEspresso\core\domain\services\registration\form\base\RegistrantData'      => EE_Dependency_Map::load_from_cache,
56
-                'EventEspresso\core\domain\services\registration\form\v2\SystemInputFieldNames' => EE_Dependency_Map::load_from_cache,
57
-            ],
58
-            'EventEspresso\core\domain\services\registration\form\base\RegFormAttendeeFactory' => [
59
-                'EventEspresso\core\services\commands\CommandBus'                          => EE_Dependency_Map::load_from_cache,
60
-                'EventEspresso\core\domain\services\registration\form\base\RegistrantData' => EE_Dependency_Map::load_from_cache,
61
-            ],
62
-            'EventEspresso\core\domain\services\registration\form\v2\RegistrantFormInput'      => [
63
-                null,
64
-                null,
65
-                'EventEspresso\core\domain\services\registration\form\v2\SystemInputFieldNames' => EE_Dependency_Map::load_from_cache,
66
-            ],
67
-            'EventEspresso\core\domain\services\registration\form\v2\FormSubmissionHandler'    => [
68
-                'EventEspresso\core\services\request\RequestInterface' => EE_Dependency_Map::load_from_cache,
69
-            ],
70
-        ];
71
-        foreach ($reg_form_dependencies as $class => $dependencies) {
72
-            $this->dependency_map->registerDependencies($class, $dependencies);
73
-        }
74
-    }
10
+	/**
11
+	 * @return void
12
+	 */
13
+	public function registerDependencies()
14
+	{
15
+		$reg_form_dependencies = [
16
+			'EventEspresso\core\domain\services\registration\form\v2\RegForm'                  => [
17
+				null,
18
+				'FormSubmissionHandler'  => EE_Dependency_Map::load_from_cache,
19
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
20
+			],
21
+			'EventEspresso\core\domain\services\registration\form\v2\RegistrantForm'           => [
22
+				null,
23
+				null,
24
+				null,
25
+				null,
26
+				'EEM_Form_Element' => EE_Dependency_Map::load_from_cache,
27
+				'EEM_Form_Section' => EE_Dependency_Map::load_from_cache,
28
+			],
29
+			'EventEspresso\core\domain\services\registration\form\v2\RegistrantFormSection'    => [
30
+				null,
31
+				null,
32
+				null,
33
+				'EventEspresso\core\domain\services\registration\form\v2\RegistrantFormInput' => EE_Dependency_Map::load_from_cache,
34
+			],
35
+			'EventEspresso\core\domain\services\registration\form\base\CountryOptions'         => [
36
+				null,
37
+				'EEM_Answer'  => EE_Dependency_Map::load_from_cache,
38
+				'EEM_Country' => EE_Dependency_Map::load_from_cache,
39
+			],
40
+			'EventEspresso\core\domain\services\registration\form\base\StateOptions'           => [
41
+				null,
42
+				'EEM_State' => EE_Dependency_Map::load_from_cache,
43
+			],
44
+			'EventEspresso\core\domain\services\registration\form\v2\RegFormHandler'           => [
45
+				null,
46
+				'EventEspresso\core\domain\services\registration\form\base\RegistrantData'         => EE_Dependency_Map::load_from_cache,
47
+				'EE_Form_Section_Proper'                                                           => EE_Dependency_Map::load_from_cache,
48
+				'EventEspresso\core\domain\services\registration\form\base\RegFormAttendeeFactory' => EE_Dependency_Map::load_from_cache,
49
+				'EE_Registration_Processor'                                                        => EE_Dependency_Map::load_from_cache,
50
+			],
51
+			'EventEspresso\core\domain\services\registration\form\v2\RegFormInputHandler'      => [
52
+				null,
53
+				null,
54
+				'EEM_Attendee'                                                                  => EE_Dependency_Map::load_from_cache,
55
+				'EventEspresso\core\domain\services\registration\form\base\RegistrantData'      => EE_Dependency_Map::load_from_cache,
56
+				'EventEspresso\core\domain\services\registration\form\v2\SystemInputFieldNames' => EE_Dependency_Map::load_from_cache,
57
+			],
58
+			'EventEspresso\core\domain\services\registration\form\base\RegFormAttendeeFactory' => [
59
+				'EventEspresso\core\services\commands\CommandBus'                          => EE_Dependency_Map::load_from_cache,
60
+				'EventEspresso\core\domain\services\registration\form\base\RegistrantData' => EE_Dependency_Map::load_from_cache,
61
+			],
62
+			'EventEspresso\core\domain\services\registration\form\v2\RegistrantFormInput'      => [
63
+				null,
64
+				null,
65
+				'EventEspresso\core\domain\services\registration\form\v2\SystemInputFieldNames' => EE_Dependency_Map::load_from_cache,
66
+			],
67
+			'EventEspresso\core\domain\services\registration\form\v2\FormSubmissionHandler'    => [
68
+				'EventEspresso\core\services\request\RequestInterface' => EE_Dependency_Map::load_from_cache,
69
+			],
70
+		];
71
+		foreach ($reg_form_dependencies as $class => $dependencies) {
72
+			$this->dependency_map->registerDependencies($class, $dependencies);
73
+		}
74
+	}
75 75
 }
Please login to merge, or discard this patch.
core/domain/services/registration/form/v2/RegFormHandler.php 2 patches
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -25,150 +25,150 @@
 block discarded – undo
25 25
 class RegFormHandler extends RegFormHandlerBase
26 26
 {
27 27
 
28
-    /**
29
-     * @var RegFormInputHandler
30
-     */
31
-    public $input_handler;
32
-
33
-    /**
34
-     * @var EE_Form_Submission
35
-     */
36
-    private $form_submission;
37
-
38
-
39
-    /**
40
-     * RegFormHandler constructor.
41
-     */
42
-    public function __construct(
43
-        EE_Checkout $checkout,
44
-        RegistrantData $registrant_data,
45
-        EE_Form_Section_Proper $reg_form,
46
-        RegFormAttendeeFactory $attendee_factory,
47
-        EE_Registration_Processor $registration_processor
48
-    ) {
49
-        parent::__construct($checkout, $registrant_data, $reg_form, $attendee_factory, $registration_processor);
50
-    }
51
-
52
-
53
-    // /**
54
-    //  * @return EE_Form_Submission
55
-    //  * @throws EE_Error
56
-    //  * @throws ReflectionException
57
-    //  */
58
-    // public function getFormSubmission(): EE_Form_Submission
59
-    // {
60
-    //     if (! $this->form_submission instanceof EE_Form_Submission) {
61
-    //         $form_submission = EEM_Form_Submission::instance()->getFormSubmissionForTransaction(
62
-    //             $this->checkout->transaction
63
-    //         );
64
-    //         if (! $form_submission instanceof EE_Form_Submission) {
65
-    //             $TXN_ID = $this->checkout->transaction->ID();
66
-    //             $form_submission = EE_Form_Submission::new_instance(
67
-    //                 [
68
-    //                     'FSB_UUID' => md5(uniqid($TXN_ID . time(), true)),
69
-    //                     'FSC_UUID' => md5(uniqid($TXN_ID . time(), true)),
70
-    //                     'FSB_data' => $this->checkout->current_step->valid_data(),
71
-    //                     'TXN_ID'   => $TXN_ID,
72
-    //                 ]
73
-    //             );
74
-    //             $form_submission->save();
75
-    //         }
76
-    //         $this->setFormSubmission($form_submission);
77
-    //     }
78
-    //     \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
79
-    //     \EEH_Debug_Tools::printr($this->form_submission->data(), '$this->form_submission->data()', __FILE__, __LINE__);
80
-    //     return $this->form_submission;
81
-    // }
82
-
83
-
84
-    /**
85
-     * @param EE_Form_Submission $form_submission
86
-     */
87
-    public function setFormSubmission(EE_Form_Submission $form_submission): void
88
-    {
89
-        $this->form_submission = $form_submission;
90
-    }
91
-
92
-
93
-    public function initializeInputHandler()
94
-    {
95
-        \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
96
-        $reg_form            = $this->checkout->current_step->reg_form;
97
-        $required_questions  = $reg_form instanceof RegForm ? $reg_form->requiredQuestions() : [];
98
-        $this->input_handler = LoaderFactory::getShared(
99
-            'EventEspresso\core\domain\services\registration\form\v2\RegFormInputHandler',
100
-            [$this->checkout->reg_url_link, $required_questions]
101
-        );
102
-    }
103
-
104
-
105
-    /**
106
-     * @param EE_Registration $registration
107
-     * @param string          $reg_url_link
108
-     * @param array           $reg_form_data
109
-     * @return bool
110
-     * @throws EE_Error
111
-     * @throws ReflectionException
112
-     */
113
-    protected function processRegFormData(
114
-        EE_Registration $registration,
115
-        string $reg_url_link,
116
-        array $reg_form_data
117
-    ): bool {
118
-        \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
119
-        \EEH_Debug_Tools::printr($reg_form_data, '$reg_form_data', __FILE__, __LINE__);
120
-        \EEH_Debug_Tools::printr($this->form_submission->data(), '$this->form_submission->data()', __FILE__, __LINE__);
121
-        if (isset($reg_form_data[ $reg_url_link ])) {
122
-            // do we need to copy basic info from primary attendee ?
123
-            $copy_primary = isset($reg_form_data[ $reg_url_link ]['additional_attendee_reg_info'])
124
-                            && absint($reg_form_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0;
125
-            $this->registrant_data->setCopyPrimary($copy_primary);
126
-            // filter form input data for this registration
127
-            $reg_form_data[ $reg_url_link ] = (array) apply_filters(
128
-                'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
129
-                $reg_form_data[ $reg_url_link ]
130
-            );
131
-            if (isset($reg_form_data['primary_attendee'])) {
132
-                $primary_reg_url_link = $reg_form_data['primary_attendee'] ?? '';
133
-                $this->registrant_data->addPrimaryRegistrantDataValue('reg_url_link', $primary_reg_url_link);
134
-                unset($reg_form_data['primary_attendee']);
135
-            }
136
-            // now loop through our array of valid post data && process attendee reg forms
137
-            foreach ($reg_form_data[ $reg_url_link ] as $form_section => $form_inputs) {
138
-                if (in_array($form_section, $this->non_input_form_sections, true)) {
139
-                    continue;
140
-                }
141
-                foreach ($form_inputs as $form_input => $input_value) {
142
-                    $input_processed = $this->input_handler->processFormInput(
143
-                        $registration,
144
-                        $reg_url_link,
145
-                        $form_input,
146
-                        $input_value
147
-                    );
148
-                    if (! $input_processed) {
149
-                        echo "\n############### ! input_processed #########################\n";
150
-                        return false;
151
-                    }
152
-                }
153
-            }
154
-        }
155
-        return true;
156
-    }
157
-
158
-
159
-    // /**
160
-    //  * @param EE_Registration $registration
161
-    //  * @return void
162
-    //  * @throws EE_Error
163
-    //  * @throws InvalidArgumentException
164
-    //  * @throws ReflectionException
165
-    //  * @throws InvalidDataTypeException
166
-    //  * @throws InvalidInterfaceException
167
-    //  */
168
-    // private function associateRegistrationWithTransaction(EE_Registration $registration)
169
-    // {
170
-    //     // add relation to registration
171
-    //     $this->checkout->transaction->_add_relation_to($registration, 'Registration');
172
-    //     $this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
173
-    // }
28
+	/**
29
+	 * @var RegFormInputHandler
30
+	 */
31
+	public $input_handler;
32
+
33
+	/**
34
+	 * @var EE_Form_Submission
35
+	 */
36
+	private $form_submission;
37
+
38
+
39
+	/**
40
+	 * RegFormHandler constructor.
41
+	 */
42
+	public function __construct(
43
+		EE_Checkout $checkout,
44
+		RegistrantData $registrant_data,
45
+		EE_Form_Section_Proper $reg_form,
46
+		RegFormAttendeeFactory $attendee_factory,
47
+		EE_Registration_Processor $registration_processor
48
+	) {
49
+		parent::__construct($checkout, $registrant_data, $reg_form, $attendee_factory, $registration_processor);
50
+	}
51
+
52
+
53
+	// /**
54
+	//  * @return EE_Form_Submission
55
+	//  * @throws EE_Error
56
+	//  * @throws ReflectionException
57
+	//  */
58
+	// public function getFormSubmission(): EE_Form_Submission
59
+	// {
60
+	//     if (! $this->form_submission instanceof EE_Form_Submission) {
61
+	//         $form_submission = EEM_Form_Submission::instance()->getFormSubmissionForTransaction(
62
+	//             $this->checkout->transaction
63
+	//         );
64
+	//         if (! $form_submission instanceof EE_Form_Submission) {
65
+	//             $TXN_ID = $this->checkout->transaction->ID();
66
+	//             $form_submission = EE_Form_Submission::new_instance(
67
+	//                 [
68
+	//                     'FSB_UUID' => md5(uniqid($TXN_ID . time(), true)),
69
+	//                     'FSC_UUID' => md5(uniqid($TXN_ID . time(), true)),
70
+	//                     'FSB_data' => $this->checkout->current_step->valid_data(),
71
+	//                     'TXN_ID'   => $TXN_ID,
72
+	//                 ]
73
+	//             );
74
+	//             $form_submission->save();
75
+	//         }
76
+	//         $this->setFormSubmission($form_submission);
77
+	//     }
78
+	//     \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
79
+	//     \EEH_Debug_Tools::printr($this->form_submission->data(), '$this->form_submission->data()', __FILE__, __LINE__);
80
+	//     return $this->form_submission;
81
+	// }
82
+
83
+
84
+	/**
85
+	 * @param EE_Form_Submission $form_submission
86
+	 */
87
+	public function setFormSubmission(EE_Form_Submission $form_submission): void
88
+	{
89
+		$this->form_submission = $form_submission;
90
+	}
91
+
92
+
93
+	public function initializeInputHandler()
94
+	{
95
+		\EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
96
+		$reg_form            = $this->checkout->current_step->reg_form;
97
+		$required_questions  = $reg_form instanceof RegForm ? $reg_form->requiredQuestions() : [];
98
+		$this->input_handler = LoaderFactory::getShared(
99
+			'EventEspresso\core\domain\services\registration\form\v2\RegFormInputHandler',
100
+			[$this->checkout->reg_url_link, $required_questions]
101
+		);
102
+	}
103
+
104
+
105
+	/**
106
+	 * @param EE_Registration $registration
107
+	 * @param string          $reg_url_link
108
+	 * @param array           $reg_form_data
109
+	 * @return bool
110
+	 * @throws EE_Error
111
+	 * @throws ReflectionException
112
+	 */
113
+	protected function processRegFormData(
114
+		EE_Registration $registration,
115
+		string $reg_url_link,
116
+		array $reg_form_data
117
+	): bool {
118
+		\EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
119
+		\EEH_Debug_Tools::printr($reg_form_data, '$reg_form_data', __FILE__, __LINE__);
120
+		\EEH_Debug_Tools::printr($this->form_submission->data(), '$this->form_submission->data()', __FILE__, __LINE__);
121
+		if (isset($reg_form_data[ $reg_url_link ])) {
122
+			// do we need to copy basic info from primary attendee ?
123
+			$copy_primary = isset($reg_form_data[ $reg_url_link ]['additional_attendee_reg_info'])
124
+							&& absint($reg_form_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0;
125
+			$this->registrant_data->setCopyPrimary($copy_primary);
126
+			// filter form input data for this registration
127
+			$reg_form_data[ $reg_url_link ] = (array) apply_filters(
128
+				'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
129
+				$reg_form_data[ $reg_url_link ]
130
+			);
131
+			if (isset($reg_form_data['primary_attendee'])) {
132
+				$primary_reg_url_link = $reg_form_data['primary_attendee'] ?? '';
133
+				$this->registrant_data->addPrimaryRegistrantDataValue('reg_url_link', $primary_reg_url_link);
134
+				unset($reg_form_data['primary_attendee']);
135
+			}
136
+			// now loop through our array of valid post data && process attendee reg forms
137
+			foreach ($reg_form_data[ $reg_url_link ] as $form_section => $form_inputs) {
138
+				if (in_array($form_section, $this->non_input_form_sections, true)) {
139
+					continue;
140
+				}
141
+				foreach ($form_inputs as $form_input => $input_value) {
142
+					$input_processed = $this->input_handler->processFormInput(
143
+						$registration,
144
+						$reg_url_link,
145
+						$form_input,
146
+						$input_value
147
+					);
148
+					if (! $input_processed) {
149
+						echo "\n############### ! input_processed #########################\n";
150
+						return false;
151
+					}
152
+				}
153
+			}
154
+		}
155
+		return true;
156
+	}
157
+
158
+
159
+	// /**
160
+	//  * @param EE_Registration $registration
161
+	//  * @return void
162
+	//  * @throws EE_Error
163
+	//  * @throws InvalidArgumentException
164
+	//  * @throws ReflectionException
165
+	//  * @throws InvalidDataTypeException
166
+	//  * @throws InvalidInterfaceException
167
+	//  */
168
+	// private function associateRegistrationWithTransaction(EE_Registration $registration)
169
+	// {
170
+	//     // add relation to registration
171
+	//     $this->checkout->transaction->_add_relation_to($registration, 'Registration');
172
+	//     $this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
173
+	// }
174 174
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
         \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
119 119
         \EEH_Debug_Tools::printr($reg_form_data, '$reg_form_data', __FILE__, __LINE__);
120 120
         \EEH_Debug_Tools::printr($this->form_submission->data(), '$this->form_submission->data()', __FILE__, __LINE__);
121
-        if (isset($reg_form_data[ $reg_url_link ])) {
121
+        if (isset($reg_form_data[$reg_url_link])) {
122 122
             // do we need to copy basic info from primary attendee ?
123
-            $copy_primary = isset($reg_form_data[ $reg_url_link ]['additional_attendee_reg_info'])
124
-                            && absint($reg_form_data[ $reg_url_link ]['additional_attendee_reg_info']) === 0;
123
+            $copy_primary = isset($reg_form_data[$reg_url_link]['additional_attendee_reg_info'])
124
+                            && absint($reg_form_data[$reg_url_link]['additional_attendee_reg_info']) === 0;
125 125
             $this->registrant_data->setCopyPrimary($copy_primary);
126 126
             // filter form input data for this registration
127
-            $reg_form_data[ $reg_url_link ] = (array) apply_filters(
127
+            $reg_form_data[$reg_url_link] = (array) apply_filters(
128 128
                 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
129
-                $reg_form_data[ $reg_url_link ]
129
+                $reg_form_data[$reg_url_link]
130 130
             );
131 131
             if (isset($reg_form_data['primary_attendee'])) {
132 132
                 $primary_reg_url_link = $reg_form_data['primary_attendee'] ?? '';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                 unset($reg_form_data['primary_attendee']);
135 135
             }
136 136
             // now loop through our array of valid post data && process attendee reg forms
137
-            foreach ($reg_form_data[ $reg_url_link ] as $form_section => $form_inputs) {
137
+            foreach ($reg_form_data[$reg_url_link] as $form_section => $form_inputs) {
138 138
                 if (in_array($form_section, $this->non_input_form_sections, true)) {
139 139
                     continue;
140 140
                 }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                         $form_input,
146 146
                         $input_value
147 147
                     );
148
-                    if (! $input_processed) {
148
+                    if ( ! $input_processed) {
149 149
                         echo "\n############### ! input_processed #########################\n";
150 150
                         return false;
151 151
                     }
Please login to merge, or discard this patch.
core/domain/services/registration/form/SystemInputFieldNamesInterface.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -4,32 +4,32 @@
 block discarded – undo
4 4
 
5 5
 interface SystemInputFieldNamesInterface
6 6
 {
7
-    const FIRST_NAME    = 'first-name';
7
+	const FIRST_NAME    = 'first-name';
8 8
 
9
-    const LAST_NAME     = 'last-name';
9
+	const LAST_NAME     = 'last-name';
10 10
 
11
-    const EMAIL         = 'email';
11
+	const EMAIL         = 'email';
12 12
 
13
-    const EMAIL_CONFIRM = 'email-confirmation';
13
+	const EMAIL_CONFIRM = 'email-confirmation';
14 14
 
15
-    const ADDRESS       = 'address';
15
+	const ADDRESS       = 'address';
16 16
 
17
-    const ADDRESS_2     = 'address-2';
17
+	const ADDRESS_2     = 'address-2';
18 18
 
19
-    const CITY          = 'city';
19
+	const CITY          = 'city';
20 20
 
21
-    const STATE         = 'state';
21
+	const STATE         = 'state';
22 22
 
23
-    const COUNTRY       = 'country';
23
+	const COUNTRY       = 'country';
24 24
 
25
-    const POSTAL_CODE   = 'postal-code';
25
+	const POSTAL_CODE   = 'postal-code';
26 26
 
27
-    const PHONE         = 'phone';
27
+	const PHONE         = 'phone';
28 28
 
29 29
 
30
-    /**
31
-     * @param string $field
32
-     * @return string
33
-     */
34
-    public function getInputName(string $field): string;
30
+	/**
31
+	 * @param string $field
32
+	 * @return string
33
+	 */
34
+	public function getInputName(string $field): string;
35 35
 }
Please login to merge, or discard this patch.
core/domain/services/registration/form/v1/RegForm.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -21,44 +21,44 @@
 block discarded – undo
21 21
 class RegForm extends RegFormBase
22 22
 {
23 23
 
24
-    /**
25
-     * RegForm constructor.
26
-     *
27
-     * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step
28
-     * @param EE_Registration_Config                $reg_config
29
-     * @throws ReflectionException
30
-     * @throws EE_Error
31
-     */
32
-    public function __construct(
33
-        EE_SPCO_Reg_Step_Attendee_Information $reg_step,
34
-        EE_Registration_Config $reg_config
35
-    ) {
36
-        LoaderFactory::getShared(RegFormQuestionFactory::class, [[$this, 'addRequiredQuestion']]);
37
-        parent::__construct($reg_step, $reg_config);
38
-    }
24
+	/**
25
+	 * RegForm constructor.
26
+	 *
27
+	 * @param EE_SPCO_Reg_Step_Attendee_Information $reg_step
28
+	 * @param EE_Registration_Config                $reg_config
29
+	 * @throws ReflectionException
30
+	 * @throws EE_Error
31
+	 */
32
+	public function __construct(
33
+		EE_SPCO_Reg_Step_Attendee_Information $reg_step,
34
+		EE_Registration_Config $reg_config
35
+	) {
36
+		LoaderFactory::getShared(RegFormQuestionFactory::class, [[$this, 'addRequiredQuestion']]);
37
+		parent::__construct($reg_step, $reg_config);
38
+	}
39 39
 
40 40
 
41
-    /**
42
-     * @param EE_Registration $registration
43
-     * @param bool            $admin_request
44
-     * @param bool            $copy_attendee_info
45
-     * @param callable        $enablePrintCopyInfo
46
-     * @return RegistrantFormInterface
47
-     */
48
-    protected function getRegistrantForm(
49
-        EE_Registration $registration,
50
-        bool $admin_request,
51
-        bool $copy_attendee_info,
52
-        callable $enablePrintCopyInfo
53
-    ): RegistrantFormInterface {
54
-        return LoaderFactory::getNew(
55
-            RegistrantForm::class,
56
-            [
57
-                $registration,
58
-                $admin_request,
59
-                $copy_attendee_info,
60
-                $enablePrintCopyInfo,
61
-            ]
62
-        );
63
-    }
41
+	/**
42
+	 * @param EE_Registration $registration
43
+	 * @param bool            $admin_request
44
+	 * @param bool            $copy_attendee_info
45
+	 * @param callable        $enablePrintCopyInfo
46
+	 * @return RegistrantFormInterface
47
+	 */
48
+	protected function getRegistrantForm(
49
+		EE_Registration $registration,
50
+		bool $admin_request,
51
+		bool $copy_attendee_info,
52
+		callable $enablePrintCopyInfo
53
+	): RegistrantFormInterface {
54
+		return LoaderFactory::getNew(
55
+			RegistrantForm::class,
56
+			[
57
+				$registration,
58
+				$admin_request,
59
+				$copy_attendee_info,
60
+				$enablePrintCopyInfo,
61
+			]
62
+		);
63
+	}
64 64
 }
Please login to merge, or discard this patch.
core/domain/services/registration/form/v1/RegFormInputHandler.php 2 patches
Indentation   +265 added lines, -265 removed lines patch added patch discarded remove patch
@@ -16,295 +16,295 @@
 block discarded – undo
16 16
 class RegFormInputHandler
17 17
 {
18 18
 
19
-    /**
20
-     * @var EEM_Attendee
21
-     */
22
-    protected $attendee_model;
19
+	/**
20
+	 * @var EEM_Attendee
21
+	 */
22
+	protected $attendee_model;
23 23
 
24
-    /**
25
-     * @var string
26
-     */
27
-    protected $checkout_reg_url_link;
24
+	/**
25
+	 * @var string
26
+	 */
27
+	protected $checkout_reg_url_link;
28 28
 
29
-    /**
30
-     * @var array
31
-     */
32
-    protected $non_persistable_fields = [SystemInputFieldNamesInterface::EMAIL_CONFIRM];
29
+	/**
30
+	 * @var array
31
+	 */
32
+	protected $non_persistable_fields = [SystemInputFieldNamesInterface::EMAIL_CONFIRM];
33 33
 
34
-    /**
35
-     * @var RegistrantData
36
-     */
37
-    protected $registrant_data;
34
+	/**
35
+	 * @var RegistrantData
36
+	 */
37
+	protected $registrant_data;
38 38
 
39
-    /**
40
-     * @var array
41
-     */
42
-    protected $required_questions;
39
+	/**
40
+	 * @var array
41
+	 */
42
+	protected $required_questions;
43 43
 
44
-    /**
45
-     * @var SystemInputFieldNamesInterface
46
-     */
47
-    protected $system_input_field_names;
44
+	/**
45
+	 * @var SystemInputFieldNamesInterface
46
+	 */
47
+	protected $system_input_field_names;
48 48
 
49 49
 
50
-    /**
51
-     * RegFormHandler constructor.
52
-     */
53
-    public function __construct(
54
-        string $checkout_reg_url_link,
55
-        array $required_questions,
56
-        EEM_Attendee $attendee_model,
57
-        RegistrantData $registrant_data,
58
-        SystemInputFieldNamesInterface $system_input_field_names
59
-    ) {
60
-        $this->attendee_model           = $attendee_model;
61
-        $this->checkout_reg_url_link    = $checkout_reg_url_link;
62
-        $this->registrant_data          = $registrant_data;
63
-        $this->required_questions       = $required_questions;
64
-        $this->system_input_field_names = $system_input_field_names;
65
-    }
50
+	/**
51
+	 * RegFormHandler constructor.
52
+	 */
53
+	public function __construct(
54
+		string $checkout_reg_url_link,
55
+		array $required_questions,
56
+		EEM_Attendee $attendee_model,
57
+		RegistrantData $registrant_data,
58
+		SystemInputFieldNamesInterface $system_input_field_names
59
+	) {
60
+		$this->attendee_model           = $attendee_model;
61
+		$this->checkout_reg_url_link    = $checkout_reg_url_link;
62
+		$this->registrant_data          = $registrant_data;
63
+		$this->required_questions       = $required_questions;
64
+		$this->system_input_field_names = $system_input_field_names;
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * @param EE_Registration  $registration
70
-     * @param string           $reg_url_link
71
-     * @param int|string       $field
72
-     * @param float|int|string $value
73
-     * @return bool
74
-     * @throws EE_Error
75
-     * @throws ReflectionException
76
-     */
77
-    public function processFormInput(
78
-        EE_Registration $registration,
79
-        string $reg_url_link,
80
-        $field,
81
-        $value
82
-    ): bool {
83
-        // check for critical inputs
84
-        if (! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($field, $value)) {
85
-            echo "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
86
-            return false;
87
-        }
88
-        $value = $this->registrant_data->saveOrCopyPrimaryRegistrantData(
89
-            $reg_url_link,
90
-            $field,
91
-            $value
92
-        );
93
-        \EEH_Debug_Tools::printr($value, ' value >>====> ', __FILE__, __LINE__);
94
-        if (! $this->saveRegistrationFormInput($registration, $reg_url_link, $field, $value)) {
95
-            EE_Error::add_error(
96
-                sprintf(
97
-                    esc_html_x(
98
-                        'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"',
99
-                        'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"',
100
-                        'event_espresso'
101
-                    ),
102
-                    $field,
103
-                    $value
104
-                ),
105
-                __FILE__,
106
-                __FUNCTION__,
107
-                __LINE__
108
-            );
109
-            return false;
110
-        }
111
-        return true;
112
-    }
68
+	/**
69
+	 * @param EE_Registration  $registration
70
+	 * @param string           $reg_url_link
71
+	 * @param int|string       $field
72
+	 * @param float|int|string $value
73
+	 * @return bool
74
+	 * @throws EE_Error
75
+	 * @throws ReflectionException
76
+	 */
77
+	public function processFormInput(
78
+		EE_Registration $registration,
79
+		string $reg_url_link,
80
+		$field,
81
+		$value
82
+	): bool {
83
+		// check for critical inputs
84
+		if (! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($field, $value)) {
85
+			echo "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
86
+			return false;
87
+		}
88
+		$value = $this->registrant_data->saveOrCopyPrimaryRegistrantData(
89
+			$reg_url_link,
90
+			$field,
91
+			$value
92
+		);
93
+		\EEH_Debug_Tools::printr($value, ' value >>====> ', __FILE__, __LINE__);
94
+		if (! $this->saveRegistrationFormInput($registration, $reg_url_link, $field, $value)) {
95
+			EE_Error::add_error(
96
+				sprintf(
97
+					esc_html_x(
98
+						'Unable to save registration form data for the form input: "%1$s" with the submitted value: "%2$s"',
99
+						'Unable to save registration form data for the form input: "form input name" with the submitted value: "form input value"',
100
+						'event_espresso'
101
+					),
102
+					$field,
103
+					$value
104
+				),
105
+				__FILE__,
106
+				__FUNCTION__,
107
+				__LINE__
108
+			);
109
+			return false;
110
+		}
111
+		return true;
112
+	}
113 113
 
114 114
 
115
-    /**
116
-     * @param EE_Registration  $registration
117
-     * @param string           $reg_url_link
118
-     * @param int|string       $field the form input name
119
-     * @param float|int|string $value the input value
120
-     * @return bool
121
-     * @throws EE_Error
122
-     * @throws InvalidArgumentException
123
-     * @throws InvalidDataTypeException
124
-     * @throws InvalidInterfaceException
125
-     * @throws ReflectionException
126
-     */
127
-    protected function saveRegistrationFormInput(
128
-        EE_Registration $registration,
129
-        string $reg_url_link,
130
-        $field = '',
131
-        $value = ''
132
-    ): bool {
133
-        if ($this->bypassSaveRegFormInputValue($registration, $field, $value)) {
134
-            echo "\n#############################################################\n";
135
-            return true;
136
-        }
137
-        /*
115
+	/**
116
+	 * @param EE_Registration  $registration
117
+	 * @param string           $reg_url_link
118
+	 * @param int|string       $field the form input name
119
+	 * @param float|int|string $value the input value
120
+	 * @return bool
121
+	 * @throws EE_Error
122
+	 * @throws InvalidArgumentException
123
+	 * @throws InvalidDataTypeException
124
+	 * @throws InvalidInterfaceException
125
+	 * @throws ReflectionException
126
+	 */
127
+	protected function saveRegistrationFormInput(
128
+		EE_Registration $registration,
129
+		string $reg_url_link,
130
+		$field = '',
131
+		$value = ''
132
+	): bool {
133
+		if ($this->bypassSaveRegFormInputValue($registration, $field, $value)) {
134
+			echo "\n#############################################################\n";
135
+			return true;
136
+		}
137
+		/*
138 138
          * $answer_cache_id is the key used to find the EE_Answer we want
139 139
          * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477
140 140
          */
141
-        $answer_cache_id   = $this->checkout_reg_url_link
142
-            ? $field . '-' . $reg_url_link
143
-            : $field;
144
-        $registrant_answer = $this->registrant_data->getRegistrantAnswer($reg_url_link, $answer_cache_id);
145
-        $answer_is_obj     = $registrant_answer instanceof EE_Answer;
146
-        // if this form input has a corresponding attendee property
147
-        if ($this->isAttendeeProperty($field)) {
148
-            $this->saveAttendeeProperty($registration, $reg_url_link, $field, $value, $registrant_answer);
149
-            return true;
150
-        }
151
-        if ($answer_is_obj) {
152
-            // save this data to the answer object
153
-            $registrant_answer->set_value($value);
154
-            $result = $registrant_answer->save();
155
-            return $result !== false;
156
-        }
157
-        foreach ($this->registrant_data->registrantAnswers($reg_url_link) as $answer) {
158
-            if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
159
-                $answer->set_value($value);
160
-                $result = $answer->save();
161
-                return $result !== false;
162
-            }
163
-        }
164
-        return false;
165
-    }
141
+		$answer_cache_id   = $this->checkout_reg_url_link
142
+			? $field . '-' . $reg_url_link
143
+			: $field;
144
+		$registrant_answer = $this->registrant_data->getRegistrantAnswer($reg_url_link, $answer_cache_id);
145
+		$answer_is_obj     = $registrant_answer instanceof EE_Answer;
146
+		// if this form input has a corresponding attendee property
147
+		if ($this->isAttendeeProperty($field)) {
148
+			$this->saveAttendeeProperty($registration, $reg_url_link, $field, $value, $registrant_answer);
149
+			return true;
150
+		}
151
+		if ($answer_is_obj) {
152
+			// save this data to the answer object
153
+			$registrant_answer->set_value($value);
154
+			$result = $registrant_answer->save();
155
+			return $result !== false;
156
+		}
157
+		foreach ($this->registrant_data->registrantAnswers($reg_url_link) as $answer) {
158
+			if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
159
+				$answer->set_value($value);
160
+				$result = $answer->save();
161
+				return $result !== false;
162
+			}
163
+		}
164
+		return false;
165
+	}
166 166
 
167 167
 
168
-    /**
169
-     * @param EE_Registration $registration
170
-     * @param string          $field
171
-     * @param mixed           $value
172
-     * @return bool
173
-     */
174
-    protected function bypassSaveRegFormInputValue(EE_Registration $registration, string $field, $value): bool
175
-    {
176
-        // fields like the "email confirmation" input are sent, but not saved
177
-        if (in_array($field, $this->non_persistable_fields, true)) {
178
-            return true;
179
-        }
180
-        // allow for plugins to hook in and do their own processing of the form input.
181
-        // For plugins to bypass normal processing here, they just need to return a truthy value.
182
-        // NOTE: this hook does the opposite of what its name implies...
183
-        // ie: returning true does NOT save the input here, meaning it needs to be saved externally.
184
-        // This should have been named something like  "bypass_save_registration_form_input"
185
-        return filter_var(
186
-            apply_filters(
187
-                'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
188
-                false,
189
-                $registration,
190
-                $field,
191
-                $value,
192
-                $this
193
-            ),
194
-            FILTER_VALIDATE_BOOLEAN
195
-        );
196
-    }
168
+	/**
169
+	 * @param EE_Registration $registration
170
+	 * @param string          $field
171
+	 * @param mixed           $value
172
+	 * @return bool
173
+	 */
174
+	protected function bypassSaveRegFormInputValue(EE_Registration $registration, string $field, $value): bool
175
+	{
176
+		// fields like the "email confirmation" input are sent, but not saved
177
+		if (in_array($field, $this->non_persistable_fields, true)) {
178
+			return true;
179
+		}
180
+		// allow for plugins to hook in and do their own processing of the form input.
181
+		// For plugins to bypass normal processing here, they just need to return a truthy value.
182
+		// NOTE: this hook does the opposite of what its name implies...
183
+		// ie: returning true does NOT save the input here, meaning it needs to be saved externally.
184
+		// This should have been named something like  "bypass_save_registration_form_input"
185
+		return filter_var(
186
+			apply_filters(
187
+				'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
188
+				false,
189
+				$registration,
190
+				$field,
191
+				$value,
192
+				$this
193
+			),
194
+			FILTER_VALIDATE_BOOLEAN
195
+		);
196
+	}
197 197
 
198 198
 
199
-    /**
200
-     * @param string $field
201
-     * @return bool
202
-     */
203
-    private function isAttendeeProperty(string $field): bool
204
-    {
205
-        // \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
206
-        // \EEH_Debug_Tools::printr($field, '$field', __FILE__, __LINE__);
207
-        switch ($field) {
208
-            case 'state':
209
-            case 'STA_ID':
210
-            case 'country':
211
-            case 'CNT_ISO':
212
-                return true;
213
-            default:
214
-                return $this->attendee_model->has_field("ATT_$field");
215
-        }
216
-    }
199
+	/**
200
+	 * @param string $field
201
+	 * @return bool
202
+	 */
203
+	private function isAttendeeProperty(string $field): bool
204
+	{
205
+		// \EEH_Debug_Tools::printr(__FUNCTION__, __CLASS__, __FILE__, __LINE__, 2);
206
+		// \EEH_Debug_Tools::printr($field, '$field', __FILE__, __LINE__);
207
+		switch ($field) {
208
+			case 'state':
209
+			case 'STA_ID':
210
+			case 'country':
211
+			case 'CNT_ISO':
212
+				return true;
213
+			default:
214
+				return $this->attendee_model->has_field("ATT_$field");
215
+		}
216
+	}
217 217
 
218 218
 
219
-    /**
220
-     * @param string $field
221
-     * @return string
222
-     */
223
-    protected function renameFormInput(string $field): string
224
-    {
225
-        switch ($field) {
226
-            case 'state':
227
-            case 'STA_ID':
228
-                return 'STA_ID';
219
+	/**
220
+	 * @param string $field
221
+	 * @return string
222
+	 */
223
+	protected function renameFormInput(string $field): string
224
+	{
225
+		switch ($field) {
226
+			case 'state':
227
+			case 'STA_ID':
228
+				return 'STA_ID';
229 229
 
230
-            case 'country':
231
-            case 'CNT_ISO':
232
-                return 'CNT_ISO';
230
+			case 'country':
231
+			case 'CNT_ISO':
232
+				return 'CNT_ISO';
233 233
 
234
-            default:
235
-                return "ATT_$field";
236
-        }
237
-    }
234
+			default:
235
+				return "ATT_$field";
236
+		}
237
+	}
238 238
 
239 239
 
240
-    /**
241
-     * @param EE_Registration $registration
242
-     * @param string          $reg_url_link
243
-     * @param string          $field
244
-     * @param                 $value
245
-     * @param                 $registrant_answer
246
-     * @throws EE_Error
247
-     * @throws ReflectionException
248
-     */
249
-    protected function saveAttendeeProperty(
250
-        EE_Registration $registration,
251
-        string $reg_url_link,
252
-        string $field,
253
-        $value,
254
-        $registrant_answer
255
-    ) {
256
-        // rename form_inputs if they are EE_Attendee properties
257
-        $field = $this->renameFormInput($field);
258
-        $this->registrant_data->addRegistrantDataValue($reg_url_link, $field, $value);
259
-        if ($registrant_answer instanceof EE_Answer) {
260
-            // and delete the corresponding answer since we won't be storing this data in that object
261
-            $registration->_remove_relation_to($registrant_answer, 'Answer');
262
-            $registrant_answer->delete_permanently();
263
-        }
264
-    }
240
+	/**
241
+	 * @param EE_Registration $registration
242
+	 * @param string          $reg_url_link
243
+	 * @param string          $field
244
+	 * @param                 $value
245
+	 * @param                 $registrant_answer
246
+	 * @throws EE_Error
247
+	 * @throws ReflectionException
248
+	 */
249
+	protected function saveAttendeeProperty(
250
+		EE_Registration $registration,
251
+		string $reg_url_link,
252
+		string $field,
253
+		$value,
254
+		$registrant_answer
255
+	) {
256
+		// rename form_inputs if they are EE_Attendee properties
257
+		$field = $this->renameFormInput($field);
258
+		$this->registrant_data->addRegistrantDataValue($reg_url_link, $field, $value);
259
+		if ($registrant_answer instanceof EE_Answer) {
260
+			// and delete the corresponding answer since we won't be storing this data in that object
261
+			$registration->_remove_relation_to($registrant_answer, 'Answer');
262
+			$registrant_answer->delete_permanently();
263
+		}
264
+	}
265 265
 
266 266
 
267
-    /**
268
-     * @param int|string       $form_input
269
-     * @param float|int|string $input_value
270
-     * @return boolean
271
-     */
272
-    private function verifyCriticalAttendeeDetailsAreSetAndValidateEmail(
273
-        $form_input = '',
274
-        $input_value = ''
275
-    ): bool {
276
-        if (empty($input_value)) {
277
-            // if the form input isn't marked as being required, then just return
278
-            if (! isset($this->required_questions[ $form_input ]) || ! $this->required_questions[ $form_input ]) {
279
-                return true;
280
-            }
281
-            switch ($form_input) {
282
-                case 'fname':
283
-                    EE_Error::add_error(
284
-                        esc_html__('First Name is a required value.', 'event_espresso'),
285
-                        __FILE__,
286
-                        __FUNCTION__,
287
-                        __LINE__
288
-                    );
289
-                    return false;
290
-                case 'lname':
291
-                    EE_Error::add_error(
292
-                        esc_html__('Last Name is a required value.', 'event_espresso'),
293
-                        __FILE__,
294
-                        __FUNCTION__,
295
-                        __LINE__
296
-                    );
297
-                    return false;
298
-                case 'email':
299
-                    EE_Error::add_error(
300
-                        esc_html__('Please enter a valid email address.', 'event_espresso'),
301
-                        __FILE__,
302
-                        __FUNCTION__,
303
-                        __LINE__
304
-                    );
305
-                    return false;
306
-            }
307
-        }
308
-        return true;
309
-    }
267
+	/**
268
+	 * @param int|string       $form_input
269
+	 * @param float|int|string $input_value
270
+	 * @return boolean
271
+	 */
272
+	private function verifyCriticalAttendeeDetailsAreSetAndValidateEmail(
273
+		$form_input = '',
274
+		$input_value = ''
275
+	): bool {
276
+		if (empty($input_value)) {
277
+			// if the form input isn't marked as being required, then just return
278
+			if (! isset($this->required_questions[ $form_input ]) || ! $this->required_questions[ $form_input ]) {
279
+				return true;
280
+			}
281
+			switch ($form_input) {
282
+				case 'fname':
283
+					EE_Error::add_error(
284
+						esc_html__('First Name is a required value.', 'event_espresso'),
285
+						__FILE__,
286
+						__FUNCTION__,
287
+						__LINE__
288
+					);
289
+					return false;
290
+				case 'lname':
291
+					EE_Error::add_error(
292
+						esc_html__('Last Name is a required value.', 'event_espresso'),
293
+						__FILE__,
294
+						__FUNCTION__,
295
+						__LINE__
296
+					);
297
+					return false;
298
+				case 'email':
299
+					EE_Error::add_error(
300
+						esc_html__('Please enter a valid email address.', 'event_espresso'),
301
+						__FILE__,
302
+						__FUNCTION__,
303
+						__LINE__
304
+					);
305
+					return false;
306
+			}
307
+		}
308
+		return true;
309
+	}
310 310
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         $value
82 82
     ): bool {
83 83
         // check for critical inputs
84
-        if (! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($field, $value)) {
84
+        if ( ! $this->verifyCriticalAttendeeDetailsAreSetAndValidateEmail($field, $value)) {
85 85
             echo "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
86 86
             return false;
87 87
         }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
             $value
92 92
         );
93 93
         \EEH_Debug_Tools::printr($value, ' value >>====> ', __FILE__, __LINE__);
94
-        if (! $this->saveRegistrationFormInput($registration, $reg_url_link, $field, $value)) {
94
+        if ( ! $this->saveRegistrationFormInput($registration, $reg_url_link, $field, $value)) {
95 95
             EE_Error::add_error(
96 96
                 sprintf(
97 97
                     esc_html_x(
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
          * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477
140 140
          */
141 141
         $answer_cache_id   = $this->checkout_reg_url_link
142
-            ? $field . '-' . $reg_url_link
142
+            ? $field.'-'.$reg_url_link
143 143
             : $field;
144 144
         $registrant_answer = $this->registrant_data->getRegistrantAnswer($reg_url_link, $answer_cache_id);
145 145
         $answer_is_obj     = $registrant_answer instanceof EE_Answer;
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
     ): bool {
276 276
         if (empty($input_value)) {
277 277
             // if the form input isn't marked as being required, then just return
278
-            if (! isset($this->required_questions[ $form_input ]) || ! $this->required_questions[ $form_input ]) {
278
+            if ( ! isset($this->required_questions[$form_input]) || ! $this->required_questions[$form_input]) {
279 279
                 return true;
280 280
             }
281 281
             switch ($form_input) {
Please login to merge, or discard this patch.