Completed
Branch master (8de7dd)
by
unknown
06:29
created
core/domain/services/registration/form/v1/RegFormQuestionFactory.php 2 patches
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -15,113 +15,113 @@
 block discarded – undo
15 15
 
16 16
 class RegFormQuestionFactory
17 17
 {
18
-    /**
19
-     * @var callable
20
-     */
21
-    protected $addRequiredQuestion;
18
+	/**
19
+	 * @var callable
20
+	 */
21
+	protected $addRequiredQuestion;
22 22
 
23
-    public EEM_Answer $answer_model;
23
+	public EEM_Answer $answer_model;
24 24
 
25 25
 
26
-    /**
27
-     * @param callable   $addRequiredQuestion
28
-     * @param EEM_Answer $answer_model
29
-     */
30
-    public function __construct(callable $addRequiredQuestion, EEM_Answer $answer_model)
31
-    {
32
-        $this->addRequiredQuestion = $addRequiredQuestion;
33
-        $this->answer_model        = $answer_model;
34
-    }
26
+	/**
27
+	 * @param callable   $addRequiredQuestion
28
+	 * @param EEM_Answer $answer_model
29
+	 */
30
+	public function __construct(callable $addRequiredQuestion, EEM_Answer $answer_model)
31
+	{
32
+		$this->addRequiredQuestion = $addRequiredQuestion;
33
+		$this->answer_model        = $answer_model;
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     * @param EE_Registration $registration
39
-     * @param EE_Question     $question
40
-     * @return EE_Form_Input_Base
41
-     * @throws EE_Error
42
-     * @throws InvalidArgumentException
43
-     * @throws InvalidDataTypeException
44
-     * @throws InvalidInterfaceException
45
-     * @throws ReflectionException
46
-     */
47
-    public function create(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base
48
-    {
49
-        // if this question was for an attendee detail, then check for that answer
50
-        $answer_value = $this->answer_model->get_attendee_property_answer_value(
51
-            $registration,
52
-            $question->system_ID()
53
-        );
54
-        $answer       = $answer_value === null
55
-            ? $this->answer_model->get_one(
56
-                [['QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()]]
57
-            )
58
-            : null;
59
-        // if NOT returning to edit an existing registration
60
-        // OR if this question is for an attendee property
61
-        // OR we still don't have an EE_Answer object
62
-        if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
63
-            // create an EE_Answer object for storing everything in
64
-            $answer = EE_Answer::new_instance(
65
-                [
66
-                    'QST_ID' => $question->ID(),
67
-                    'REG_ID' => $registration->ID(),
68
-                ]
69
-            );
70
-        }
71
-        // verify instance
72
-        if ($answer instanceof EE_Answer) {
73
-            if (! empty($answer_value)) {
74
-                $answer->set('ANS_value', $answer_value);
75
-            }
76
-            $answer->cache('Question', $question);
77
-            // remember system ID had a bug where sometimes it could be null
78
-            $answer_cache_id = $question->is_system_question()
79
-                ? $question->system_ID() . '-' . $registration->reg_url_link()
80
-                : $question->ID() . '-' . $registration->reg_url_link();
81
-            $registration->cache('Answer', $answer, $answer_cache_id);
82
-        }
83
-        return $this->generateQuestionInput($registration, $question, $answer);
84
-    }
37
+	/**
38
+	 * @param EE_Registration $registration
39
+	 * @param EE_Question     $question
40
+	 * @return EE_Form_Input_Base
41
+	 * @throws EE_Error
42
+	 * @throws InvalidArgumentException
43
+	 * @throws InvalidDataTypeException
44
+	 * @throws InvalidInterfaceException
45
+	 * @throws ReflectionException
46
+	 */
47
+	public function create(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base
48
+	{
49
+		// if this question was for an attendee detail, then check for that answer
50
+		$answer_value = $this->answer_model->get_attendee_property_answer_value(
51
+			$registration,
52
+			$question->system_ID()
53
+		);
54
+		$answer       = $answer_value === null
55
+			? $this->answer_model->get_one(
56
+				[['QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()]]
57
+			)
58
+			: null;
59
+		// if NOT returning to edit an existing registration
60
+		// OR if this question is for an attendee property
61
+		// OR we still don't have an EE_Answer object
62
+		if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
63
+			// create an EE_Answer object for storing everything in
64
+			$answer = EE_Answer::new_instance(
65
+				[
66
+					'QST_ID' => $question->ID(),
67
+					'REG_ID' => $registration->ID(),
68
+				]
69
+			);
70
+		}
71
+		// verify instance
72
+		if ($answer instanceof EE_Answer) {
73
+			if (! empty($answer_value)) {
74
+				$answer->set('ANS_value', $answer_value);
75
+			}
76
+			$answer->cache('Question', $question);
77
+			// remember system ID had a bug where sometimes it could be null
78
+			$answer_cache_id = $question->is_system_question()
79
+				? $question->system_ID() . '-' . $registration->reg_url_link()
80
+				: $question->ID() . '-' . $registration->reg_url_link();
81
+			$registration->cache('Answer', $answer, $answer_cache_id);
82
+		}
83
+		return $this->generateQuestionInput($registration, $question, $answer);
84
+	}
85 85
 
86 86
 
87
-    /**
88
-     * @param EE_Registration $registration
89
-     * @param EE_Question     $question
90
-     * @param                 $answer
91
-     * @return EE_Form_Input_Base
92
-     * @throws EE_Error
93
-     * @throws InvalidArgumentException
94
-     * @throws ReflectionException
95
-     * @throws InvalidDataTypeException
96
-     * @throws InvalidInterfaceException
97
-     */
98
-    private function generateQuestionInput(
99
-        EE_Registration $registration,
100
-        EE_Question $question,
101
-        $answer
102
-    ): EE_Form_Input_Base {
103
-        $identifier = $question->is_system_question()
104
-            ? $question->system_ID()
105
-            : $question->ID();
106
-        $callback   = $this->addRequiredQuestion;
107
-        $callback($identifier, $question->required());
108
-        $input_constructor_args                  = [
109
-            'html_name'        => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
110
-            'html_id'          => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
111
-            'html_class'       => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
112
-            'html_label_id'    => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
113
-            'html_label_class' => 'ee-reg-qstn',
114
-        ];
115
-        $input_constructor_args['html_label_id'] .= '-lbl';
116
-        if ($answer instanceof EE_Answer && $answer->ID()) {
117
-            $input_constructor_args['html_name']     .= '[' . $answer->ID() . ']';
118
-            $input_constructor_args['html_id']       .= '-' . $answer->ID();
119
-            $input_constructor_args['html_label_id'] .= '-' . $answer->ID();
120
-        }
121
-        return $question->generate_form_input(
122
-            $registration,
123
-            $answer,
124
-            $input_constructor_args
125
-        );
126
-    }
87
+	/**
88
+	 * @param EE_Registration $registration
89
+	 * @param EE_Question     $question
90
+	 * @param                 $answer
91
+	 * @return EE_Form_Input_Base
92
+	 * @throws EE_Error
93
+	 * @throws InvalidArgumentException
94
+	 * @throws ReflectionException
95
+	 * @throws InvalidDataTypeException
96
+	 * @throws InvalidInterfaceException
97
+	 */
98
+	private function generateQuestionInput(
99
+		EE_Registration $registration,
100
+		EE_Question $question,
101
+		$answer
102
+	): EE_Form_Input_Base {
103
+		$identifier = $question->is_system_question()
104
+			? $question->system_ID()
105
+			: $question->ID();
106
+		$callback   = $this->addRequiredQuestion;
107
+		$callback($identifier, $question->required());
108
+		$input_constructor_args                  = [
109
+			'html_name'        => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
110
+			'html_id'          => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
111
+			'html_class'       => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
112
+			'html_label_id'    => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
113
+			'html_label_class' => 'ee-reg-qstn',
114
+		];
115
+		$input_constructor_args['html_label_id'] .= '-lbl';
116
+		if ($answer instanceof EE_Answer && $answer->ID()) {
117
+			$input_constructor_args['html_name']     .= '[' . $answer->ID() . ']';
118
+			$input_constructor_args['html_id']       .= '-' . $answer->ID();
119
+			$input_constructor_args['html_label_id'] .= '-' . $answer->ID();
120
+		}
121
+		return $question->generate_form_input(
122
+			$registration,
123
+			$answer,
124
+			$input_constructor_args
125
+		);
126
+	}
127 127
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             $registration,
52 52
             $question->system_ID()
53 53
         );
54
-        $answer       = $answer_value === null
54
+        $answer = $answer_value === null
55 55
             ? $this->answer_model->get_one(
56 56
                 [['QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()]]
57 57
             )
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
         }
71 71
         // verify instance
72 72
         if ($answer instanceof EE_Answer) {
73
-            if (! empty($answer_value)) {
73
+            if ( ! empty($answer_value)) {
74 74
                 $answer->set('ANS_value', $answer_value);
75 75
             }
76 76
             $answer->cache('Question', $question);
77 77
             // remember system ID had a bug where sometimes it could be null
78 78
             $answer_cache_id = $question->is_system_question()
79
-                ? $question->system_ID() . '-' . $registration->reg_url_link()
80
-                : $question->ID() . '-' . $registration->reg_url_link();
79
+                ? $question->system_ID().'-'.$registration->reg_url_link()
80
+                : $question->ID().'-'.$registration->reg_url_link();
81 81
             $registration->cache('Answer', $answer, $answer_cache_id);
82 82
         }
83 83
         return $this->generateQuestionInput($registration, $question, $answer);
@@ -105,18 +105,18 @@  discard block
 block discarded – undo
105 105
             : $question->ID();
106 106
         $callback   = $this->addRequiredQuestion;
107 107
         $callback($identifier, $question->required());
108
-        $input_constructor_args                  = [
109
-            'html_name'        => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
110
-            'html_id'          => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
111
-            'html_class'       => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
112
-            'html_label_id'    => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
108
+        $input_constructor_args = [
109
+            'html_name'        => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']',
110
+            'html_id'          => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
111
+            'html_class'       => 'ee-reg-qstn ee-reg-qstn-'.$identifier,
112
+            'html_label_id'    => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
113 113
             'html_label_class' => 'ee-reg-qstn',
114 114
         ];
115 115
         $input_constructor_args['html_label_id'] .= '-lbl';
116 116
         if ($answer instanceof EE_Answer && $answer->ID()) {
117
-            $input_constructor_args['html_name']     .= '[' . $answer->ID() . ']';
118
-            $input_constructor_args['html_id']       .= '-' . $answer->ID();
119
-            $input_constructor_args['html_label_id'] .= '-' . $answer->ID();
117
+            $input_constructor_args['html_name']     .= '['.$answer->ID().']';
118
+            $input_constructor_args['html_id']       .= '-'.$answer->ID();
119
+            $input_constructor_args['html_label_id'] .= '-'.$answer->ID();
120 120
         }
121 121
         return $question->generate_form_input(
122 122
             $registration,
Please login to merge, or discard this patch.
core/domain/services/registration/form/v1/RegFormDependencyHandler.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -7,62 +7,62 @@
 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\v1\RegForm'             => [
17
-                null,
18
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
19
-            ],
20
-            'EventEspresso\core\domain\services\registration\form\v1\subsections\AttendeeRegForm' => [
21
-                null,
22
-                null,
23
-                null,
24
-                null,
25
-                null,
26
-                'EEM_Event_Question_Group' => EE_Dependency_Map::load_from_cache,
27
-            ],
28
-            'EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory' => [
29
-                null,
30
-                'EEM_Answer' => EE_Dependency_Map::load_from_cache,
31
-            ],
32
-            'EventEspresso\core\domain\services\registration\form\v1\subsections\RegFormQuestions' => [
33
-                null,
34
-                null,
35
-                null,
36
-                'EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory' => EE_Dependency_Map::load_from_cache,
37
-            ],
38
-            'EventEspresso\core\domain\services\registration\form\utilities\CountryOptions' => [
39
-                null,
40
-                'EEM_Answer'  => EE_Dependency_Map::load_from_cache,
41
-                'EEM_Country' => EE_Dependency_Map::load_from_cache,
42
-            ],
43
-            'EventEspresso\core\domain\services\registration\form\utilities\StateOptions' => [
44
-                null,
45
-                'EEM_State' => EE_Dependency_Map::load_from_cache,
46
-            ],
47
-            'EventEspresso\core\domain\services\registration\form\v1\RegFormHandler'         => [
48
-                null,
49
-                'EventEspresso\core\domain\services\registration\form\v1\RegistrantData'         => EE_Dependency_Map::load_from_cache,
50
-                'EventEspresso\core\domain\services\registration\form\v1\RegFormAttendeeFactory' => EE_Dependency_Map::load_from_cache,
51
-                'EE_Registration_Processor'                                                      => EE_Dependency_Map::load_from_cache,
52
-            ],
53
-            'EventEspresso\core\domain\services\registration\form\v1\RegFormInputHandler'    => [
54
-                null,
55
-                null,
56
-                'EEM_Attendee'                                                           => EE_Dependency_Map::load_from_cache,
57
-                'EventEspresso\core\domain\services\registration\form\v1\RegistrantData' => EE_Dependency_Map::load_from_cache,
58
-            ],
59
-            'EventEspresso\core\domain\services\registration\form\v1\RegFormAttendeeFactory' => [
60
-                'EventEspresso\core\services\commands\CommandBus'                        => EE_Dependency_Map::load_from_cache,
61
-                'EventEspresso\core\domain\services\registration\form\v1\RegistrantData' => EE_Dependency_Map::load_from_cache,
62
-            ],
63
-        ];
64
-        foreach ($reg_form_dependencies as $class => $dependencies) {
65
-            $this->dependency_map->registerDependencies($class, $dependencies);
66
-        }
67
-    }
10
+	/**
11
+	 * @return void
12
+	 */
13
+	public function registerDependencies()
14
+	{
15
+		$reg_form_dependencies = [
16
+			'EventEspresso\core\domain\services\registration\form\v1\RegForm'             => [
17
+				null,
18
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
19
+			],
20
+			'EventEspresso\core\domain\services\registration\form\v1\subsections\AttendeeRegForm' => [
21
+				null,
22
+				null,
23
+				null,
24
+				null,
25
+				null,
26
+				'EEM_Event_Question_Group' => EE_Dependency_Map::load_from_cache,
27
+			],
28
+			'EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory' => [
29
+				null,
30
+				'EEM_Answer' => EE_Dependency_Map::load_from_cache,
31
+			],
32
+			'EventEspresso\core\domain\services\registration\form\v1\subsections\RegFormQuestions' => [
33
+				null,
34
+				null,
35
+				null,
36
+				'EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory' => EE_Dependency_Map::load_from_cache,
37
+			],
38
+			'EventEspresso\core\domain\services\registration\form\utilities\CountryOptions' => [
39
+				null,
40
+				'EEM_Answer'  => EE_Dependency_Map::load_from_cache,
41
+				'EEM_Country' => EE_Dependency_Map::load_from_cache,
42
+			],
43
+			'EventEspresso\core\domain\services\registration\form\utilities\StateOptions' => [
44
+				null,
45
+				'EEM_State' => EE_Dependency_Map::load_from_cache,
46
+			],
47
+			'EventEspresso\core\domain\services\registration\form\v1\RegFormHandler'         => [
48
+				null,
49
+				'EventEspresso\core\domain\services\registration\form\v1\RegistrantData'         => EE_Dependency_Map::load_from_cache,
50
+				'EventEspresso\core\domain\services\registration\form\v1\RegFormAttendeeFactory' => EE_Dependency_Map::load_from_cache,
51
+				'EE_Registration_Processor'                                                      => EE_Dependency_Map::load_from_cache,
52
+			],
53
+			'EventEspresso\core\domain\services\registration\form\v1\RegFormInputHandler'    => [
54
+				null,
55
+				null,
56
+				'EEM_Attendee'                                                           => EE_Dependency_Map::load_from_cache,
57
+				'EventEspresso\core\domain\services\registration\form\v1\RegistrantData' => EE_Dependency_Map::load_from_cache,
58
+			],
59
+			'EventEspresso\core\domain\services\registration\form\v1\RegFormAttendeeFactory' => [
60
+				'EventEspresso\core\services\commands\CommandBus'                        => EE_Dependency_Map::load_from_cache,
61
+				'EventEspresso\core\domain\services\registration\form\v1\RegistrantData' => EE_Dependency_Map::load_from_cache,
62
+			],
63
+		];
64
+		foreach ($reg_form_dependencies as $class => $dependencies) {
65
+			$this->dependency_map->registerDependencies($class, $dependencies);
66
+		}
67
+	}
68 68
 }
Please login to merge, or discard this patch.
core/domain/services/registration/form/v1/RegistrantData.php 2 patches
Indentation   +330 added lines, -330 removed lines patch added patch discarded remove patch
@@ -18,334 +18,334 @@
 block discarded – undo
18 18
  */
19 19
 class RegistrantData
20 20
 {
21
-    private int $attendee_counter = 0;
22
-
23
-    private array $registrant_data = [];
24
-
25
-    private bool $copy_primary = false;
26
-
27
-    private array $required_questions = [];
28
-
29
-    /**
30
-     * @var EE_Registration[]
31
-     */
32
-    private array $registrations = [];
33
-
34
-    /**
35
-     * @var EE_Answer[][]
36
-     */
37
-    private array $registrant_answers = [];
38
-
39
-    /**
40
-     * array for tracking reg form data for the primary registrant
41
-     *
42
-     * @var array
43
-     */
44
-    private array $primary_registrant_data = ['line_item_id' => null];
45
-
46
-    /**
47
-     * the attendee object created for the primary registrant
48
-     *
49
-     * @var EE_Attendee|null
50
-     */
51
-    private ?EE_Attendee $primary_registrant = null;
52
-
53
-
54
-    /**
55
-     * @param EE_Registration $registration
56
-     * @throws EE_Error
57
-     * @throws ReflectionException
58
-     */
59
-    public function initializeRegistrantData(EE_Registration $registration): void
60
-    {
61
-        $reg_url_link = $registration->reg_url_link();
62
-        $this->registrations[ $reg_url_link ] = $registration;
63
-        $this->registrant_answers[ $reg_url_link ] = $registration->answers();
64
-        $this->registrant_data[ $reg_url_link ] = [];
65
-        $this->attendee_counter++;
66
-    }
67
-
68
-
69
-    /**
70
-     * @return int
71
-     */
72
-    public function attendeeCount(): int
73
-    {
74
-        return $this->attendee_counter;
75
-    }
76
-
77
-
78
-    /**
79
-     * @return bool
80
-     */
81
-    public function copyPrimary(): bool
82
-    {
83
-        return $this->copy_primary;
84
-    }
85
-
86
-
87
-    /**
88
-     * @param bool $copy_primary
89
-     */
90
-    public function setCopyPrimary(bool $copy_primary): void
91
-    {
92
-        $this->copy_primary = filter_var($copy_primary, FILTER_VALIDATE_BOOLEAN);
93
-    }
94
-
95
-
96
-    /**
97
-     * @param string $reg_url_link
98
-     * @return array|null
99
-     */
100
-    public function getRegistrant(string $reg_url_link): ?EE_Registration
101
-    {
102
-        return $this->registrations[ $reg_url_link ] ?? null;
103
-    }
104
-
105
-
106
-    /**
107
-     * @param string $reg_url_link
108
-     * @return array|null
109
-     */
110
-    public function getRegistrantData(string $reg_url_link): ?array
111
-    {
112
-        return $this->registrant_data[ $reg_url_link ] ?? null;
113
-    }
114
-
115
-
116
-    /**
117
-     * @param string $reg_url_link
118
-     * @param string $key
119
-     * @param mixed $value
120
-     */
121
-    public function addRegistrantDataValue(string $reg_url_link, string $key, $value): void
122
-    {
123
-        $this->registrant_data[ $reg_url_link ][ $key ] = $value;
124
-    }
125
-
126
-
127
-    /**
128
-     * ensures that all attendees at least have data for first name, last name, and email address
129
-     *
130
-     * @param string $reg_url_link
131
-     * @throws EE_Error
132
-     * @throws ReflectionException
133
-     */
134
-    public function ensureCriticalRegistrantDataIsSet(string $reg_url_link): void
135
-    {
136
-        if ($this->currentRegistrantIsPrimary()) {
137
-            return;
138
-        }
139
-        // bare minimum critical details include first name, last name, email address
140
-        $critical_attendee_details = ['ATT_fname', 'ATT_lname', 'ATT_email'];
141
-        // add address info to critical details?
142
-        if (
143
-            apply_filters(
144
-                'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantData__ensureCriticalRegistrantDataIsSet',
145
-                false
146
-            )
147
-        ) {
148
-            $critical_attendee_details += [
149
-                'ATT_address',
150
-                'ATT_address2',
151
-                'ATT_city',
152
-                'STA_ID',
153
-                'CNT_ISO',
154
-                'ATT_zip',
155
-                'ATT_phone',
156
-            ];
157
-        }
158
-        foreach ($critical_attendee_details as $critical_attendee_detail) {
159
-            if (
160
-                ! isset($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ])
161
-                || empty($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ])
162
-            ) {
163
-                $this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ] = $this->primary_registrant->get(
164
-                    $critical_attendee_detail
165
-                );
166
-            }
167
-        }
168
-    }
169
-
170
-
171
-    /**
172
-     * @param string $reg_url_link
173
-     * @param array $registrant_data
174
-     */
175
-    public function setRegistrantData(string $reg_url_link, array $registrant_data): void
176
-    {
177
-        $this->registrant_data[ $reg_url_link ] = $registrant_data;
178
-    }
179
-
180
-
181
-    /**
182
-     * @return array
183
-     */
184
-    public function getRequiredQuestions(): array
185
-    {
186
-        return $this->required_questions;
187
-    }
188
-
189
-
190
-    /**
191
-     * @param string $identifier
192
-     * @param string $required_question
193
-     */
194
-    public function addRequiredQuestion(string $identifier, string $required_question): void
195
-    {
196
-        $this->required_questions[ $identifier ] = $required_question;
197
-    }
198
-
199
-
200
-    /**
201
-     * @return EE_Answer[]
202
-     */
203
-    public function registrantAnswers(string $reg_url_link): array
204
-    {
205
-        return $this->registrant_answers[ $reg_url_link ] ?? [];
206
-    }
207
-
208
-
209
-    /**
210
-     * @param string $reg_url_link
211
-     * @param string $identifier  the answer cache ID
212
-     * @param EE_Answer $answer
213
-     */
214
-    public function addRegistrantAnswer(string $reg_url_link, string $identifier, EE_Answer $answer): void
215
-    {
216
-        $this->registrant_answers[ $reg_url_link ][ $identifier ] = $answer;
217
-    }
218
-
219
-
220
-    /**
221
-     * @param string $reg_url_link
222
-     * @param string $identifier
223
-     * @return EE_Answer|null
224
-     */
225
-    public function getRegistrantAnswer(string $reg_url_link, string $identifier): ?EE_Answer
226
-    {
227
-        return $this->registrant_answers[ $reg_url_link ][ $identifier ] ?? null;
228
-    }
229
-
230
-
231
-
232
-    /**
233
-     * @param string $reg_url_link
234
-     * @param string $identifier
235
-     * @return bool
236
-     */
237
-    public function registrantAnswerIsObject(string $reg_url_link, string $identifier): bool
238
-    {
239
-        $registrant_answer = $this->getRegistrantAnswer($reg_url_link, $identifier);
240
-        return $registrant_answer instanceof EE_Answer;
241
-    }
242
-
243
-
244
-    /**
245
-     * @return array
246
-     */
247
-    public function primaryRegistrantData(): array
248
-    {
249
-        return $this->primary_registrant_data;
250
-    }
251
-
252
-
253
-    /**
254
-     * @param string $key
255
-     * @param mixed  $value
256
-     */
257
-    public function addPrimaryRegistrantDataValue(string $key, $value): void
258
-    {
259
-        $this->primary_registrant_data[ $key ] = $value;
260
-    }
261
-
262
-
263
-    /**
264
-     * @param string $key
265
-     * @return mixed
266
-     */
267
-    public function getPrimaryRegistrantDataValue(string $key)
268
-    {
269
-        return $this->primary_registrant_data[ $key ] ?? null;
270
-    }
271
-
272
-
273
-    /**
274
-     * @param array $primary_registrant_data
275
-     */
276
-    public function setPrimaryRegistrantData(array $primary_registrant_data): void
277
-    {
278
-        $this->primary_registrant_data = $primary_registrant_data;
279
-    }
280
-
281
-
282
-    /**
283
-     * @return EE_Attendee
284
-     */
285
-    public function primaryRegistrant(): EE_Attendee
286
-    {
287
-        return $this->primary_registrant;
288
-    }
289
-
290
-
291
-    /**
292
-     * @return bool
293
-     */
294
-    public function primaryRegistrantIsValid(): bool
295
-    {
296
-        return $this->primary_registrant instanceof EE_Attendee;
297
-    }
298
-
299
-
300
-    /**
301
-     * @param EE_Attendee $primary_registrant
302
-     */
303
-    public function setPrimaryRegistrant(EE_Attendee $primary_registrant): void
304
-    {
305
-        $this->primary_registrant = $primary_registrant;
306
-    }
307
-
308
-
309
-    /**
310
-     * @param string $reg_url_link
311
-     * @return bool
312
-     */
313
-    public function currentRegistrantIsPrimary(string $reg_url_link = ''): bool
314
-    {
315
-        return $this->attendeeCount() === 1
316
-            || (
317
-                $reg_url_link !== ''
318
-                && $this->getPrimaryRegistrantDataValue('reg_url_link') === $reg_url_link
319
-            );
320
-    }
321
-
322
-
323
-    /**
324
-     * @return bool
325
-     */
326
-    public function currentRegistrantIsNotPrimary(): bool
327
-    {
328
-        return $this->attendeeCount() > 1;
329
-    }
330
-
331
-
332
-    /**
333
-     * @param string $reg_url_link
334
-     * @param string $form_input
335
-     * @param mixed  $input_value
336
-     * @return mixed|null
337
-     */
338
-    public function saveOrCopyPrimaryRegistrantData(string $reg_url_link, string $form_input, $input_value)
339
-    {
340
-        // store a bit of data about the primary attendee
341
-        if (! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) {
342
-            $this->primary_registrant_data[ $form_input ] = $input_value;
343
-            return $input_value;
344
-        }
345
-        // or copy value from primary if incoming value is not set
346
-        if ($input_value === null && $this->copyPrimary()) {
347
-            $input_value = $this->getPrimaryRegistrantDataValue($form_input);
348
-        }
349
-        return $input_value;
350
-    }
21
+	private int $attendee_counter = 0;
22
+
23
+	private array $registrant_data = [];
24
+
25
+	private bool $copy_primary = false;
26
+
27
+	private array $required_questions = [];
28
+
29
+	/**
30
+	 * @var EE_Registration[]
31
+	 */
32
+	private array $registrations = [];
33
+
34
+	/**
35
+	 * @var EE_Answer[][]
36
+	 */
37
+	private array $registrant_answers = [];
38
+
39
+	/**
40
+	 * array for tracking reg form data for the primary registrant
41
+	 *
42
+	 * @var array
43
+	 */
44
+	private array $primary_registrant_data = ['line_item_id' => null];
45
+
46
+	/**
47
+	 * the attendee object created for the primary registrant
48
+	 *
49
+	 * @var EE_Attendee|null
50
+	 */
51
+	private ?EE_Attendee $primary_registrant = null;
52
+
53
+
54
+	/**
55
+	 * @param EE_Registration $registration
56
+	 * @throws EE_Error
57
+	 * @throws ReflectionException
58
+	 */
59
+	public function initializeRegistrantData(EE_Registration $registration): void
60
+	{
61
+		$reg_url_link = $registration->reg_url_link();
62
+		$this->registrations[ $reg_url_link ] = $registration;
63
+		$this->registrant_answers[ $reg_url_link ] = $registration->answers();
64
+		$this->registrant_data[ $reg_url_link ] = [];
65
+		$this->attendee_counter++;
66
+	}
67
+
68
+
69
+	/**
70
+	 * @return int
71
+	 */
72
+	public function attendeeCount(): int
73
+	{
74
+		return $this->attendee_counter;
75
+	}
76
+
77
+
78
+	/**
79
+	 * @return bool
80
+	 */
81
+	public function copyPrimary(): bool
82
+	{
83
+		return $this->copy_primary;
84
+	}
85
+
86
+
87
+	/**
88
+	 * @param bool $copy_primary
89
+	 */
90
+	public function setCopyPrimary(bool $copy_primary): void
91
+	{
92
+		$this->copy_primary = filter_var($copy_primary, FILTER_VALIDATE_BOOLEAN);
93
+	}
94
+
95
+
96
+	/**
97
+	 * @param string $reg_url_link
98
+	 * @return array|null
99
+	 */
100
+	public function getRegistrant(string $reg_url_link): ?EE_Registration
101
+	{
102
+		return $this->registrations[ $reg_url_link ] ?? null;
103
+	}
104
+
105
+
106
+	/**
107
+	 * @param string $reg_url_link
108
+	 * @return array|null
109
+	 */
110
+	public function getRegistrantData(string $reg_url_link): ?array
111
+	{
112
+		return $this->registrant_data[ $reg_url_link ] ?? null;
113
+	}
114
+
115
+
116
+	/**
117
+	 * @param string $reg_url_link
118
+	 * @param string $key
119
+	 * @param mixed $value
120
+	 */
121
+	public function addRegistrantDataValue(string $reg_url_link, string $key, $value): void
122
+	{
123
+		$this->registrant_data[ $reg_url_link ][ $key ] = $value;
124
+	}
125
+
126
+
127
+	/**
128
+	 * ensures that all attendees at least have data for first name, last name, and email address
129
+	 *
130
+	 * @param string $reg_url_link
131
+	 * @throws EE_Error
132
+	 * @throws ReflectionException
133
+	 */
134
+	public function ensureCriticalRegistrantDataIsSet(string $reg_url_link): void
135
+	{
136
+		if ($this->currentRegistrantIsPrimary()) {
137
+			return;
138
+		}
139
+		// bare minimum critical details include first name, last name, email address
140
+		$critical_attendee_details = ['ATT_fname', 'ATT_lname', 'ATT_email'];
141
+		// add address info to critical details?
142
+		if (
143
+			apply_filters(
144
+				'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantData__ensureCriticalRegistrantDataIsSet',
145
+				false
146
+			)
147
+		) {
148
+			$critical_attendee_details += [
149
+				'ATT_address',
150
+				'ATT_address2',
151
+				'ATT_city',
152
+				'STA_ID',
153
+				'CNT_ISO',
154
+				'ATT_zip',
155
+				'ATT_phone',
156
+			];
157
+		}
158
+		foreach ($critical_attendee_details as $critical_attendee_detail) {
159
+			if (
160
+				! isset($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ])
161
+				|| empty($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ])
162
+			) {
163
+				$this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ] = $this->primary_registrant->get(
164
+					$critical_attendee_detail
165
+				);
166
+			}
167
+		}
168
+	}
169
+
170
+
171
+	/**
172
+	 * @param string $reg_url_link
173
+	 * @param array $registrant_data
174
+	 */
175
+	public function setRegistrantData(string $reg_url_link, array $registrant_data): void
176
+	{
177
+		$this->registrant_data[ $reg_url_link ] = $registrant_data;
178
+	}
179
+
180
+
181
+	/**
182
+	 * @return array
183
+	 */
184
+	public function getRequiredQuestions(): array
185
+	{
186
+		return $this->required_questions;
187
+	}
188
+
189
+
190
+	/**
191
+	 * @param string $identifier
192
+	 * @param string $required_question
193
+	 */
194
+	public function addRequiredQuestion(string $identifier, string $required_question): void
195
+	{
196
+		$this->required_questions[ $identifier ] = $required_question;
197
+	}
198
+
199
+
200
+	/**
201
+	 * @return EE_Answer[]
202
+	 */
203
+	public function registrantAnswers(string $reg_url_link): array
204
+	{
205
+		return $this->registrant_answers[ $reg_url_link ] ?? [];
206
+	}
207
+
208
+
209
+	/**
210
+	 * @param string $reg_url_link
211
+	 * @param string $identifier  the answer cache ID
212
+	 * @param EE_Answer $answer
213
+	 */
214
+	public function addRegistrantAnswer(string $reg_url_link, string $identifier, EE_Answer $answer): void
215
+	{
216
+		$this->registrant_answers[ $reg_url_link ][ $identifier ] = $answer;
217
+	}
218
+
219
+
220
+	/**
221
+	 * @param string $reg_url_link
222
+	 * @param string $identifier
223
+	 * @return EE_Answer|null
224
+	 */
225
+	public function getRegistrantAnswer(string $reg_url_link, string $identifier): ?EE_Answer
226
+	{
227
+		return $this->registrant_answers[ $reg_url_link ][ $identifier ] ?? null;
228
+	}
229
+
230
+
231
+
232
+	/**
233
+	 * @param string $reg_url_link
234
+	 * @param string $identifier
235
+	 * @return bool
236
+	 */
237
+	public function registrantAnswerIsObject(string $reg_url_link, string $identifier): bool
238
+	{
239
+		$registrant_answer = $this->getRegistrantAnswer($reg_url_link, $identifier);
240
+		return $registrant_answer instanceof EE_Answer;
241
+	}
242
+
243
+
244
+	/**
245
+	 * @return array
246
+	 */
247
+	public function primaryRegistrantData(): array
248
+	{
249
+		return $this->primary_registrant_data;
250
+	}
251
+
252
+
253
+	/**
254
+	 * @param string $key
255
+	 * @param mixed  $value
256
+	 */
257
+	public function addPrimaryRegistrantDataValue(string $key, $value): void
258
+	{
259
+		$this->primary_registrant_data[ $key ] = $value;
260
+	}
261
+
262
+
263
+	/**
264
+	 * @param string $key
265
+	 * @return mixed
266
+	 */
267
+	public function getPrimaryRegistrantDataValue(string $key)
268
+	{
269
+		return $this->primary_registrant_data[ $key ] ?? null;
270
+	}
271
+
272
+
273
+	/**
274
+	 * @param array $primary_registrant_data
275
+	 */
276
+	public function setPrimaryRegistrantData(array $primary_registrant_data): void
277
+	{
278
+		$this->primary_registrant_data = $primary_registrant_data;
279
+	}
280
+
281
+
282
+	/**
283
+	 * @return EE_Attendee
284
+	 */
285
+	public function primaryRegistrant(): EE_Attendee
286
+	{
287
+		return $this->primary_registrant;
288
+	}
289
+
290
+
291
+	/**
292
+	 * @return bool
293
+	 */
294
+	public function primaryRegistrantIsValid(): bool
295
+	{
296
+		return $this->primary_registrant instanceof EE_Attendee;
297
+	}
298
+
299
+
300
+	/**
301
+	 * @param EE_Attendee $primary_registrant
302
+	 */
303
+	public function setPrimaryRegistrant(EE_Attendee $primary_registrant): void
304
+	{
305
+		$this->primary_registrant = $primary_registrant;
306
+	}
307
+
308
+
309
+	/**
310
+	 * @param string $reg_url_link
311
+	 * @return bool
312
+	 */
313
+	public function currentRegistrantIsPrimary(string $reg_url_link = ''): bool
314
+	{
315
+		return $this->attendeeCount() === 1
316
+			|| (
317
+				$reg_url_link !== ''
318
+				&& $this->getPrimaryRegistrantDataValue('reg_url_link') === $reg_url_link
319
+			);
320
+	}
321
+
322
+
323
+	/**
324
+	 * @return bool
325
+	 */
326
+	public function currentRegistrantIsNotPrimary(): bool
327
+	{
328
+		return $this->attendeeCount() > 1;
329
+	}
330
+
331
+
332
+	/**
333
+	 * @param string $reg_url_link
334
+	 * @param string $form_input
335
+	 * @param mixed  $input_value
336
+	 * @return mixed|null
337
+	 */
338
+	public function saveOrCopyPrimaryRegistrantData(string $reg_url_link, string $form_input, $input_value)
339
+	{
340
+		// store a bit of data about the primary attendee
341
+		if (! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) {
342
+			$this->primary_registrant_data[ $form_input ] = $input_value;
343
+			return $input_value;
344
+		}
345
+		// or copy value from primary if incoming value is not set
346
+		if ($input_value === null && $this->copyPrimary()) {
347
+			$input_value = $this->getPrimaryRegistrantDataValue($form_input);
348
+		}
349
+		return $input_value;
350
+	}
351 351
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
     public function initializeRegistrantData(EE_Registration $registration): void
