Completed
Branch models-cleanup/model-relations (db5ca7)
by
unknown
13:03 queued 08:35
created
core/libraries/form_sections/inputs/EE_Button_Input.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -11,42 +11,42 @@
 block discarded – undo
11 11
 class EE_Button_Input extends EE_Form_Input_Base
12 12
 {
13 13
 
14
-    /**
15
-     * @var string of HTML to put between the button tags
16
-     */
17
-    protected $_button_content;
18
-    /**
19
-     * @param array $options
20
-     */
21
-    public function __construct($options = array())
22
-    {
23
-        if (empty($options['button_content'])) {
24
-            $options['button_content'] = esc_html__('Button', 'event_espresso');
25
-        }
26
-        $this->_set_display_strategy(new EE_Button_Display_Strategy());
27
-        $this->_set_normalization_strategy(new EE_Text_Normalization());
28
-        $this->_add_validation_strategy(new EE_Plaintext_Validation_Strategy());
29
-        parent::__construct($options);
30
-    }
14
+	/**
15
+	 * @var string of HTML to put between the button tags
16
+	 */
17
+	protected $_button_content;
18
+	/**
19
+	 * @param array $options
20
+	 */
21
+	public function __construct($options = array())
22
+	{
23
+		if (empty($options['button_content'])) {
24
+			$options['button_content'] = esc_html__('Button', 'event_espresso');
25
+		}
26
+		$this->_set_display_strategy(new EE_Button_Display_Strategy());
27
+		$this->_set_normalization_strategy(new EE_Text_Normalization());
28
+		$this->_add_validation_strategy(new EE_Plaintext_Validation_Strategy());
29
+		parent::__construct($options);
30
+	}
31 31
 
32 32
 
33 33
 
34
-    /**
35
-     * Sets the button content
36
-     * @see EE_Button_Input::$_button_content
37
-     * @param string $new_content
38
-     */
39
-    public function set_button_content($new_content)
40
-    {
41
-        $this->_button_content = $new_content;
42
-    }
34
+	/**
35
+	 * Sets the button content
36
+	 * @see EE_Button_Input::$_button_content
37
+	 * @param string $new_content
38
+	 */
39
+	public function set_button_content($new_content)
40
+	{
41
+		$this->_button_content = $new_content;
42
+	}
43 43
     
44
-    /**
45
-     * Gets the button content
46
-     * @return string
47
-     */
48
-    public function button_content()
49
-    {
50
-        return $this->_button_content;
51
-    }
44
+	/**
45
+	 * Gets the button content
46
+	 * @return string
47
+	 */
48
+	public function button_content()
49
+	{
50
+		return $this->_button_content;
51
+	}
52 52
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Submit_Input.input.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -11,17 +11,17 @@
 block discarded – undo
11 11
 class EE_Submit_Input extends EE_Form_Input_Base
12 12
 {
13 13
 
14
-    /**
15
-     * @param array $options
16
-     */
17
-    public function __construct($options = array())
18
-    {
19
-        if (empty($options['default'])) {
20
-            $options['default'] = esc_html__('Submit', 'event_espresso');
21
-        }
22
-        $this->_set_display_strategy(new EE_Submit_Input_Display_Strategy());
23
-        $this->_set_normalization_strategy(new EE_Text_Normalization());
24
-        $this->_add_validation_strategy(new EE_Plaintext_Validation_Strategy());
25
-        parent::__construct($options);
26
-    }
14
+	/**
15
+	 * @param array $options
16
+	 */
17
+	public function __construct($options = array())
18
+	{
19
+		if (empty($options['default'])) {
20
+			$options['default'] = esc_html__('Submit', 'event_espresso');
21
+		}
22
+		$this->_set_display_strategy(new EE_Submit_Input_Display_Strategy());
23
+		$this->_set_normalization_strategy(new EE_Text_Normalization());
24
+		$this->_add_validation_strategy(new EE_Plaintext_Validation_Strategy());
25
+		parent::__construct($options);
26
+	}
27 27
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Checkbox_Multi_Input.input.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
 class EE_Checkbox_Multi_Input extends EE_Form_Input_With_Options_Base
15 15
 {
16 16
 
17
-    /**
18
-     * @param array $input_settings
19
-     * @param array | EE_Question_Option[] $answer_options
20
-     */
21
-    public function __construct($answer_options, $input_settings = array())
22
-    {
23
-        $this->_set_display_strategy(new EE_Checkbox_Display_Strategy());
24
-        $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) )));
25
-        $this->_multiple_selections = true;
26
-        parent::__construct($answer_options, $input_settings);
27
-    }
17
+	/**
18
+	 * @param array $input_settings
19
+	 * @param array | EE_Question_Option[] $answer_options
20
+	 */
21
+	public function __construct($answer_options, $input_settings = array())
22
+	{
23
+		$this->_set_display_strategy(new EE_Checkbox_Display_Strategy());
24
+		$this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) )));
25
+		$this->_multiple_selections = true;
26
+		parent::__construct($answer_options, $input_settings);
27
+	}
28 28
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
     public function __construct($answer_options, $input_settings = array())