60 60
     {
61 61
         $reg_url_link = $registration->reg_url_link();
62
-        $this->registrations[ $reg_url_link ] = $registration;
63
-        $this->registrant_answers[ $reg_url_link ] = $registration->answers();
64
-        $this->registrant_data[ $reg_url_link ] = [];
62
+        $this->registrations[$reg_url_link] = $registration;
63
+        $this->registrant_answers[$reg_url_link] = $registration->answers();
64
+        $this->registrant_data[$reg_url_link] = [];
65 65
         $this->attendee_counter++;
66 66
     }
67 67
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function getRegistrant(string $reg_url_link): ?EE_Registration
101 101
     {
102
-        return $this->registrations[ $reg_url_link ] ?? null;
102
+        return $this->registrations[$reg_url_link] ?? null;
103 103
     }
104 104
 
105 105
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function getRegistrantData(string $reg_url_link): ?array
111 111
     {
112
-        return $this->registrant_data[ $reg_url_link ] ?? null;
112
+        return $this->registrant_data[$reg_url_link] ?? null;
113 113
     }
114 114
 
115 115
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public function addRegistrantDataValue(string $reg_url_link, string $key, $value): void
122 122
     {
123
-        $this->registrant_data[ $reg_url_link ][ $key ] = $value;
123
+        $this->registrant_data[$reg_url_link][$key] = $value;
124 124
     }
125 125
 
126 126
 
@@ -157,10 +157,10 @@  discard block
 block discarded – undo
157 157
         }
158 158
         foreach ($critical_attendee_details as $critical_attendee_detail) {
159 159
             if (
160
-                ! isset($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ])
161
-                || empty($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ])
160
+                ! isset($this->registrant_data[$reg_url_link][$critical_attendee_detail])
161
+                || empty($this->registrant_data[$reg_url_link][$critical_attendee_detail])
162 162
             ) {
163
-                $this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ] = $this->primary_registrant->get(
163
+                $this->registrant_data[$reg_url_link][$critical_attendee_detail] = $this->primary_registrant->get(
164 164
                     $critical_attendee_detail
165 165
                 );
166 166
             }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      */
175 175
     public function setRegistrantData(string $reg_url_link, array $registrant_data): void
176 176
     {
177
-        $this->registrant_data[ $reg_url_link ] = $registrant_data;
177
+        $this->registrant_data[$reg_url_link] = $registrant_data;
178 178
     }
179 179
 
180 180
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function addRequiredQuestion(string $identifier, string $required_question): void
195 195
     {
196
-        $this->required_questions[ $identifier ] = $required_question;
196
+        $this->required_questions[$identifier] = $required_question;
197 197
     }
198 198
 