22 22
     {
23 23
         $this->_set_display_strategy(new EE_Checkbox_Display_Strategy());
24
-        $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) )));
24
+        $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array(new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null))));
25 25
         $this->_multiple_selections = true;
26 26
         parent::__construct($answer_options, $input_settings);
27 27
     }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Month_Input.input.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -9,36 +9,36 @@
 block discarded – undo
9 9
 class EE_Month_Input extends EE_Select_Input
10 10
 {
11 11
 
12
-    /**
13
-     * @param bool  $leading_zero
14
-     * @param array $input_settings
15
-     * @param bool $january_is_month_1 whether january should have value of 1; or it should be month 0
16
-     */
17
-    public function __construct($leading_zero = false, $input_settings = array(), $january_is_month_1 = true)
18
-    {
19
-        $key_begin_range = $january_is_month_1 ? 1 : 0;
20
-        $key_range = range($key_begin_range, $key_begin_range + 11);
21
-        if ($leading_zero) {
22
-            array_walk($key_range, array( $this, '_zero_pad' ));
23
-        }
24
-        $value_range = range(1, 12);
25
-        array_walk($value_range, array( $this, '_zero_pad' ));
26
-        parent::__construct(
27
-            array_combine(
28
-                $key_range,
29
-                $value_range
30
-            ),
31
-            $input_settings
32
-        );
33
-    }
12
+	/**
13
+	 * @param bool  $leading_zero
14
+	 * @param array $input_settings
15
+	 * @param bool $january_is_month_1 whether january should have value of 1; or it should be month 0
16
+	 */
17
+	public function __construct($leading_zero = false, $input_settings = array(), $january_is_month_1 = true)
18
+	{
19
+		$key_begin_range = $january_is_month_1 ? 1 : 0;
20
+		$key_range = range($key_begin_range, $key_begin_range + 11);
21
+		if ($leading_zero) {
22
+			array_walk($key_range, array( $this, '_zero_pad' ));
23
+		}
24
+		$value_range = range(1, 12);
25
+		array_walk($value_range, array( $this, '_zero_pad' ));
26
+		parent::__construct(
27
+			array_combine(
28
+				$key_range,
29
+				$value_range
30
+			),
31
+			$input_settings
32
+		);
33
+	}
34 34
     
35
-    /**
36
-     * Changes int 1 to 01, etc. Useful with array_walk
37
-     * @param int $input
38
-     * @param mixed $key
39
-     */
40
-    protected function _zero_pad(&$input, $key)
41
-    {
42
-        $input = str_pad($input, 2, '0', STR_PAD_LEFT);
43
-    }
35
+	/**
36
+	 * Changes int 1 to 01, etc. Useful with array_walk
37
+	 * @param int $input
38
+	 * @param mixed $key
39
+	 */
40
+	protected function _zero_pad(&$input, $key)
41
+	{
42
+		$input = str_pad($input, 2, '0', STR_PAD_LEFT);
43
+	}
44 44
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@
 block discarded – undo
19 19
         $key_begin_range = $january_is_month_1 ? 1 : 0;
20 20
         $key_range = range($key_begin_range, $key_begin_range + 11);
21 21
         if ($leading_zero) {
22
-            array_walk($key_range, array( $this, '_zero_pad' ));
22
+            array_walk($key_range, array($this, '_zero_pad'));
23 23
         }
24 24
         $value_range = range(1, 12);
25
-        array_walk($value_range, array( $this, '_zero_pad' ));
25
+        array_walk($value_range, array($this, '_zero_pad'));
26 26
         parent::__construct(
27 27
             array_combine(
28 28
                 $key_range,
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Credit_Card_Year_Input.input.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@
 block discarded – undo
10 10
 class EE_Credit_Card_Year_Input extends EE_Year_Input
11 11
 {
12 12
 
13
-    /**
14
-     * @param array $input_settings
15
-     * @param bool  $four_digit_year
16
-     * @param int   $years_behind
17
-     * @param int   $years_ahead
18
-     */
19
-    public function __construct($input_settings = array(), $four_digit_year = true, $years_behind = 0, $years_ahead = 15)
20
-    {
21
-        $this->set_sensitive_data_removal_strategy(new EE_All_Sensitive_Data_Removal());
22
-        parent::__construct($input_settings, $four_digit_year, $years_behind, $years_ahead);
23
-    }
13
+	/**
14
+	 * @param array $input_settings
15
+	 * @param bool  $four_digit_year
16
+	 * @param int   $years_behind
17
+	 * @param int   $years_ahead
18
+	 */
19
+	public function __construct($input_settings = array(), $four_digit_year = true, $years_behind = 0, $years_ahead = 15)
20
+	{
21
+		$this->set_sensitive_data_removal_strategy(new EE_All_Sensitive_Data_Removal());
22
+		parent::__construct($input_settings, $four_digit_year, $years_behind, $years_ahead);
23
+	}
24 24
 }
Please login to merge, or discard this patch.
libraries/form_sections/inputs/EE_Select_Ajax_Model_Rest_Input.input.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         );
68 68
         // make sure limit and caps are always set
69 69
         $query_params = array_merge(
70
-            array( 'limit' => 10, 'caps' => EEM_Base::caps_read_admin ),
70
+            array('limit' => 10, 'caps' => EEM_Base::caps_read_admin),
71 71
             $query_params
72 72
         );
73 73
         $this->_value_field_name = EEH_Array::is_set(
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
         $values_for_options = (array) $value;
147 147
         $value_field = $this->_get_model()->field_settings_for($this->_value_field_name);
148 148
         $display_field = $this->_get_model()->field_settings_for($this->_display_field_name);
149
-        $this->_extra_select_columns[] = $value_field->get_qualified_column() . ' AS ' . $this->_value_field_name;
150
-        $this->_extra_select_columns[] = $display_field->get_qualified_column() . ' AS ' . $this->_display_field_name;
149
+        $this->_extra_select_columns[] = $value_field->get_qualified_column().' AS '.$this->_value_field_name;
150
+        $this->_extra_select_columns[] = $display_field->get_qualified_column().' AS '.$this->_display_field_name;
151 151
         $display_values = $this->_get_model()->get_all_wpdb_results(
152 152
             array(
153 153
                 array(
154
-                    $this->_value_field_name => array( 'IN', $values_for_options )
154
+                    $this->_value_field_name => array('IN', $values_for_options)
155 155
                 )
156 156
             ),
157 157
             ARRAY_A,
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
         if (is_array($select_options)) {
162 162
             foreach ($display_values as $db_rows) {
163 163
                 $db_rows = (array) $db_rows;
164
-                $select_options[ $db_rows[ $this->_value_field_name ] ] = apply_filters(
164
+                $select_options[$db_rows[$this->_value_field_name]] = apply_filters(
165 165
                     'FHEE__EE_Select_Ajax_Model_Rest_Input___set_raw_value__select_option_value',
166
-                    $db_rows[ $this->_display_field_name ],
166
+                    $db_rows[$this->_display_field_name],
167 167
                     $db_rows
168 168
                 );
169 169
             }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      */
180 180
     protected function _get_model()
181 181
     {
182
-        if (! EE_Registry::instance()->is_model_name($this->_model_name)) {
182
+        if ( ! EE_Registry::instance()->is_model_name($this->_model_name)) {
183 183
             throw new EE_Error(
184 184
                 sprintf(
185 185
                     __(
Please login to merge, or discard this patch.
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -17,189 +17,189 @@
 block discarded – undo
17 17
 class EE_Select_Ajax_Model_Rest_Input extends EE_Form_Input_With_Options_Base
18 18
 {
19 19
 
20
-    /**
21
-     * @var string $_model_name
22
-     */
23
-    protected $_model_name;
20
+	/**
21
+	 * @var string $_model_name
22
+	 */
23
+	protected $_model_name;
24 24
 
25
-    /**
26
-     * @var string $_display_field_name
27
-     */
28
-    protected $_display_field_name;
25
+	/**
26
+	 * @var string $_display_field_name
27
+	 */
28
+	protected $_display_field_name;
29 29
 
30
-    /**
31
-     * @var string $_value_field_name
32
-     */
33
-    protected $_value_field_name;
30
+	/**
31
+	 * @var string $_value_field_name
32
+	 */
33
+	protected $_value_field_name;
34 34
 
35
-    /**
36
-     * @var array $_extra_select_columns
37
-     */
38
-    protected $_extra_select_columns = array();
35
+	/**
36
+	 * @var array $_extra_select_columns
37
+	 */
38
+	protected $_extra_select_columns = array();
39 39
 
40 40
 
41
-    /**
42
-     * @param array $input_settings     {
43
-     * @type string $model_name         the name of model to be used for searching, both via the REST API and server-side model queries
44
-     * @type array  $query_params       default query parameters which will apply to both REST API queries and server-side queries. This should be
45
-     *                                  in the exact format that will be used for server-side model usage (eg use index 0 for where conditions, not
46
-     *                                  the string "where")
47
-     * @type string $value_field_name   the name of the model field on this model to
48
-     *                                  be used for the HTML select's option's values
49
-     * @type string $display_field_name the name of the model field on this model
50
-     *                                  to be used for the HTML select's option's display text
51
-     * @type array  $select2_args       arguments to be passed directly into the select2's JS constructor
52
-     *                                  }
53
-     *                                  And the arguments accepted by EE_Form_Input_With_Options_Base
54
-     * }
55
-     * @throws EE_Error
56
-     * @throws InvalidArgumentException
57
-     * @throws InvalidDataTypeException
58
-     * @throws InvalidInterfaceException
59
-     */
60
-    public function __construct($input_settings = array())
61
-    {
62
-        // needed input settings:
63
-        // select2_args
64
-        $this->_model_name = EEH_Array::is_set(
65
-            $input_settings,
66
-            'model_name',
67
-            null
68
-        );
69
-        $model = $this->_get_model();
70
-        $query_params = EEH_Array::is_set(
71
-            $input_settings,
72
-            'query_params',
73
-            array()
74
-        );
75
-        // make sure limit and caps are always set
76
-        $query_params = array_merge(
77
-            array( 'limit' => 10, 'caps' => EEM_Base::caps_read_admin ),
78
-            $query_params
79
-        );
80
-        $this->_value_field_name = EEH_Array::is_set(
81
-            $input_settings,
82
-            'value_field_name',
83
-            $model->primary_key_name()
84
-        );
85
-        $this->_display_field_name = EEH_Array::is_set(
86
-            $input_settings,
87
-            'display_field_name',
88
-            $model->get_a_field_of_type('EE_Text_Field_Base')->get_name()
89
-        );
90
-        $this->_extra_select_columns = EEH_Array::is_set(
91
-            $input_settings,
92
-            'extra_select_columns',
93
-            array()
94
-        );
95
-        $this->_add_validation_strategy(
96
-            new EE_Model_Matching_Query_Validation_Strategy(
97
-                '',
98
-                $this->_model_name,
99
-                $query_params,
100
-                $this->_value_field_name
101
-            )
102
-        );
103
-        // get resource endpoint
104
-        $rest_controller = LoaderFactory::getLoader()->getNew(
105
-            'EventEspresso\core\libraries\rest_api\controllers\model\Read'
106
-        );
107
-        $rest_controller->setRequestedVersion(EED_Core_Rest_Api::latest_rest_api_version());
108
-        $default_select2_args = array(
109
-            'ajax' => array(
110
-                'url' => $rest_controller->getVersionedLinkTo(
111
-                    EEH_Inflector::pluralize_and_lower($this->_model_name)
112
-                ),
113
-                'dataType' => 'json',
114
-                'delay' => '250',
115
-                'data_interface' => 'EE_Select2_REST_API_Interface',
116
-                'data_interface_args' => array(
117
-                    'default_query_params' => (object) ModelDataTranslator::prepareQueryParamsForRestApi(
118
-                        $query_params,
119
-                        $model
120
-                    ),
121
-                    'display_field' => $this->_display_field_name,
122
-                    'value_field' => $this->_value_field_name,
123
-                    'nonce' => wp_create_nonce('wp_rest'),
124
-                    'locale' => str_replace('_', '-', strtolower(get_locale()))
125
-                ),
126
-            ),
127
-            'cache' => true,
128
-            'width' => 'resolve'
129
-        );
130
-        $select2_args = array_replace_recursive(
131
-            $default_select2_args,
132
-            (array) EEH_Array::is_set($input_settings, 'select2_args', array())
133
-        );
134
-        $this->set_display_strategy(new EE_Select2_Display_Strategy($select2_args));
135
-        parent::__construct(array(), $input_settings);
136
-    }
41
+	/**
42
+	 * @param array $input_settings     {
43
+	 * @type string $model_name         the name of model to be used for searching, both via the REST API and server-side model queries
44
+	 * @type array  $query_params       default query parameters which will apply to both REST API queries and server-side queries. This should be
45
+	 *                                  in the exact format that will be used for server-side model usage (eg use index 0 for where conditions, not
46
+	 *                                  the string "where")
47
+	 * @type string $value_field_name   the name of the model field on this model to
48
+	 *                                  be used for the HTML select's option's values
49
+	 * @type string $display_field_name the name of the model field on this model
50
+	 *                                  to be used for the HTML select's option's display text
51
+	 * @type array  $select2_args       arguments to be passed directly into the select2's JS constructor
52
+	 *                                  }
53
+	 *                                  And the arguments accepted by EE_Form_Input_With_Options_Base
54
+	 * }
55
+	 * @throws EE_Error
56
+	 * @throws InvalidArgumentException
57
+	 * @throws InvalidDataTypeException
58
+	 * @throws InvalidInterfaceException
59
+	 */
60
+	public function __construct($input_settings = array())
61
+	{
62
+		// needed input settings:
63
+		// select2_args
64
+		$this->_model_name = EEH_Array::is_set(
65
+			$input_settings,
66
+			'model_name',
67
+			null
68
+		);
69
+		$model = $this->_get_model();
70
+		$query_params = EEH_Array::is_set(
71
+			$input_settings,
72
+			'query_params',
73
+			array()
74
+		);
75
+		// make sure limit and caps are always set
76
+		$query_params = array_merge(
77
+			array( 'limit' => 10, 'caps' => EEM_Base::caps_read_admin ),
78
+			$query_params
79
+		);
80
+		$this->_value_field_name = EEH_Array::is_set(
81
+			$input_settings,
82
+			'value_field_name',
83
+			$model->primary_key_name()
84
+		);
85
+		$this->_display_field_name = EEH_Array::is_set(
86
+			$input_settings,
87
+			'display_field_name',
88
+			$model->get_a_field_of_type('EE_Text_Field_Base')->get_name()
89
+		);
90
+		$this->_extra_select_columns = EEH_Array::is_set(
91
+			$input_settings,
92
+			'extra_select_columns',
93
+			array()
94
+		);
95
+		$this->_add_validation_strategy(
96
+			new EE_Model_Matching_Query_Validation_Strategy(
97
+				'',
98
+				$this->_model_name,
99
+				$query_params,
100
+				$this->_value_field_name
101
+			)
102
+		);
103
+		// get resource endpoint
104
+		$rest_controller = LoaderFactory::getLoader()->getNew(
105
+			'EventEspresso\core\libraries\rest_api\controllers\model\Read'
106
+		);
107
+		$rest_controller->setRequestedVersion(EED_Core_Rest_Api::latest_rest_api_version());
108
+		$default_select2_args = array(
109
+			'ajax' => array(
110
+				'url' => $rest_controller->getVersionedLinkTo(
111
+					EEH_Inflector::pluralize_and_lower($this->_model_name)
112
+				),
113
+				'dataType' => 'json',
114
+				'delay' => '250',
115
+				'data_interface' => 'EE_Select2_REST_API_Interface',
116
+				'data_interface_args' => array(
117
+					'default_query_params' => (object) ModelDataTranslator::prepareQueryParamsForRestApi(
118
+						$query_params,
119
+						$model
120
+					),
121
+					'display_field' => $this->_display_field_name,
122
+					'value_field' => $this->_value_field_name,
123
+					'nonce' => wp_create_nonce('wp_rest'),
124
+					'locale' => str_replace('_', '-', strtolower(get_locale()))
125
+				),
126
+			),
127
+			'cache' => true,
128
+			'width' => 'resolve'
129
+		);
130
+		$select2_args = array_replace_recursive(
131
+			$default_select2_args,
132
+			(array) EEH_Array::is_set($input_settings, 'select2_args', array())
133
+		);
134
+		$this->set_display_strategy(new EE_Select2_Display_Strategy($select2_args));
135
+		parent::__construct(array(), $input_settings);
136
+	}
137 137
 
138 138
 
139 139
 
140
-    /**
141
-     * Before setting the raw value (usually because we're setting the default,
142
-     * or we've received a form submission and this might be re-displayed to the user),
143
-     * sets the options so that the current selections appear on initial display.
144
-     *
145
-     * Note: because this input uses EE_Model_Matching_Query_Validation_Strategy
146
-     * for validation, this input's options only affect DISPLAY and NOT validation,
147
-     * which is why its ok to just assume the provided $value to be in the list of acceptable values
148
-     *
149
-     * @param mixed $value
150
-     * @return void
151
-     * @throws \EE_Error
152
-     */
153
-    public function _set_raw_value($value)
154
-    {
155
-        $values_for_options = (array) $value;
156
-        $value_field = $this->_get_model()->field_settings_for($this->_value_field_name);
157
-        $display_field = $this->_get_model()->field_settings_for($this->_display_field_name);
158
-        $this->_extra_select_columns[] = $value_field->get_qualified_column() . ' AS ' . $this->_value_field_name;
159
-        $this->_extra_select_columns[] = $display_field->get_qualified_column() . ' AS ' . $this->_display_field_name;
160
-        $display_values = $this->_get_model()->get_all_wpdb_results(
161
-            array(
162
-                array(
163
-                    $this->_value_field_name => array( 'IN', $values_for_options )
164
-                )
165
-            ),
166
-            ARRAY_A,
167
-            implode(',', $this->_extra_select_columns)
168
-        );
169
-        $select_options = array();
170
-        if (is_array($select_options)) {
171
-            foreach ($display_values as $db_rows) {
172
-                $db_rows = (array) $db_rows;
173
-                $select_options[ $db_rows[ $this->_value_field_name ] ] = apply_filters(
174
-                    'FHEE__EE_Select_Ajax_Model_Rest_Input___set_raw_value__select_option_value',
175
-                    $db_rows[ $this->_display_field_name ],
176
-                    $db_rows
177
-                );
178
-            }
179
-        }
180
-        $this->set_select_options($select_options);
181
-        parent::_set_raw_value($value);
182
-    }
140
+	/**
141
+	 * Before setting the raw value (usually because we're setting the default,
142
+	 * or we've received a form submission and this might be re-displayed to the user),
143
+	 * sets the options so that the current selections appear on initial display.
144
+	 *
145
+	 * Note: because this input uses EE_Model_Matching_Query_Validation_Strategy
146
+	 * for validation, this input's options only affect DISPLAY and NOT validation,
147
+	 * which is why its ok to just assume the provided $value to be in the list of acceptable values
148
+	 *
149
+	 * @param mixed $value
150
+	 * @return void
151
+	 * @throws \EE_Error
152
+	 */
153
+	public function _set_raw_value($value)
154
+	{
155
+		$values_for_options = (array) $value;
156
+		$value_field = $this->_get_model()->field_settings_for($this->_value_field_name);
157
+		$display_field = $this->_get_model()->field_settings_for($this->_display_field_name);
158
+		$this->_extra_select_columns[] = $value_field->get_qualified_column() . ' AS ' . $this->_value_field_name;
159
+		$this->_extra_select_columns[] = $display_field->get_qualified_column() . ' AS ' . $this->_display_field_name;
160
+		$display_values = $this->_get_model()->get_all_wpdb_results(
161
+			array(
162
+				array(
163
+					$this->_value_field_name => array( 'IN', $values_for_options )
164
+				)
165
+			),
166
+			ARRAY_A,
167
+			implode(',', $this->_extra_select_columns)
168
+		);
169
+		$select_options = array();
170
+		if (is_array($select_options)) {
171
+			foreach ($display_values as $db_rows) {
172
+				$db_rows = (array) $db_rows;
173
+				$select_options[ $db_rows[ $this->_value_field_name ] ] = apply_filters(
174
+					'FHEE__EE_Select_Ajax_Model_Rest_Input___set_raw_value__select_option_value',
175
+					$db_rows[ $this->_display_field_name ],
176
+					$db_rows
177
+				);
178
+			}
179
+		}
180
+		$this->set_select_options($select_options);
181
+		parent::_set_raw_value($value);
182
+	}
183 183
 
184
-    /**
185
-     * Returns the model, or throws an exception if the model name provided in constructor doesn't exist
186
-     * @return EEM_Base
187
-     * @throws EE_Error
188
-     */
189
-    protected function _get_model()
190
-    {
191
-        if (! EE_Registry::instance()->is_model_name($this->_model_name)) {
192
-            throw new EE_Error(
193
-                sprintf(
194
-                    __(
195
-                        '%1$s is not a proper model name. Please provide a model name in the "model_name" form input argument',
196
-                        'event_espresso'
197
-                    ),
198
-                    $this->_model_name
199
-                )
200
-            );
201
-        } else {
202
-            return EE_Registry::instance()->load_model($this->_model_name);
203
-        }
204
-    }
184
+	/**
185
+	 * Returns the model, or throws an exception if the model name provided in constructor doesn't exist
186
+	 * @return EEM_Base
187
+	 * @throws EE_Error
188
+	 */
189
+	protected function _get_model()
190
+	{
191
+		if (! EE_Registry::instance()->is_model_name($this->_model_name)) {
192
+			throw new EE_Error(
193
+				sprintf(
194
+					__(
195
+						'%1$s is not a proper model name. Please provide a model name in the "model_name" form input argument',
196
+						'event_espresso'
197
+					),
198
+					$this->_model_name
199
+				)
200
+			);
201
+		} else {
202
+			return EE_Registry::instance()->load_model($this->_model_name);
203
+		}
204
+	}
205 205
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Credit_Card_Input.input.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -10,16 +10,16 @@
 block discarded – undo
10 10
 class EE_Credit_Card_Input extends EE_Form_Input_Base
11 11
 {
12 12
 
13
-    /**
14
-     * @param array $input_settings
15
-     */
16
-    public function __construct($input_settings = array())
17
-    {
18
-        $input_settings['required'] = isset($input_settings['required']) ? $input_settings['required'] : true;
19
-        $this->_set_display_strategy(new EE_Text_Input_Display_Strategy());
20
-        $this->_set_normalization_strategy(new EE_Credit_Card_Normalization());
21
-        $this->_add_validation_strategy(new EE_Credit_Card_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null));
22
-        $this->set_sensitive_data_removal_strategy(new EE_Credit_Card_Sensitive_Data_Removal());
23
-        parent::__construct($input_settings);
24
-    }
13
+	/**
14
+	 * @param array $input_settings
15
+	 */
16
+	public function __construct($input_settings = array())
17
+	{
18
+		$input_settings['required'] = isset($input_settings['required']) ? $input_settings['required'] : true;
19
+		$this->_set_display_strategy(new EE_Text_Input_Display_Strategy());
20
+		$this->_set_normalization_strategy(new EE_Credit_Card_Normalization());
21
+		$this->_add_validation_strategy(new EE_Credit_Card_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null));
22
+		$this->set_sensitive_data_removal_strategy(new EE_Credit_Card_Sensitive_Data_Removal());
23
+		parent::__construct($input_settings);
24
+	}
25 25
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Integer_Input.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -12,35 +12,35 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * @param array $input_settings
17
-     */
18
-    public function __construct($input_settings = array())
19
-    {
20
-        $this->_set_display_strategy(
21
-            new EE_Number_Input_Display_Strategy(
22
-                isset($input_settings['min_value'])
23
-                    ? $input_settings['min_value']
24
-                    : null,
25
-                isset($input_settings['max_value'])
26
-                    ? $input_settings['max_value']
27
-                    : null
28
-            )
29
-        );
30
-        $this->_set_normalization_strategy(
31
-            new EE_Int_Normalization(
32
-                isset($input_settings['validation_error_message'])
33
-                    ? $input_settings['validation_error_message']
34
-                    : null
35
-            )
36
-        );
37
-        $this->_add_validation_strategy(
38
-            new EE_Int_Validation_Strategy(
39
-                isset($input_settings['validation_error_message'])
40
-                    ? $input_settings['validation_error_message']
41
-                    : null
42
-            )
43
-        );
44
-        parent::__construct($input_settings);
45
-    }
15
+	/**
16
+	 * @param array $input_settings
17
+	 */
18
+	public function __construct($input_settings = array())
19
+	{
20
+		$this->_set_display_strategy(
21
+			new EE_Number_Input_Display_Strategy(
22
+				isset($input_settings['min_value'])
23
+					? $input_settings['min_value']
24
+					: null,
25
+				isset($input_settings['max_value'])
26
+					? $input_settings['max_value']
27
+					: null
28
+			)
29
+		);
30
+		$this->_set_normalization_strategy(
31
+			new EE_Int_Normalization(
32
+				isset($input_settings['validation_error_message'])
33
+					? $input_settings['validation_error_message']
34
+					: null
35
+			)
36
+		);
37
+		$this->_add_validation_strategy(
38
+			new EE_Int_Validation_Strategy(
39
+				isset($input_settings['validation_error_message'])
40
+					? $input_settings['validation_error_message']
41
+					: null
42
+			)
43
+		);
44
+		parent::__construct($input_settings);
45
+	}
46 46
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Hidden_Input.input.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -9,28 +9,28 @@
 block discarded – undo
9 9
 class EE_Hidden_Input extends EE_Form_Input_Base
10 10
 {
11 11
 
12
-    /**
13
-     * @param array $input_settings
14
-     */
15
-    public function __construct($input_settings = array())
16
-    {
17
-        // require_once('strategies/display_strategies/EE_Text_Input_Display_Strategy.strategy.php');
18
-        $this->_set_display_strategy(new EE_Hidden_Display_Strategy());
19
-        if (isset($input_settings['normalization_strategy']) && $input_settings['normalization_strategy'] instanceof EE_Normalization_Strategy_Base) {
20
-            $this->_set_normalization_strategy($input_settings['normalization_strategy']);
21
-        } else {
22
-            $this->_set_normalization_strategy(new EE_Text_Normalization());
23
-        }
24
-        parent::__construct($input_settings);
25
-    }
12
+	/**
13
+	 * @param array $input_settings
14
+	 */
15
+	public function __construct($input_settings = array())
16
+	{
17
+		// require_once('strategies/display_strategies/EE_Text_Input_Display_Strategy.strategy.php');
18
+		$this->_set_display_strategy(new EE_Hidden_Display_Strategy());
19
+		if (isset($input_settings['normalization_strategy']) && $input_settings['normalization_strategy'] instanceof EE_Normalization_Strategy_Base) {
20
+			$this->_set_normalization_strategy($input_settings['normalization_strategy']);
21
+		} else {
22
+			$this->_set_normalization_strategy(new EE_Text_Normalization());
23
+		}
24
+		parent::__construct($input_settings);
25
+	}
26 26
 
27 27
 
28 28
 
29
-    /**
30
-     * @return string
31
-     */
32
-    public function get_html_for_label()
33
-    {
34
-        return '';
35
-    }
29
+	/**
30
+	 * @return string
31
+	 */
32
+	public function get_html_for_label()
33
+	{
34
+		return '';
35
+	}
36 36
 }
Please login to merge, or discard this patch.