199 199
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
      */
203 203
     public function registrantAnswers(string $reg_url_link): array
204 204
     {
205
-        return $this->registrant_answers[ $reg_url_link ] ?? [];
205
+        return $this->registrant_answers[$reg_url_link] ?? [];
206 206
     }
207 207
 
208 208
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      */
214 214
     public function addRegistrantAnswer(string $reg_url_link, string $identifier, EE_Answer $answer): void
215 215
     {
216
-        $this->registrant_answers[ $reg_url_link ][ $identifier ] = $answer;
216
+        $this->registrant_answers[$reg_url_link][$identifier] = $answer;
217 217
     }
218 218
 
219 219
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      */
225 225
     public function getRegistrantAnswer(string $reg_url_link, string $identifier): ?EE_Answer
226 226
     {
227
-        return $this->registrant_answers[ $reg_url_link ][ $identifier ] ?? null;
227
+        return $this->registrant_answers[$reg_url_link][$identifier] ?? null;
228 228
     }
229 229
 
230 230
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
      */
257 257
     public function addPrimaryRegistrantDataValue(string $key, $value): void
258 258
     {
259
-        $this->primary_registrant_data[ $key ] = $value;
259
+        $this->primary_registrant_data[$key] = $value;
260 260
     }
261 261
 
262 262
 
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
      */
267 267
     public function getPrimaryRegistrantDataValue(string $key)
268 268
     {
269
-        return $this->primary_registrant_data[ $key ] ?? null;
269
+        return $this->primary_registrant_data[$key] ?? null;
270 270
     }
271 271
 
272 272
 
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
     public function saveOrCopyPrimaryRegistrantData(string $reg_url_link, string $form_input, $input_value)
339 339
     {
340 340
         // store a bit of data about the primary attendee
341
-        if (! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) {
342
-            $this->primary_registrant_data[ $form_input ] = $input_value;
341
+        if ( ! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) {
342
+            $this->primary_registrant_data[$form_input] = $input_value;
343 343
             return $input_value;
344 344
         }
345 345
         // or copy value from primary if incoming value is not set
Please login to merge, or discard this patch.
core/domain/services/registration/CancelRegistrationForm.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -211,7 +211,7 @@
 block discarded – undo
211 211
 		 *  	"confirmation_code" => "01EF",
212 212
 		 *  	"ee-form-submit-registration_cancellations" => "Cancel Registration(s)",
213 213
 		 * ]
214
- 		 */
214
+		 */
215 215
 		$success = true;
216 216
 		foreach ($valid_data['registrations'] as $registrant) {
217 217
 			$reg_url_link = $registrant['reg_url_link'];
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
 						]
84 84
 					),
85 85
 					'required_input_notice'   => new EE_Form_Section_HTML(
86
-						EEH_HTML::br(2) .
86
+						EEH_HTML::br(2).
87 87
 						EEH_HTML::span(
88 88
 							esc_html__('* required field', 'event_espresso'),
89 89
 							'',
90 90
 							'ee-status-bg--info'
91
-						) .
91
+						).
92 92
 						EEH_HTML::br(2)
93 93
 					),
94 94
 					'cancel_registration'     => $this->generateSubmitButton(
@@ -216,14 +216,14 @@  discard block
 block discarded – undo
216 216
 		foreach ($valid_data['registrations'] as $registrant) {
217 217
 			$reg_url_link = $registrant['reg_url_link'];
218 218
 			$registration = EEM_Registration::instance()->get_registration_for_reg_url_link($reg_url_link);
219
-			if (! $registration instanceof EE_Registration) {
219
+			if ( ! $registration instanceof EE_Registration) {
220 220
 				return sprintf(
221 221
 					esc_html__(
222 222
 						'%1$sCould not find registration for the REG URL link: %2$s',
223 223
 						'event_espresso'
224 224
 					),
225 225
 					'<p class="ee-registrations-cancelled-pg ee-attention">',
226
-					$reg_url_link . '</p>'
226
+					$reg_url_link.'</p>'
227 227
 				);
228 228
 			}
229 229
 			if ($registration->status_ID() === RegStatus::CANCELLED) {
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 			);
248 248
 			$success = $updated && $success;
249 249
 		}
250
-		if (! $success) {
250
+		if ( ! $success) {
251 251
 			return sprintf(
252 252
 				esc_html__(
253 253
 					'%1$sAn error occurred and the one or more registrations could not be cancelled.%2$s',
Please login to merge, or discard this patch.
core/services/dependencies/DependencyHandler.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,16 +6,16 @@
 block discarded – undo
6 6
 
7 7
 abstract class DependencyHandler implements DependencyHandlerInterface
8 8
 {
9
-    protected EE_Dependency_Map $dependency_map;
9
+	protected EE_Dependency_Map $dependency_map;
10 10
 
11 11
 
12
-    /**
13
-     * DependencyHandler constructor.
14
-     *
15
-     * @param EE_Dependency_Map $dependency_map
16
-     */
17
-    public function __construct(EE_Dependency_Map $dependency_map)
18
-    {
19
-        $this->dependency_map = $dependency_map;
20
-    }
12
+	/**
13
+	 * DependencyHandler constructor.
14
+	 *
15
+	 * @param EE_Dependency_Map $dependency_map
16
+	 */
17
+	public function __construct(EE_Dependency_Map $dependency_map)
18
+	{
19
+		$this->dependency_map = $dependency_map;
20
+	}
21 21
 }
Please login to merge, or discard this patch.
core/services/container/Mirror.php 1 patch
Indentation   +341 added lines, -341 removed lines patch added patch discarded remove patch
@@ -19,345 +19,345 @@
 block discarded – undo
19 19
  */
20 20
 class Mirror
21 21
 {
22
-    /**
23
-     * @var ReflectionClass[]
24
-     */
25
-    private array $classes = [];
26
-
27
-    /**
28
-     * @var ReflectionMethod[]
29
-     */
30
-    private array $constructors = [];
31
-
32
-    /**
33
-     * @var ReflectionParameter[][]
34
-     */
35
-    private array $parameters = [];
36
-
37
-    /**
38
-     * @var ReflectionParameter[][]
39
-     */
40
-    private array $parameter_classes = [];
41
-
42
-    /**
43
-     * @var ReflectionProperty[][]
44
-     */
45
-    private array $properties = [];
46
-
47
-    /**
48
-     * @var ReflectionMethod[][]
49
-     */
50
-    private array $methods = [];
51
-
52
-    private array $default_properties = [];
53
-
54
-    private array $static_properties = [];
55
-
56
-
57
-    /**
58
-     * @param string $class_name
59
-     * @return ReflectionClass
60
-     * @throws ReflectionException
61
-     */
62
-    public function getReflectionClass(string $class_name): ReflectionClass
63
-    {
64
-        if (! isset($this->classes[ $class_name ])) {
65
-            $this->classes[ $class_name ] = new ReflectionClass($class_name);
66
-        }
67
-        return $this->classes[ $class_name ];
68
-    }
69
-
70
-
71
-    /**
72
-     * @param string $class_name
73
-     * @return ReflectionMethod|null
74
-     * @throws ReflectionException
75
-     */
76
-    public function getConstructor(string $class_name): ?ReflectionMethod
77
-    {
78
-        if (! isset($this->constructors[ $class_name ])) {
79
-            $reflection_class                  = $this->getReflectionClass($class_name);
80
-            $this->constructors[ $class_name ] = $reflection_class->getConstructor();
81
-        }
82
-        return $this->constructors[ $class_name ];
83
-    }
84
-
85
-
86
-    /**
87
-     * @param ReflectionClass $reflection_class
88
-     * @return ReflectionMethod|null
89
-     * @throws ReflectionException
90
-     */
91
-    public function getConstructorFromReflection(ReflectionClass $reflection_class): ?ReflectionMethod
92
-    {
93
-        return $this->getConstructor($reflection_class->getName());
94
-    }
95
-
96
-
97
-    /**
98
-     * @throws ReflectionException
99
-     */
100
-    public function getClassShortName(string $class_name): string
101
-    {
102
-        return $this->getReflectionClass($class_name)->getShortName();
103
-    }
104
-
105
-
106
-    /**
107
-     * @param string $class_name
108
-     * @return ReflectionParameter[]
109
-     * @throws ReflectionException
110
-     */
111
-    public function getParameters(string $class_name): array
112
-    {
113
-        if (! isset($this->parameters[ $class_name ])) {
114
-            $constructor                     = $this->getConstructor($class_name);
115
-            $this->parameters[ $class_name ] = $constructor->getParameters();
116
-        }
117
-        return $this->parameters[ $class_name ];
118
-    }
119
-
120
-
121
-    /**
122
-     * @param ReflectionClass $reflection_class
123
-     * @return ReflectionParameter[]
124
-     * @throws ReflectionException
125
-     */
126
-    public function getParametersFromReflection(ReflectionClass $reflection_class): array
127
-    {
128
-        return $this->getParameters($reflection_class->getName());
129
-    }
130
-
131
-
132
-    /**
133
-     * @param ReflectionMethod $constructor
134
-     * @return ReflectionParameter[]
135
-     * @throws ReflectionException
136
-     */
137
-    public function getParametersFromReflectionConstructor(ReflectionMethod $constructor): array
138
-    {
139
-        return $this->getParameters($constructor->getDeclaringClass());
140
-    }
141
-
142
-
143
-    /**
144
-     * returns array of ReflectionParameter objects for parameters that are NOT optional
145
-     *
146
-     * @param string $class_name
147
-     * @return ReflectionParameter[]
148
-     * @throws ReflectionException
149
-     */
150
-    public function getRequiredParameters(string $class_name): array
151
-    {
152
-        $required_parameters = [];
153
-        $parameters          = $this->getParameters($class_name);
154
-        foreach ($parameters as $parameter) {
155
-            if ($parameter instanceof ReflectionParameter && ! $parameter->isOptional()) {
156
-                $required_parameters[] = $parameter;
157
-            }
158
-        }
159
-        return $required_parameters;
160
-    }
161
-
162
-
163
-    /**
164
-     * @param ReflectionParameter $param
165
-     * @param string              $class_name
166
-     * @param string              $index
167
-     * @return string|null
168
-     */
169
-    public function getParameterClassName(ReflectionParameter $param, string $class_name, string $index): ?string
170
-    {
171
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
172
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
173
-        }
174
-        if (! isset($this->parameter_classes[ $class_name ])) {
175
-            $this->parameter_classes[ $class_name ] = [];
176
-        }
177
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
178
-            $this->parameter_classes[ $class_name ][ $index ] = [];
179
-        }
180
-        // ReflectionParameter::getClass() is deprecated in PHP 8+
181
-        $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = PHP_VERSION_ID < 70100
182
-            ? $this->getParameterClassNameLegacy($param)
183
-            : $this->getParameterClassNamePhp8($param);
184
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
185
-    }
186
-
187
-
188
-    /**
189
-     * @param ReflectionParameter $param
190
-     * @return string|null
191
-     * @since   4.10.13.p
192
-     */
193
-    private function getParameterClassNameLegacy(ReflectionParameter $param): ?string
194
-    {
195
-        $reflection_class = $param->getClass();
196
-        return $reflection_class instanceof ReflectionClass
197
-            ? $reflection_class->getName()
198
-            : null;
199
-    }
200
-
201
-
202
-    /**
203
-     * ReflectionParameter::getClass() is deprecated in PHP 8+,
204
-     * so the class name for a parameter needs to be extracted from the ReflectionType,
205
-     * which can either be a ReflectionNamedType or ReflectionUnionType
206
-     *
207
-     * @param ReflectionParameter $param
208
-     * @return string|null
209
-     * @since   4.10.13.p
210
-     */
211
-    private function getParameterClassNamePhp8(ReflectionParameter $param): ?string
212
-    {
213
-        $reflection_type = $param->getType();
214
-        if ($reflection_type instanceof \ReflectionNamedType) {
215
-            return $reflection_type->getName();
216
-        }
217
-        if ($reflection_type instanceof \ReflectionUnionType) {
218
-            $reflection_types = $reflection_type->getTypes();
219
-            if (is_array($reflection_types)) {
220
-                $first = reset($reflection_types);
221
-                return $first->getName();
222
-            }
223
-        }
224
-        return null;
225
-    }
226
-
227
-
228
-    /**
229
-     * @param ReflectionParameter $param
230
-     * @param string              $class_name
231
-     * @param string              $index
232
-     * @return array|string|null
233
-     */
234
-    public function getParameterDefaultValue(ReflectionParameter $param, string $class_name, string $index)
235
-    {
236
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
237
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
238
-        }
239
-        if (! isset($this->parameter_classes[ $class_name ])) {
240
-            $this->parameter_classes[ $class_name ] = [];
241
-        }
242
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
243
-            $this->parameter_classes[ $class_name ][ $index ] = [];
244
-        }
245
-        $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
246
-            ? $param->getDefaultValue()
247
-            : null;
248
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
249
-    }
250
-
251
-
252
-    /**
253
-     * @param string $class_name
254
-     * @return ReflectionProperty[]
255
-     * @throws ReflectionException
256
-     */
257
-    public function getProperties(string $class_name): array
258
-    {
259
-        if (! isset($this->properties[ $class_name ])) {
260
-            $reflection_class = $this->getReflectionClass($class_name);
261
-            $properties       = $reflection_class->getProperties();
262
-            foreach ($properties as $property) {
263
-                $this->properties[ $class_name ][ $property->getName() ] = $property;
264
-            }
265
-        }
266
-        return $this->properties[ $class_name ];
267
-    }
268
-
269
-
270
-    /**
271
-     * @param ReflectionClass $reflection_class
272
-     * @return ReflectionProperty[]
273
-     * @throws ReflectionException
274
-     */
275
-    public function getPropertiesFromReflection(ReflectionClass $reflection_class): array
276
-    {
277
-        return $this->getProperties($reflection_class->getName());
278
-    }
279
-
280
-
281
-    /**
282
-     * @param string $class_name
283
-     * @param string $property_name
284
-     * @return ReflectionProperty|null
285
-     * @throws ReflectionException
286
-     */
287
-    public function getProperty(string $class_name, string $property_name): ?ReflectionProperty
288
-    {
289
-        if (! isset($this->properties[ $class_name ][ $property_name ])) {
290
-            $this->getProperties($class_name);
291
-        }
292
-        return $this->properties[ $class_name ][ $property_name ] ?? null;
293
-    }
294
-
295
-
296
-    /**
297
-     * @param string $class_name
298
-     * @return ReflectionMethod[]
299
-     * @throws ReflectionException
300
-     */
301
-    public function getMethods(string $class_name): array
302
-    {
303
-        if (! isset($this->methods[ $class_name ])) {
304
-            $reflection_class             = $this->getReflectionClass($class_name);
305
-            $this->methods[ $class_name ] = $reflection_class->getMethods();
306
-        }
307
-        return $this->methods[ $class_name ];
308
-    }
309
-
310
-
311
-    /**
312
-     * @param ReflectionClass $reflection_class )
313
-     * @return ReflectionMethod[]
314
-     * @throws ReflectionException
315
-     */
316
-    public function getMethodsFromReflection(ReflectionClass $reflection_class): array
317
-    {
318
-        return $this->getMethods($reflection_class->getName());
319
-    }
320
-
321
-
322
-    /**
323
-     * @param string $class_name
324
-     * @return array
325
-     * @throws ReflectionException
326
-     */
327
-    public function getDefaultProperties(string $class_name): array
328
-    {
329
-        if (! isset($this->default_properties[ $class_name ])) {
330
-            $reflection_class                        = $this->getReflectionClass($class_name);
331
-            $this->default_properties[ $class_name ] = $reflection_class->getDefaultProperties();
332
-        }
333
-        return $this->default_properties[ $class_name ];
334
-    }
335
-
336
-
337
-    /**
338
-     * @param string $class_name
339
-     * @return array
340
-     * @throws ReflectionException
341
-     */
342
-    public function getStaticProperties(string $class_name): array
343
-    {
344
-        if (! isset($this->static_properties[ $class_name ])) {
345
-            $reflection_class                       = $this->getReflectionClass($class_name);
346
-            $this->static_properties[ $class_name ] = $reflection_class->getStaticProperties();
347
-        }
348
-        return $this->static_properties[ $class_name ];
349
-    }
350
-
351
-
352
-    /**
353
-     * @param string $class_name
354
-     * @param string $property
355
-     * @return bool
356
-     * @throws ReflectionException
357
-     */
358
-    public function hasProperty(string $class_name, string $property): bool
359
-    {
360
-        $this->getProperties($class_name);
361
-        return isset($this->properties[ $class_name ][ $property ]);
362
-    }
22
+	/**
23
+	 * @var ReflectionClass[]
24
+	 */
25
+	private array $classes = [];
26
+
27
+	/**
28
+	 * @var ReflectionMethod[]
29
+	 */
30
+	private array $constructors = [];
31
+
32
+	/**
33
+	 * @var ReflectionParameter[][]
34
+	 */
35
+	private array $parameters = [];
36
+
37
+	/**
38
+	 * @var ReflectionParameter[][]
39
+	 */
40
+	private array $parameter_classes = [];
41
+
42
+	/**
43
+	 * @var ReflectionProperty[][]
44
+	 */
45
+	private array $properties = [];
46
+
47
+	/**
48
+	 * @var ReflectionMethod[][]
49
+	 */
50
+	private array $methods = [];
51
+
52
+	private array $default_properties = [];
53
+
54
+	private array $static_properties = [];
55
+
56
+
57
+	/**
58
+	 * @param string $class_name
59
+	 * @return ReflectionClass
60
+	 * @throws ReflectionException
61
+	 */
62
+	public function getReflectionClass(string $class_name): ReflectionClass
63
+	{
64
+		if (! isset($this->classes[ $class_name ])) {
65
+			$this->classes[ $class_name ] = new ReflectionClass($class_name);
66
+		}
67
+		return $this->classes[ $class_name ];
68
+	}
69
+
70
+
71
+	/**
72
+	 * @param string $class_name
73
+	 * @return ReflectionMethod|null
74
+	 * @throws ReflectionException
75
+	 */
76
+	public function getConstructor(string $class_name): ?ReflectionMethod
77
+	{
78
+		if (! isset($this->constructors[ $class_name ])) {
79
+			$reflection_class                  = $this->getReflectionClass($class_name);
80
+			$this->constructors[ $class_name ] = $reflection_class->getConstructor();
81
+		}
82
+		return $this->constructors[ $class_name ];
83
+	}
84
+
85
+
86
+	/**
87
+	 * @param ReflectionClass $reflection_class
88
+	 * @return ReflectionMethod|null
89
+	 * @throws ReflectionException
90
+	 */
91
+	public function getConstructorFromReflection(ReflectionClass $reflection_class): ?ReflectionMethod
92
+	{
93
+		return $this->getConstructor($reflection_class->getName());
94
+	}
95
+
96
+
97
+	/**
98
+	 * @throws ReflectionException
99
+	 */
100
+	public function getClassShortName(string $class_name): string
101
+	{
102
+		return $this->getReflectionClass($class_name)->getShortName();
103
+	}
104
+
105
+
106
+	/**
107
+	 * @param string $class_name
108
+	 * @return ReflectionParameter[]
109
+	 * @throws ReflectionException
110
+	 */
111
+	public function getParameters(string $class_name): array
112
+	{
113
+		if (! isset($this->parameters[ $class_name ])) {
114
+			$constructor                     = $this->getConstructor($class_name);
115
+			$this->parameters[ $class_name ] = $constructor->getParameters();
116
+		}
117
+		return $this->parameters[ $class_name ];
118
+	}
119
+
120
+
121
+	/**
122
+	 * @param ReflectionClass $reflection_class
123
+	 * @return ReflectionParameter[]
124
+	 * @throws ReflectionException
125
+	 */
126
+	public function getParametersFromReflection(ReflectionClass $reflection_class): array
127
+	{
128
+		return $this->getParameters($reflection_class->getName());
129
+	}
130
+
131
+
132
+	/**
133
+	 * @param ReflectionMethod $constructor
134
+	 * @return ReflectionParameter[]
135
+	 * @throws ReflectionException
136
+	 */
137
+	public function getParametersFromReflectionConstructor(ReflectionMethod $constructor): array
138
+	{
139
+		return $this->getParameters($constructor->getDeclaringClass());
140
+	}
141
+
142
+
143
+	/**
144
+	 * returns array of ReflectionParameter objects for parameters that are NOT optional
145
+	 *
146
+	 * @param string $class_name
147
+	 * @return ReflectionParameter[]
148
+	 * @throws ReflectionException
149
+	 */
150
+	public function getRequiredParameters(string $class_name): array
151
+	{
152
+		$required_parameters = [];
153
+		$parameters          = $this->getParameters($class_name);
154
+		foreach ($parameters as $parameter) {
155
+			if ($parameter instanceof ReflectionParameter && ! $parameter->isOptional()) {
156
+				$required_parameters[] = $parameter;
157
+			}
158
+		}
159
+		return $required_parameters;
160
+	}
161
+
162
+
163
+	/**
164
+	 * @param ReflectionParameter $param
165
+	 * @param string              $class_name
166
+	 * @param string              $index
167
+	 * @return string|null
168
+	 */
169
+	public function getParameterClassName(ReflectionParameter $param, string $class_name, string $index): ?string
170
+	{
171
+		if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
172
+			return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
173
+		}
174
+		if (! isset($this->parameter_classes[ $class_name ])) {
175
+			$this->parameter_classes[ $class_name ] = [];
176
+		}
177
+		if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
178
+			$this->parameter_classes[ $class_name ][ $index ] = [];
179
+		}
180
+		// ReflectionParameter::getClass() is deprecated in PHP 8+
181
+		$this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = PHP_VERSION_ID < 70100
182
+			? $this->getParameterClassNameLegacy($param)
183
+			: $this->getParameterClassNamePhp8($param);
184
+		return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
185
+	}
186
+
187
+
188
+	/**
189
+	 * @param ReflectionParameter $param
190
+	 * @return string|null
191
+	 * @since   4.10.13.p
192
+	 */
193
+	private function getParameterClassNameLegacy(ReflectionParameter $param): ?string
194
+	{
195
+		$reflection_class = $param->getClass();
196
+		return $reflection_class instanceof ReflectionClass
197
+			? $reflection_class->getName()
198
+			: null;
199
+	}
200
+
201
+
202
+	/**
203
+	 * ReflectionParameter::getClass() is deprecated in PHP 8+,
204
+	 * so the class name for a parameter needs to be extracted from the ReflectionType,
205
+	 * which can either be a ReflectionNamedType or ReflectionUnionType
206
+	 *
207
+	 * @param ReflectionParameter $param
208
+	 * @return string|null
209
+	 * @since   4.10.13.p
210
+	 */
211
+	private function getParameterClassNamePhp8(ReflectionParameter $param): ?string
212
+	{
213
+		$reflection_type = $param->getType();
214
+		if ($reflection_type instanceof \ReflectionNamedType) {
215
+			return $reflection_type->getName();
216
+		}
217
+		if ($reflection_type instanceof \ReflectionUnionType) {
218
+			$reflection_types = $reflection_type->getTypes();
219
+			if (is_array($reflection_types)) {
220
+				$first = reset($reflection_types);
221
+				return $first->getName();
222
+			}
223
+		}
224
+		return null;
225
+	}
226
+
227
+
228
+	/**
229
+	 * @param ReflectionParameter $param
230
+	 * @param string              $class_name
231
+	 * @param string              $index
232
+	 * @return array|string|null
233
+	 */
234
+	public function getParameterDefaultValue(ReflectionParameter $param, string $class_name, string $index)
235
+	{
236
+		if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
237
+			return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
238
+		}
239
+		if (! isset($this->parameter_classes[ $class_name ])) {
240
+			$this->parameter_classes[ $class_name ] = [];
241
+		}
242
+		if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
243
+			$this->parameter_classes[ $class_name ][ $index ] = [];
244
+		}
245
+		$this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
246
+			? $param->getDefaultValue()
247
+			: null;
248
+		return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
249
+	}
250
+
251
+
252
+	/**
253
+	 * @param string $class_name
254
+	 * @return ReflectionProperty[]
255
+	 * @throws ReflectionException
256
+	 */
257
+	public function getProperties(string $class_name): array
258
+	{
259
+		if (! isset($this->properties[ $class_name ])) {
260
+			$reflection_class = $this->getReflectionClass($class_name);
261
+			$properties       = $reflection_class->getProperties();
262
+			foreach ($properties as $property) {
263
+				$this->properties[ $class_name ][ $property->getName() ] = $property;
264
+			}
265
+		}
266
+		return $this->properties[ $class_name ];
267
+	}
268
+
269
+
270
+	/**
271
+	 * @param ReflectionClass $reflection_class
272
+	 * @return ReflectionProperty[]
273
+	 * @throws ReflectionException
274
+	 */
275
+	public function getPropertiesFromReflection(ReflectionClass $reflection_class): array
276
+	{
277
+		return $this->getProperties($reflection_class->getName());
278
+	}
279
+
280
+
281
+	/**
282
+	 * @param string $class_name
283
+	 * @param string $property_name
284
+	 * @return ReflectionProperty|null
285
+	 * @throws ReflectionException
286
+	 */
287
+	public function getProperty(string $class_name, string $property_name): ?ReflectionProperty
288
+	{
289
+		if (! isset($this->properties[ $class_name ][ $property_name ])) {
290
+			$this->getProperties($class_name);
291
+		}
292
+		return $this->properties[ $class_name ][ $property_name ] ?? null;
293
+	}
294
+
295
+
296
+	/**
297
+	 * @param string $class_name
298
+	 * @return ReflectionMethod[]
299
+	 * @throws ReflectionException
300
+	 */
301
+	public function getMethods(string $class_name): array
302
+	{
303
+		if (! isset($this->methods[ $class_name ])) {
304
+			$reflection_class             = $this->getReflectionClass($class_name);
305
+			$this->methods[ $class_name ] = $reflection_class->getMethods();
306
+		}
307
+		return $this->methods[ $class_name ];
308
+	}
309
+
310
+
311
+	/**
312
+	 * @param ReflectionClass $reflection_class )
313
+	 * @return ReflectionMethod[]
314
+	 * @throws ReflectionException
315
+	 */
316
+	public function getMethodsFromReflection(ReflectionClass $reflection_class): array
317
+	{
318
+		return $this->getMethods($reflection_class->getName());
319
+	}
320
+
321
+
322
+	/**
323
+	 * @param string $class_name
324
+	 * @return array
325
+	 * @throws ReflectionException
326
+	 */
327
+	public function getDefaultProperties(string $class_name): array
328
+	{
329
+		if (! isset($this->default_properties[ $class_name ])) {
330
+			$reflection_class                        = $this->getReflectionClass($class_name);
331
+			$this->default_properties[ $class_name ] = $reflection_class->getDefaultProperties();
332
+		}
333
+		return $this->default_properties[ $class_name ];
334
+	}
335
+
336
+
337
+	/**
338
+	 * @param string $class_name
339
+	 * @return array
340
+	 * @throws ReflectionException
341
+	 */
342
+	public function getStaticProperties(string $class_name): array
343
+	{
344
+		if (! isset($this->static_properties[ $class_name ])) {
345
+			$reflection_class                       = $this->getReflectionClass($class_name);
346
+			$this->static_properties[ $class_name ] = $reflection_class->getStaticProperties();
347
+		}
348
+		return $this->static_properties[ $class_name ];
349
+	}
350
+
351
+
352
+	/**
353
+	 * @param string $class_name
354
+	 * @param string $property
355
+	 * @return bool
356
+	 * @throws ReflectionException
357
+	 */
358
+	public function hasProperty(string $class_name, string $property): bool
359
+	{
360
+		$this->getProperties($class_name);
361
+		return isset($this->properties[ $class_name ][ $property ]);
362
+	}
363 363
 }
Please login to merge, or discard this patch.
core/services/service_changes/ServiceChangesManager.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -19,57 +19,57 @@
 block discarded – undo
19 19
  */
20 20
 class ServiceChangesManager
21 21
 {
22
-    private EE_Dependency_Map $dependency_map;
22
+	private EE_Dependency_Map $dependency_map;
23 23
 
24
-    private LoaderInterface $loader;
24
+	private LoaderInterface $loader;
25 25
 
26 26
 
27
-    /**
28
-     * @param EE_Dependency_Map $dependency_map
29
-     * @param LoaderInterface   $loader
30
-     * @throws EE_Error
31
-     * @throws ReflectionException
32
-     */
33
-    public function __construct(EE_Dependency_Map $dependency_map, LoaderInterface $loader)
34
-    {
35
-        $this->dependency_map = $dependency_map;
36
-        $this->loader         = $loader;
37
-        if (DbStatus::isOnline()) {
38
-            $this->registerDependencies();
39
-            $this->loadServiceChangeNotifications();
40
-        }
41
-    }
27
+	/**
28
+	 * @param EE_Dependency_Map $dependency_map
29
+	 * @param LoaderInterface   $loader
30
+	 * @throws EE_Error
31
+	 * @throws ReflectionException
32
+	 */
33
+	public function __construct(EE_Dependency_Map $dependency_map, LoaderInterface $loader)
34
+	{
35
+		$this->dependency_map = $dependency_map;
36
+		$this->loader         = $loader;
37
+		if (DbStatus::isOnline()) {
38
+			$this->registerDependencies();
39
+			$this->loadServiceChangeNotifications();
40
+		}
41
+	}
42 42
 
43 43
 
44
-    /**
45
-     * @return void
46
-     */
47
-    private function registerDependencies()
48
-    {
49
-        $this->dependency_map->registerDependencies(
50
-            'EventEspresso\core\domain\services\service_changes\PaymentMethodDeprecations2025',
51
-            [
52
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
53
-            ]
54
-        );
55
-    }
44
+	/**
45
+	 * @return void
46
+	 */
47
+	private function registerDependencies()
48
+	{
49
+		$this->dependency_map->registerDependencies(
50
+			'EventEspresso\core\domain\services\service_changes\PaymentMethodDeprecations2025',
51
+			[
52
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
53
+			]
54
+		);
55
+	}
56 56
 
57 57
 
58
-    /**
59
-     * @throws EE_Error
60
-     * @throws ReflectionException
61
-     */
62
-    public function loadServiceChangeNotifications()
63
-    {
64
-        if (
65
-            apply_filters(
66
-                'FHEE__EventEspresso_core_services_service_changes_ServiceChangesManager__loadServiceChangeNotifications__loadPaymentMethodDeprecations2025',
67
-                true
68
-            )
69
-        ) {
70
-            /** @var PaymentMethodDeprecations2025 $pm_deps */
71
-            $pm_deps = $this->loader->getShared(PaymentMethodDeprecations2025::class);
72
-            $pm_deps->setHooks();
73
-        }
74
-    }
58
+	/**
59
+	 * @throws EE_Error
60
+	 * @throws ReflectionException
61
+	 */
62
+	public function loadServiceChangeNotifications()
63
+	{
64
+		if (
65
+			apply_filters(
66
+				'FHEE__EventEspresso_core_services_service_changes_ServiceChangesManager__loadServiceChangeNotifications__loadPaymentMethodDeprecations2025',
67
+				true
68
+			)
69
+		) {
70
+			/** @var PaymentMethodDeprecations2025 $pm_deps */
71
+			$pm_deps = $this->loader->getShared(PaymentMethodDeprecations2025::class);
72
+			$pm_deps->setHooks();
73
+		}
74
+	}
75 75
 }
Please login to merge, or discard this patch.
core/services/routing/Router.php 1 patch
Indentation   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -30,246 +30,246 @@
 block discarded – undo
30 30
  */
31 31
 class Router
32 32
 {
33
-    protected EE_Dependency_Map $dependency_map;
33
+	protected EE_Dependency_Map $dependency_map;
34 34
 
35
-    protected LoaderInterface $loader;
35
+	protected LoaderInterface $loader;
36 36
 
37
-    protected RouteHandler $route_handler;
37
+	protected RouteHandler $route_handler;
38 38
 
39
-    protected string $route_request_type;
39
+	protected string $route_request_type;
40 40
 
41
-    protected array $routes_loaded;
41
+	protected array $routes_loaded;
42 42
 
43 43
 
44
-    /**
45
-     * RoutingSwitch constructor.
46
-     *
47
-     * @param EE_Dependency_Map $dependency_map
48
-     * @param LoaderInterface   $loader
49
-     * @param RouteHandler      $router
50
-     */
51
-    public function __construct(EE_Dependency_Map $dependency_map, LoaderInterface $loader, RouteHandler $router)
52
-    {
53
-        $this->dependency_map = $dependency_map;
54
-        $this->loader         = $loader;
55
-        $this->route_handler  = $router;
56
-    }
44
+	/**
45
+	 * RoutingSwitch constructor.
46
+	 *
47
+	 * @param EE_Dependency_Map $dependency_map
48
+	 * @param LoaderInterface   $loader
49
+	 * @param RouteHandler      $router
50
+	 */
51
+	public function __construct(EE_Dependency_Map $dependency_map, LoaderInterface $loader, RouteHandler $router)
52
+	{
53
+		$this->dependency_map = $dependency_map;
54
+		$this->loader         = $loader;
55
+		$this->route_handler  = $router;
56
+	}
57 57
 
58 58
 
59
-    /**
60
-     * @throws Exception|Throwable
61
-     */
62
-    public function loadPrimaryRoutes()
63
-    {
64
-        if (isset($this->routes_loaded[ __FUNCTION__ ])) {
65
-            return;
66
-        }
67
-        $this->dependency_map->registerDependencies(
68
-            'EventEspresso\core\domain\entities\routing\handlers\admin\ActivationRequests',
69
-            Route::getFullDependencies()
70
-        );
71
-        $this->dependency_map->registerDependencies(
72
-            'EventEspresso\core\domain\entities\routing\handlers\shared\RegularRequests',
73
-            Route::getFullDependencies()
74
-        );
75
-        // now load and prep all primary Routes
76
-        $this->route_handler->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\ActivationRequests');
77
-        $this->route_handler->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\RegularRequests');
78
-        $this->route_request_type = $this->route_handler->getRouteRequestType();
79
-        do_action(
80
-            'AHEE__EventEspresso_core_services_routing_Router__loadPrimaryRoutes',
81
-            $this->route_handler,
82
-            $this->route_request_type,
83
-            $this->dependency_map
84
-        );
85
-        $this->routes_loaded[ __FUNCTION__ ] = true;
86
-    }
59
+	/**
60
+	 * @throws Exception|Throwable
61
+	 */
62
+	public function loadPrimaryRoutes()
63
+	{
64
+		if (isset($this->routes_loaded[ __FUNCTION__ ])) {
65
+			return;
66
+		}
67
+		$this->dependency_map->registerDependencies(
68
+			'EventEspresso\core\domain\entities\routing\handlers\admin\ActivationRequests',
69
+			Route::getFullDependencies()
70
+		);
71
+		$this->dependency_map->registerDependencies(
72
+			'EventEspresso\core\domain\entities\routing\handlers\shared\RegularRequests',
73
+			Route::getFullDependencies()
74
+		);
75
+		// now load and prep all primary Routes
76
+		$this->route_handler->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\ActivationRequests');
77
+		$this->route_handler->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\RegularRequests');
78
+		$this->route_request_type = $this->route_handler->getRouteRequestType();
79
+		do_action(
80
+			'AHEE__EventEspresso_core_services_routing_Router__loadPrimaryRoutes',
81
+			$this->route_handler,
82
+			$this->route_request_type,
83
+			$this->dependency_map
84
+		);
85
+		$this->routes_loaded[ __FUNCTION__ ] = true;
86
+	}
87 87
 
88 88
 
89
-    /**
90
-     * @throws Exception|Throwable
91
-     */
92
-    public function registerShortcodesModulesAndWidgets()
93
-    {
94
-        if (isset($this->routes_loaded[ __FUNCTION__ ])) {
95
-            return;
96
-        }
97
-        do_action(
98
-            'AHEE__EventEspresso_core_services_routing_Router__registerShortcodesModulesAndWidgets',
99
-            $this->route_handler,
100
-            $this->route_request_type,
101
-            $this->dependency_map
102
-        );
89
+	/**
90
+	 * @throws Exception|Throwable
91
+	 */
92
+	public function registerShortcodesModulesAndWidgets()
93
+	{
94
+		if (isset($this->routes_loaded[ __FUNCTION__ ])) {
95
+			return;
96
+		}
97
+		do_action(
98
+			'AHEE__EventEspresso_core_services_routing_Router__registerShortcodesModulesAndWidgets',
99
+			$this->route_handler,
100
+			$this->route_request_type,
101
+			$this->dependency_map
102
+		);
103 103
 
104
-        /** @var LegacyModulesManager $legacy_modules_manager */
105
-        $legacy_modules_manager = $this->loader->getShared(LegacyModulesManager::class);
106
-        $legacy_modules_manager->setHooks();
104
+		/** @var LegacyModulesManager $legacy_modules_manager */
105
+		$legacy_modules_manager = $this->loader->getShared(LegacyModulesManager::class);
106
+		$legacy_modules_manager->setHooks();
107 107
 
108
-        switch ($this->route_request_type) {
109
-            case PrimaryRoute::ROUTE_REQUEST_TYPE_ACTIVATION:
110
-                break;
111
-            case PrimaryRoute::ROUTE_REQUEST_TYPE_REGULAR:
112
-                $this->route_handler->addRoute(
113
-                    'EventEspresso\core\domain\entities\routing\handlers\frontend\ShortcodeRequests'
114
-                );
115
-                /** @var LegacyWidgetsManager $legacy_widgets_manager */
116
-                $legacy_widgets_manager = $this->loader->getShared(LegacyWidgetsManager::class);
117
-                $legacy_widgets_manager->setHooks();
118
-                break;
119
-        }
120
-        $this->routes_loaded[ __FUNCTION__ ] = true;
121
-    }
108
+		switch ($this->route_request_type) {
109
+			case PrimaryRoute::ROUTE_REQUEST_TYPE_ACTIVATION:
110
+				break;
111
+			case PrimaryRoute::ROUTE_REQUEST_TYPE_REGULAR:
112
+				$this->route_handler->addRoute(
113
+					'EventEspresso\core\domain\entities\routing\handlers\frontend\ShortcodeRequests'
114
+				);
115
+				/** @var LegacyWidgetsManager $legacy_widgets_manager */
116
+				$legacy_widgets_manager = $this->loader->getShared(LegacyWidgetsManager::class);
117
+				$legacy_widgets_manager->setHooks();
118
+				break;
119
+		}
120
+		$this->routes_loaded[ __FUNCTION__ ] = true;
121
+	}
122 122
 
123 123
 
124
-    /**
125
-     * @throws Exception|Throwable
126
-     */
127
-    public function brewEspresso()
128
-    {
129
-        if (isset($this->routes_loaded[ __FUNCTION__ ])) {
130
-            return;
131
-        }
132
-        do_action(
133
-            'AHEE__EventEspresso_core_services_routing_Router__brewEspresso',
134
-            $this->route_handler,
135
-            $this->route_request_type,
136
-            $this->dependency_map
137
-        );
138
-        switch ($this->route_request_type) {
139
-            case PrimaryRoute::ROUTE_REQUEST_TYPE_ACTIVATION:
140
-                break;
141
-            case PrimaryRoute::ROUTE_REQUEST_TYPE_REGULAR:
142
-                $this->route_handler->addRoute(
143
-                    'EventEspresso\core\domain\entities\routing\handlers\shared\GQLRequests'
144
-                );
145
-                $this->route_handler->addRoute(
146
-                    'EventEspresso\core\domain\entities\routing\handlers\shared\RestApiRequests'
147
-                );
148
-                break;
149
-        }
150
-        $this->routes_loaded[ __FUNCTION__ ] = true;
151
-    }
124
+	/**
125
+	 * @throws Exception|Throwable
126
+	 */
127
+	public function brewEspresso()
128
+	{
129
+		if (isset($this->routes_loaded[ __FUNCTION__ ])) {
130
+			return;
131
+		}
132
+		do_action(
133
+			'AHEE__EventEspresso_core_services_routing_Router__brewEspresso',
134
+			$this->route_handler,
135
+			$this->route_request_type,
136
+			$this->dependency_map
137
+		);
138
+		switch ($this->route_request_type) {
139
+			case PrimaryRoute::ROUTE_REQUEST_TYPE_ACTIVATION:
140
+				break;
141
+			case PrimaryRoute::ROUTE_REQUEST_TYPE_REGULAR:
142
+				$this->route_handler->addRoute(
143
+					'EventEspresso\core\domain\entities\routing\handlers\shared\GQLRequests'
144
+				);
145
+				$this->route_handler->addRoute(
146
+					'EventEspresso\core\domain\entities\routing\handlers\shared\RestApiRequests'
147
+				);
148
+				break;
149
+		}
150
+		$this->routes_loaded[ __FUNCTION__ ] = true;
151
+	}
152 152
 
153 153
 
154
-    /**
155
-     * @throws Exception|Throwable
156
-     */
157
-    public function loadControllers()
158
-    {
159
-        if (isset($this->routes_loaded[ __FUNCTION__ ])) {
160
-            return;
161
-        }
162
-        do_action(
163
-            'AHEE__EventEspresso_core_services_routing_Router__loadControllers',
164
-            $this->route_handler,
165
-            $this->route_request_type,
166
-            $this->dependency_map
167
-        );
168
-        $this->route_handler->addRoute(
169
-            'EventEspresso\core\domain\entities\routing\handlers\admin\AdminRoute'
170
-        );
171
-        switch ($this->route_request_type) {
172
-            case PrimaryRoute::ROUTE_REQUEST_TYPE_ACTIVATION:
173
-                $this->route_handler->addRoute(
174
-                    'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage'
175
-                );
176
-                break;
177
-            case PrimaryRoute::ROUTE_REQUEST_TYPE_REGULAR:
178
-                $this->route_handler->addRoute(
179
-                    'EventEspresso\core\domain\entities\routing\handlers\frontend\FrontendRequests'
180
-                );
181
-                $this->route_handler->addRoute(
182
-                    'EventEspresso\core\domain\entities\routing\handlers\frontend\RegistrationCheckoutRequests'
183
-                );
184
-                $this->route_handler->addRoute(
185
-                    'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoLegacyAdmin'
186
-                );
187
-                $this->route_handler->addRoute(
188
-                    'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventsAdmin'
189
-                );
190
-                $this->route_handler->addRoute(
191
-                    'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventEditor'
192
-                );
193
-                $this->route_handler->addRoute(
194
-                    'EventEspresso\core\domain\entities\routing\handlers\admin\GutenbergEditor'
195
-                );
196
-                $this->route_handler->addRoute(
197
-                    'EventEspresso\core\domain\entities\routing\handlers\admin\NonEspressoAdminAjax'
198
-                );
199
-                $this->route_handler->addRoute(
200
-                    'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage'
201
-                );
202
-                $this->route_handler->addRoute(
203
-                    'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressProfilePage'
204
-                );
205
-                $this->route_handler->addRoute(
206
-                    'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPostsPage'
207
-                );
208
-                $this->route_handler->addRoute(
209
-                    'EventEspresso\core\domain\entities\routing\handlers\shared\WordPressHeartbeat'
210
-                );
211
-                $this->route_handler->addRoute(
212
-                    'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoBatchJob'
213
-                );
214
-                break;
215
-        }
216
-        $this->routes_loaded[ __FUNCTION__ ] = true;
217
-    }
154
+	/**
155
+	 * @throws Exception|Throwable
156
+	 */
157
+	public function loadControllers()
158
+	{
159
+		if (isset($this->routes_loaded[ __FUNCTION__ ])) {
160
+			return;
161
+		}
162
+		do_action(
163
+			'AHEE__EventEspresso_core_services_routing_Router__loadControllers',
164
+			$this->route_handler,
165
+			$this->route_request_type,
166
+			$this->dependency_map
167
+		);
168
+		$this->route_handler->addRoute(
169
+			'EventEspresso\core\domain\entities\routing\handlers\admin\AdminRoute'
170
+		);
171
+		switch ($this->route_request_type) {
172
+			case PrimaryRoute::ROUTE_REQUEST_TYPE_ACTIVATION:
173
+				$this->route_handler->addRoute(
174
+					'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage'
175
+				);
176
+				break;
177
+			case PrimaryRoute::ROUTE_REQUEST_TYPE_REGULAR:
178
+				$this->route_handler->addRoute(
179
+					'EventEspresso\core\domain\entities\routing\handlers\frontend\FrontendRequests'
180
+				);
181
+				$this->route_handler->addRoute(
182
+					'EventEspresso\core\domain\entities\routing\handlers\frontend\RegistrationCheckoutRequests'
183
+				);
184
+				$this->route_handler->addRoute(
185
+					'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoLegacyAdmin'
186
+				);
187
+				$this->route_handler->addRoute(
188
+					'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventsAdmin'
189
+				);
190
+				$this->route_handler->addRoute(
191
+					'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventEditor'
192
+				);
193
+				$this->route_handler->addRoute(
194
+					'EventEspresso\core\domain\entities\routing\handlers\admin\GutenbergEditor'
195
+				);
196
+				$this->route_handler->addRoute(
197
+					'EventEspresso\core\domain\entities\routing\handlers\admin\NonEspressoAdminAjax'
198
+				);
199
+				$this->route_handler->addRoute(
200
+					'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage'
201
+				);
202
+				$this->route_handler->addRoute(
203
+					'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressProfilePage'
204
+				);
205
+				$this->route_handler->addRoute(
206
+					'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPostsPage'
207
+				);
208
+				$this->route_handler->addRoute(
209
+					'EventEspresso\core\domain\entities\routing\handlers\shared\WordPressHeartbeat'
210
+				);
211
+				$this->route_handler->addRoute(
212
+					'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoBatchJob'
213
+				);
214
+				break;
215
+		}
216
+		$this->routes_loaded[ __FUNCTION__ ] = true;
217
+	}
218 218
 
219 219
 
220
-    /**
221
-     * @throws Exception|Throwable
222
-     */
223
-    public function coreLoadedAndReady()
224
-    {
225
-        if (isset($this->routes_loaded[ __FUNCTION__ ])) {
226
-            return;
227
-        }
228
-        do_action(
229
-            'AHEE__EventEspresso_core_services_routing_Router__coreLoadedAndReady',
230
-            $this->route_handler,
231
-            $this->route_request_type,
232
-            $this->dependency_map
233
-        );
234
-        switch ($this->route_request_type) {
235
-            case PrimaryRoute::ROUTE_REQUEST_TYPE_ACTIVATION:
236
-                break;
237
-            case PrimaryRoute::ROUTE_REQUEST_TYPE_REGULAR:
238
-                $this->route_handler->addRoute(
239
-                    'EventEspresso\core\domain\entities\routing\handlers\shared\AssetRequests'
240
-                );
241
-                $this->route_handler->addRoute(
242
-                    'EventEspresso\core\domain\entities\routing\handlers\shared\SessionRequests'
243
-                );
244
-                break;
245
-        }
246
-        $this->routes_loaded[ __FUNCTION__ ] = true;
247
-    }
220
+	/**
221
+	 * @throws Exception|Throwable
222
+	 */
223
+	public function coreLoadedAndReady()
224
+	{
225
+		if (isset($this->routes_loaded[ __FUNCTION__ ])) {
226
+			return;
227
+		}
228
+		do_action(
229
+			'AHEE__EventEspresso_core_services_routing_Router__coreLoadedAndReady',
230
+			$this->route_handler,
231
+			$this->route_request_type,
232
+			$this->dependency_map
233
+		);
234
+		switch ($this->route_request_type) {
235
+			case PrimaryRoute::ROUTE_REQUEST_TYPE_ACTIVATION:
236
+				break;
237
+			case PrimaryRoute::ROUTE_REQUEST_TYPE_REGULAR:
238
+				$this->route_handler->addRoute(
239
+					'EventEspresso\core\domain\entities\routing\handlers\shared\AssetRequests'
240
+				);
241
+				$this->route_handler->addRoute(
242
+					'EventEspresso\core\domain\entities\routing\handlers\shared\SessionRequests'
243
+				);
244
+				break;
245
+		}
246
+		$this->routes_loaded[ __FUNCTION__ ] = true;
247
+	}
248 248
 
249 249
 
250
-    /**
251
-     * @throws Exception|Throwable
252
-     */
253
-    public function initializeLast()
254
-    {
255
-        if (isset($this->routes_loaded[ __FUNCTION__ ])) {
256
-            return;
257
-        }
258
-        do_action(
259
-            'AHEE__EventEspresso_core_services_routing_Router__initializeLast',
260
-            $this->route_handler,
261
-            $this->route_request_type,
262
-            $this->dependency_map
263
-        );
264
-        switch ($this->route_request_type) {
265
-            case PrimaryRoute::ROUTE_REQUEST_TYPE_ACTIVATION:
266
-                break;
267
-            case PrimaryRoute::ROUTE_REQUEST_TYPE_REGULAR:
268
-                $this->route_handler->addRoute(
269
-                    'EventEspresso\core\domain\entities\routing\handlers\admin\PersonalDataRequests'
270
-                );
271
-                break;
272
-        }
273
-        $this->routes_loaded[ __FUNCTION__ ] = true;
274
-    }
250
+	/**
251
+	 * @throws Exception|Throwable
252
+	 */
253
+	public function initializeLast()
254
+	{
255
+		if (isset($this->routes_loaded[ __FUNCTION__ ])) {
256
+			return;
257
+		}
258
+		do_action(
259
+			'AHEE__EventEspresso_core_services_routing_Router__initializeLast',
260
+			$this->route_handler,
261
+			$this->route_request_type,
262
+			$this->dependency_map
263
+		);
264
+		switch ($this->route_request_type) {
265
+			case PrimaryRoute::ROUTE_REQUEST_TYPE_ACTIVATION:
266
+				break;
267
+			case PrimaryRoute::ROUTE_REQUEST_TYPE_REGULAR:
268
+				$this->route_handler->addRoute(
269
+					'EventEspresso\core\domain\entities\routing\handlers\admin\PersonalDataRequests'
270
+				);
271
+				break;
272
+		}
273
+		$this->routes_loaded[ __FUNCTION__ ] = true;
274
+	}
275 275
 }
Please login to merge, or discard this patch.
core/services/routing/RouteHandler.php 1 patch
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -22,161 +22,161 @@
 block discarded – undo
22 22
  */
23 23
 class RouteHandler
24 24
 {
25
-    private CapabilitiesCheckerInterface $capabilities_checker;
26
-
27
-    private JsonDataNodeHandler $data_node_handler;
28
-
29
-    private LoaderInterface $loader;
30
-
31
-    protected RequestInterface $request;
32
-
33
-    private RouteCollection $routes;
34
-
35
-    private bool $print_data_nodes = true;
36
-
37
-    protected string $route_request_type = '';
38
-
39
-
40
-    /**
41
-     * RouteHandler constructor.
42
-     *
43
-     * @param CapabilitiesCheckerInterface $capabilities_checker
44
-     * @param JsonDataNodeHandler $data_node_handler
45
-     * @param LoaderInterface     $loader
46
-     * @param RequestInterface    $request
47
-     * @param RouteCollection     $routes
48
-     */
49
-    public function __construct(
50
-        CapabilitiesCheckerInterface $capabilities_checker,
51
-        JsonDataNodeHandler $data_node_handler,
52
-        LoaderInterface $loader,
53
-        RequestInterface $request,
54
-        RouteCollection $routes
55
-    ) {
56
-        $this->capabilities_checker = $capabilities_checker;
57
-        $this->data_node_handler = $data_node_handler;
58
-        $this->loader            = $loader;
59
-        $this->request           = $request;
60
-        $this->routes            = $routes;
61
-    }
62
-
63
-
64
-    /**
65
-     * @param string $fqcn   Fully Qualified Class Name for Route
66
-     * @param bool   $handle if true [default] will immediately call RouteInterface::handleRequest() after adding
67
-     * @throws Exception|Throwable
68
-     */
69
-    public function addRoute(string $fqcn, bool $handle = true)
70
-    {
71
-        try {
72
-            $route = $this->loader->getShared($fqcn);
73
-            $this->validateRoute($route, $fqcn);
74
-            if ($this->capabilities_checker->processCapCheck($route->getCapCheck(), true)) {
75
-                $this->routes->add($route);
76
-                $this->handle($route, $handle);
77
-            }
78
-        } catch (Exception $exception) {
79
-            new ExceptionStackTraceDisplay(
80
-                new DomainException(
81
-                    sprintf(
82
-                        esc_html__(
83
-                            'The following error occurred while trying to handle the "%1$s" route:%2$s%3$s',
84
-                            'event_espresso'
85
-                        ),
86
-                        $fqcn,
87
-                        '<br />',
88
-                        $exception->getMessage()
89
-                    )
90
-                )
91
-            );
92
-        }
93
-    }
94
-
95
-
96
-    /**
97
-     * @return string
98
-     */
99
-    public function getRouteRequestType(): string
100
-    {
101
-        return $this->route_request_type;
102
-    }
103
-
104
-
105
-    /**
106
-     * @param string $route_request_type
107
-     */
108
-    public function setRouteRequestType(string $route_request_type = '')
109
-    {
110
-        $this->route_request_type = ! empty($route_request_type) ? $route_request_type : $this->route_request_type;
111
-    }
112
-
113
-
114
-    /**
115
-     * @param RouteInterface $route
116
-     * @param bool           $handle if true [default] will immediately call RouteInterface::handleRequest()
117
-     */
118
-    public function handle(RouteInterface $route, bool $handle = true)
119
-    {
120
-        if ($handle && $route->isNotHandled()) {
121
-            $route->handleRequest();
122
-            if ($route instanceof PrimaryRoute) {
123
-                $this->setRouteRequestType($route->getRouteRequestType());
124
-            }
125
-            $data_node = $route->dataNode();
126
-            if ($data_node instanceof JsonDataNode) {
127
-                $this->data_node_handler->addDataNode($data_node);
128
-                $this->printDataNodes();
129
-            }
130
-        }
131
-    }
132
-
133
-
134
-    /**
135
-     * calls RouteInterface::handleRequest() on all Routes that
136
-     *      - match current request
137
-     *      - have yet to be handled
138
-     *
139
-     * @return void
140
-     */
141
-    public function handleRoutesForCurrentRequest()
142
-    {
143
-        $this->routes->handleRoutesForCurrentRequest();
144
-    }
145
-
146
-
147
-    /**
148
-     * @return void
149
-     */
150
-    private function printDataNodes()
151
-    {
152
-        if ($this->print_data_nodes) {
153
-            add_action('admin_footer', [$this->data_node_handler, 'printDataNode'], 0);
154
-            add_action('wp_footer', [$this->data_node_handler, 'printDataNode'], 0);
155
-            $this->print_data_nodes = false;
156
-        }
157
-    }
158
-
159
-
160
-    /**
161
-     * @param RouteInterface|null $route
162
-     * @param string              $fqcn
163
-     */
164
-    private function validateRoute(?RouteInterface $route, string $fqcn = '')
165
-    {
166
-        if (! $route instanceof RouteInterface) {
167
-            throw new InvalidClassException(
168
-                sprintf(
169
-                    /*
25
+	private CapabilitiesCheckerInterface $capabilities_checker;
26
+
27
+	private JsonDataNodeHandler $data_node_handler;
28
+
29
+	private LoaderInterface $loader;
30
+
31
+	protected RequestInterface $request;
32
+
33
+	private RouteCollection $routes;
34
+
35
+	private bool $print_data_nodes = true;
36
+
37
+	protected string $route_request_type = '';
38
+
39
+
40
+	/**
41
+	 * RouteHandler constructor.
42
+	 *
43
+	 * @param CapabilitiesCheckerInterface $capabilities_checker
44
+	 * @param JsonDataNodeHandler $data_node_handler
45
+	 * @param LoaderInterface     $loader
46
+	 * @param RequestInterface    $request
47
+	 * @param RouteCollection     $routes
48
+	 */
49
+	public function __construct(
50
+		CapabilitiesCheckerInterface $capabilities_checker,
51
+		JsonDataNodeHandler $data_node_handler,
52
+		LoaderInterface $loader,
53
+		RequestInterface $request,
54
+		RouteCollection $routes
55
+	) {
56
+		$this->capabilities_checker = $capabilities_checker;
57
+		$this->data_node_handler = $data_node_handler;
58
+		$this->loader            = $loader;
59
+		$this->request           = $request;
60
+		$this->routes            = $routes;
61
+	}
62
+
63
+
64
+	/**
65
+	 * @param string $fqcn   Fully Qualified Class Name for Route
66
+	 * @param bool   $handle if true [default] will immediately call RouteInterface::handleRequest() after adding
67
+	 * @throws Exception|Throwable
68
+	 */
69
+	public function addRoute(string $fqcn, bool $handle = true)
70
+	{
71
+		try {
72
+			$route = $this->loader->getShared($fqcn);
73
+			$this->validateRoute($route, $fqcn);
74
+			if ($this->capabilities_checker->processCapCheck($route->getCapCheck(), true)) {
75
+				$this->routes->add($route);
76
+				$this->handle($route, $handle);
77
+			}
78
+		} catch (Exception $exception) {
79
+			new ExceptionStackTraceDisplay(
80
+				new DomainException(
81
+					sprintf(
82
+						esc_html__(
83
+							'The following error occurred while trying to handle the "%1$s" route:%2$s%3$s',
84
+							'event_espresso'
85
+						),
86
+						$fqcn,
87
+						'<br />',
88
+						$exception->getMessage()
89
+					)
90
+				)
91
+			);
92
+		}
93
+	}
94
+
95
+
96
+	/**
97
+	 * @return string
98
+	 */
99
+	public function getRouteRequestType(): string
100
+	{
101
+		return $this->route_request_type;
102
+	}
103
+
104
+
105
+	/**
106
+	 * @param string $route_request_type
107
+	 */
108
+	public function setRouteRequestType(string $route_request_type = '')
109
+	{
110
+		$this->route_request_type = ! empty($route_request_type) ? $route_request_type : $this->route_request_type;
111
+	}
112
+
113
+
114
+	/**
115
+	 * @param RouteInterface $route
116
+	 * @param bool           $handle if true [default] will immediately call RouteInterface::handleRequest()
117
+	 */
118
+	public function handle(RouteInterface $route, bool $handle = true)
119
+	{
120
+		if ($handle && $route->isNotHandled()) {
121
+			$route->handleRequest();
122
+			if ($route instanceof PrimaryRoute) {
123
+				$this->setRouteRequestType($route->getRouteRequestType());
124
+			}
125
+			$data_node = $route->dataNode();
126
+			if ($data_node instanceof JsonDataNode) {
127
+				$this->data_node_handler->addDataNode($data_node);
128
+				$this->printDataNodes();
129
+			}
130
+		}
131
+	}
132
+
133
+
134
+	/**
135
+	 * calls RouteInterface::handleRequest() on all Routes that
136
+	 *      - match current request
137
+	 *      - have yet to be handled
138
+	 *
139
+	 * @return void
140
+	 */
141
+	public function handleRoutesForCurrentRequest()
142
+	{
143
+		$this->routes->handleRoutesForCurrentRequest();
144
+	}
145
+
146
+
147
+	/**
148
+	 * @return void
149
+	 */
150
+	private function printDataNodes()
151
+	{
152
+		if ($this->print_data_nodes) {
153
+			add_action('admin_footer', [$this->data_node_handler, 'printDataNode'], 0);
154
+			add_action('wp_footer', [$this->data_node_handler, 'printDataNode'], 0);
155
+			$this->print_data_nodes = false;
156
+		}
157
+	}
158
+
159
+
160
+	/**
161
+	 * @param RouteInterface|null $route
162
+	 * @param string              $fqcn
163
+	 */
164
+	private function validateRoute(?RouteInterface $route, string $fqcn = '')
165
+	{
166
+		if (! $route instanceof RouteInterface) {
167
+			throw new InvalidClassException(
168
+				sprintf(
169
+					/*
170 170
                      * translators:
171 171
                      * The supplied FQCN (Fully\Qualified\Class\Name) must be an instance of RouteInterface.
172 172
                      */
173
-                    esc_html__(
174
-                        'The supplied FQCN (%1$s) must be an instance of RouteInterface.',
175
-                        'event_espresso'
176
-                    ),
177
-                    $fqcn
178
-                )
179
-            );
180
-        }
181
-    }
173
+					esc_html__(
174
+						'The supplied FQCN (%1$s) must be an instance of RouteInterface.',
175
+						'event_espresso'
176
+					),
177
+					$fqcn
178
+				)
179
+			);
180
+		}
181
+	}
182 182
 }
Please login to merge, or discard this patch.