Completed
Branch dev (08e10f)
by
unknown
12:20 queued 10:12
created
core/services/assets/AssetCollection.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             /** @var Asset $asset */
76 76
             $asset = $this->current();
77 77
             if ($asset->type() === $type) {
78
-                $files[ $asset->handle() ] = $asset;
78
+                $files[$asset->handle()] = $asset;
79 79
             }
80 80
             $this->next();
81 81
         }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             /** @var JavascriptAsset $asset */
97 97
             $asset = $this->current();
98 98
             if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) {
99
-                $files[ $asset->handle() ] = $asset;
99
+                $files[$asset->handle()] = $asset;
100 100
             }
101 101
             $this->next();
102 102
         }
Please login to merge, or discard this patch.
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -21,192 +21,192 @@
 block discarded – undo
21 21
 {
22 22
 
23 23
 
24
-    /**
25
-     * AssetCollection constructor
26
-     *
27
-     * @throws InvalidInterfaceException
28
-     */
29
-    public function __construct()
30
-    {
31
-        parent::__construct('EventEspresso\core\domain\values\assets\Asset');
32
-    }
33
-
34
-
35
-    /**
36
-     * @return StylesheetAsset[]
37
-     * @since 4.9.62.p
38
-     */
39
-    public function getStylesheetAssets()
40
-    {
41
-        return $this->getAssetsOfType(Asset::TYPE_CSS);
42
-    }
43
-
44
-
45
-    /**
46
-     * @return JavascriptAsset[]
47
-     * @since 4.9.62.p
48
-     */
49
-    public function getJavascriptAssets()
50
-    {
51
-        return $this->getAssetsOfType(Asset::TYPE_JS);
52
-    }
53
-
54
-
55
-    /**
56
-     * @return ManifestFile[]
57
-     * @since 4.9.62.p
58
-     */
59
-    public function getManifestFiles()
60
-    {
61
-        return $this->getAssetsOfType(Asset::TYPE_MANIFEST);
62
-    }
63
-
64
-
65
-    /**
66
-     * @param $type
67
-     * @return JavascriptAsset[]|StylesheetAsset[]|ManifestFile[]
68
-     * @since 4.9.62.p
69
-     */
70
-    protected function getAssetsOfType($type)
71
-    {
72
-        $files = array();
73
-        $this->rewind();
74
-        while ($this->valid()) {
75
-            /** @var Asset $asset */
76
-            $asset = $this->current();
77
-            if ($asset->type() === $type) {
78
-                $files[ $asset->handle() ] = $asset;
79
-            }
80
-            $this->next();
81
-        }
82
-        $this->rewind();
83
-        return $files;
84
-    }
85
-
86
-
87
-    /**
88
-     * @return JavascriptAsset[]
89
-     * @since 4.9.62.p
90
-     */
91
-    public function getJavascriptAssetsWithData()
92
-    {
93
-        $files = array();
94
-        $this->rewind();
95
-        while ($this->valid()) {
96
-            /** @var JavascriptAsset $asset */
97
-            $asset = $this->current();
98
-            if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) {
99
-                $files[ $asset->handle() ] = $asset;
100
-            }
101
-            $this->next();
102
-        }
103
-        $this->rewind();
104
-        return $files;
105
-    }
106
-
107
-
108
-    /**
109
-     * returns TRUE or FALSE
110
-     * depending on whether the object is within the Collection
111
-     * based on the supplied $identifier and type
112
-     *
113
-     * @param  mixed $identifier
114
-     * @param string $type
115
-     * @return bool
116
-     * @since 4.9.63.p
117
-     */
118
-    public function hasAssetOfType($identifier, $type = Asset::TYPE_JS)
119
-    {
120
-        $this->rewind();
121
-        while ($this->valid()) {
122
-            if ($this->getInfo() === $identifier && $this->current()->type() === $type) {
123
-                $this->rewind();
124
-                return true;
125
-            }
126
-            $this->next();
127
-        }
128
-        return false;
129
-    }
130
-
131
-
132
-    /**
133
-     * returns TRUE or FALSE
134
-     * depending on whether the Javascript Asset is within the Collection
135
-     * based on the supplied $identifier
136
-     *
137
-     * @param  mixed $identifier
138
-     * @return bool
139
-     * @since 4.9.63.p
140
-     */
141
-    public function hasJavascriptAsset($identifier)
142
-    {
143
-        return $this->hasAssetOfType($identifier, Asset::TYPE_JS);
144
-    }
145
-
146
-
147
-    /**
148
-     * returns TRUE or FALSE
149
-     * depending on whether the Stylesheet Asset is within the Collection
150
-     * based on the supplied $identifier
151
-     *
152
-     * @param  mixed $identifier
153
-     * @return bool
154
-     * @since 4.9.63.p
155
-     */
156
-    public function hasStylesheetAsset($identifier)
157
-    {
158
-        return $this->hasAssetOfType($identifier, Asset::TYPE_CSS);
159
-    }
160
-
161
-    /**
162
-     * returns the object from the Collection
163
-     * based on the supplied $identifier and type
164
-     *
165
-     * @param  mixed $identifier
166
-     * @param string $type
167
-     * @return JavascriptAsset|StylesheetAsset
168
-     * @since 4.9.63.p
169
-     */
170
-    public function getAssetOfType($identifier, $type = Asset::TYPE_JS)
171
-    {
172
-        $this->rewind();
173
-        while ($this->valid()) {
174
-            if ($this->getInfo() === $identifier && $this->current()->type() === $type) {
175
-                /** @var JavascriptAsset|StylesheetAsset $object */
176
-                $object = $this->current();
177
-                $this->rewind();
178
-                return $object;
179
-            }
180
-            $this->next();
181
-        }
182
-        return null;
183
-    }
184
-
185
-
186
-    /**
187
-     * returns the Stylesheet Asset from the Collection
188
-     * based on the supplied $identifier
189
-     *
190
-     * @param  mixed $identifier
191
-     * @return StylesheetAsset
192
-     * @since 4.9.63.p
193
-     */
194
-    public function getStylesheetAsset($identifier)
195
-    {
196
-        return $this->getAssetOfType($identifier, Asset::TYPE_CSS);
197
-    }
198
-
199
-
200
-    /**
201
-     * returns the Javascript Asset from the Collection
202
-     * based on the supplied $identifier
203
-     *
204
-     * @param  mixed $identifier
205
-     * @return JavascriptAsset
206
-     * @since 4.9.63.p
207
-     */
208
-    public function getJavascriptAsset($identifier)
209
-    {
210
-        return $this->getAssetOfType($identifier, Asset::TYPE_JS);
211
-    }
24
+	/**
25
+	 * AssetCollection constructor
26
+	 *
27
+	 * @throws InvalidInterfaceException
28
+	 */
29
+	public function __construct()
30
+	{
31
+		parent::__construct('EventEspresso\core\domain\values\assets\Asset');
32
+	}
33
+
34
+
35
+	/**
36
+	 * @return StylesheetAsset[]
37
+	 * @since 4.9.62.p
38
+	 */
39
+	public function getStylesheetAssets()
40
+	{
41
+		return $this->getAssetsOfType(Asset::TYPE_CSS);
42
+	}
43
+
44
+
45
+	/**
46
+	 * @return JavascriptAsset[]
47
+	 * @since 4.9.62.p
48
+	 */
49
+	public function getJavascriptAssets()
50
+	{
51
+		return $this->getAssetsOfType(Asset::TYPE_JS);
52
+	}
53
+
54
+
55
+	/**
56
+	 * @return ManifestFile[]
57
+	 * @since 4.9.62.p
58
+	 */
59
+	public function getManifestFiles()
60
+	{
61
+		return $this->getAssetsOfType(Asset::TYPE_MANIFEST);
62
+	}
63
+
64
+
65
+	/**
66
+	 * @param $type
67
+	 * @return JavascriptAsset[]|StylesheetAsset[]|ManifestFile[]
68
+	 * @since 4.9.62.p
69
+	 */
70
+	protected function getAssetsOfType($type)
71
+	{
72
+		$files = array();
73
+		$this->rewind();
74
+		while ($this->valid()) {
75
+			/** @var Asset $asset */
76
+			$asset = $this->current();
77
+			if ($asset->type() === $type) {
78
+				$files[ $asset->handle() ] = $asset;
79
+			}
80
+			$this->next();
81
+		}
82
+		$this->rewind();
83
+		return $files;
84
+	}
85
+
86
+
87
+	/**
88
+	 * @return JavascriptAsset[]
89
+	 * @since 4.9.62.p
90
+	 */
91
+	public function getJavascriptAssetsWithData()
92
+	{
93
+		$files = array();
94
+		$this->rewind();
95
+		while ($this->valid()) {
96
+			/** @var JavascriptAsset $asset */
97
+			$asset = $this->current();
98
+			if ($asset->type() === Asset::TYPE_JS && $asset->hasInlineData()) {
99
+				$files[ $asset->handle() ] = $asset;
100
+			}
101
+			$this->next();
102
+		}
103
+		$this->rewind();
104
+		return $files;
105
+	}
106
+
107
+
108
+	/**
109
+	 * returns TRUE or FALSE
110
+	 * depending on whether the object is within the Collection
111
+	 * based on the supplied $identifier and type
112
+	 *
113
+	 * @param  mixed $identifier
114
+	 * @param string $type
115
+	 * @return bool
116
+	 * @since 4.9.63.p
117
+	 */
118
+	public function hasAssetOfType($identifier, $type = Asset::TYPE_JS)
119
+	{
120
+		$this->rewind();
121
+		while ($this->valid()) {
122
+			if ($this->getInfo() === $identifier && $this->current()->type() === $type) {
123
+				$this->rewind();
124
+				return true;
125
+			}
126
+			$this->next();
127
+		}
128
+		return false;
129
+	}
130
+
131
+
132
+	/**
133
+	 * returns TRUE or FALSE
134
+	 * depending on whether the Javascript Asset is within the Collection
135
+	 * based on the supplied $identifier
136
+	 *
137
+	 * @param  mixed $identifier
138
+	 * @return bool
139
+	 * @since 4.9.63.p
140
+	 */
141
+	public function hasJavascriptAsset($identifier)
142
+	{
143
+		return $this->hasAssetOfType($identifier, Asset::TYPE_JS);
144
+	}
145
+
146
+
147
+	/**
148
+	 * returns TRUE or FALSE
149
+	 * depending on whether the Stylesheet Asset is within the Collection
150
+	 * based on the supplied $identifier
151
+	 *
152
+	 * @param  mixed $identifier
153
+	 * @return bool
154
+	 * @since 4.9.63.p
155
+	 */
156
+	public function hasStylesheetAsset($identifier)
157
+	{
158
+		return $this->hasAssetOfType($identifier, Asset::TYPE_CSS);
159
+	}
160
+
161
+	/**
162
+	 * returns the object from the Collection
163
+	 * based on the supplied $identifier and type
164
+	 *
165
+	 * @param  mixed $identifier
166
+	 * @param string $type
167
+	 * @return JavascriptAsset|StylesheetAsset
168
+	 * @since 4.9.63.p
169
+	 */
170
+	public function getAssetOfType($identifier, $type = Asset::TYPE_JS)
171
+	{
172
+		$this->rewind();
173
+		while ($this->valid()) {
174
+			if ($this->getInfo() === $identifier && $this->current()->type() === $type) {
175
+				/** @var JavascriptAsset|StylesheetAsset $object */
176
+				$object = $this->current();
177
+				$this->rewind();
178
+				return $object;
179
+			}
180
+			$this->next();
181
+		}
182
+		return null;
183
+	}
184
+
185
+
186
+	/**
187
+	 * returns the Stylesheet Asset from the Collection
188
+	 * based on the supplied $identifier
189
+	 *
190
+	 * @param  mixed $identifier
191
+	 * @return StylesheetAsset
192
+	 * @since 4.9.63.p
193
+	 */
194
+	public function getStylesheetAsset($identifier)
195
+	{
196
+		return $this->getAssetOfType($identifier, Asset::TYPE_CSS);
197
+	}
198
+
199
+
200
+	/**
201
+	 * returns the Javascript Asset from the Collection
202
+	 * based on the supplied $identifier
203
+	 *
204
+	 * @param  mixed $identifier
205
+	 * @return JavascriptAsset
206
+	 * @since 4.9.63.p
207
+	 */
208
+	public function getJavascriptAsset($identifier)
209
+	{
210
+		return $this->getAssetOfType($identifier, Asset::TYPE_JS);
211
+	}
212 212
 }
Please login to merge, or discard this patch.
core/domain/services/admin/privacy/forms/PrivacySettingsFormHandler.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -28,112 +28,112 @@
 block discarded – undo
28 28
 class PrivacySettingsFormHandler extends FormHandler
29 29
 {
30 30
 
31
-    /**
32
-     * @var EE_Config
33
-     */
34
-    protected $config;
31
+	/**
32
+	 * @var EE_Config
33
+	 */
34
+	protected $config;
35 35
 
36 36
 
37
-    /**
38
-     * PrivacySettingsFormHandler constructor.
39
-     *
40
-     * @param EE_Registry $registry
41
-     * @param EE_Config   $config
42
-     */
43
-    public function __construct(EE_Registry $registry, EE_Config $config)
44
-    {
45
-        $this->config = $config;
46
-        parent::__construct(
47
-            esc_html__('Privacy Settings', 'event_espresso'),
48
-            esc_html__('Privacy Settings', 'event_espresso'),
49
-            'privacy-settings',
50
-            '',
51
-            FormHandler::DO_NOT_SETUP_FORM,
52
-            $registry
53
-        );
54
-    }
37
+	/**
38
+	 * PrivacySettingsFormHandler constructor.
39
+	 *
40
+	 * @param EE_Registry $registry
41
+	 * @param EE_Config   $config
42
+	 */
43
+	public function __construct(EE_Registry $registry, EE_Config $config)
44
+	{
45
+		$this->config = $config;
46
+		parent::__construct(
47
+			esc_html__('Privacy Settings', 'event_espresso'),
48
+			esc_html__('Privacy Settings', 'event_espresso'),
49
+			'privacy-settings',
50
+			'',
51
+			FormHandler::DO_NOT_SETUP_FORM,
52
+			$registry
53
+		);
54
+	}
55 55
 
56 56
 
57
-    /**
58
-     * creates and returns the actual form
59
-     *
60
-     * @return EE_Form_Section_Proper
61
-     */
62
-    public function generate()
63
-    {
64
-        // this form makes use of the session for passing around invalid form submission data, so make sure its enabled
65
-        add_filter('FHEE__EE_Session___save_session_to_db__abort_session_save', '__return_false');
66
-        /**
67
-         * @var $reg_config EE_Registration_Config
68
-         */
69
-        $reg_config = $this->config->registration;
70
-        return new EE_Form_Section_Proper(
71
-            array(
72
-                'name'        => 'privacy_consent_settings',
73
-                'subsections' => array(
74
-                    'privacy_consent_form_hdr' => new EE_Form_Section_HTML(
75
-                        EEH_HTML::h2(esc_html__('Privacy Policy Consent Settings', 'event_espresso'))
76
-                    ),
77
-                    'enable'                   => new EE_Select_Reveal_Input(
78
-                        array(
79
-                            'enable-privacy-consent' => esc_html__('Enabled', 'event_espresso'),
80
-                            'disable'                => esc_html__('Disabled', 'event_espresso'),
81
-                        ),
82
-                        array(
83
-                            'default'         => $reg_config->isConsentCheckboxEnabled()
84
-                                ? 'enable-privacy-consent'
85
-                                : 'disable',
86
-                            'html_label_text' => esc_html__('Privacy Consent Checkbox', 'event_espresso'),
87
-                            'html_help_text'  => esc_html__(
88
-                                'When enabled, a checkbox appears in the registration form requiring users to consent to your site\'s privacy policy.',
89
-                                'event_espresso'
90
-                            ),
91
-                        )
92
-                    ),
93
-                    'enable-privacy-consent'   => new EE_Form_Section_Proper(
94
-                        array(
95
-                            'subsections' => array(
96
-                                'consent_assertion' => new EE_Text_Area_Input(
97
-                                    array(
98
-                                        'default'               => $reg_config->getConsentCheckboxLabelText(),
99
-                                        'html_label_text'       => esc_html__('Consent Text', 'event_espresso'),
100
-                                        'html_help_text'        => esc_html__(
101
-                                            'Text describing what the registrant is consenting to by submitting their personal data in the registration form. To reset to default value, remove all this text and save.',
102
-                                            'event_espresso'
103
-                                        ),
104
-                                        'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
105
-                                    )
106
-                                ),
107
-                            ),
108
-                        )
109
-                    ),
110
-                ),
111
-            )
112
-        );
113
-    }
57
+	/**
58
+	 * creates and returns the actual form
59
+	 *
60
+	 * @return EE_Form_Section_Proper
61
+	 */
62
+	public function generate()
63
+	{
64
+		// this form makes use of the session for passing around invalid form submission data, so make sure its enabled
65
+		add_filter('FHEE__EE_Session___save_session_to_db__abort_session_save', '__return_false');
66
+		/**
67
+		 * @var $reg_config EE_Registration_Config
68
+		 */
69
+		$reg_config = $this->config->registration;
70
+		return new EE_Form_Section_Proper(
71
+			array(
72
+				'name'        => 'privacy_consent_settings',
73
+				'subsections' => array(
74
+					'privacy_consent_form_hdr' => new EE_Form_Section_HTML(
75
+						EEH_HTML::h2(esc_html__('Privacy Policy Consent Settings', 'event_espresso'))
76
+					),
77
+					'enable'                   => new EE_Select_Reveal_Input(
78
+						array(
79
+							'enable-privacy-consent' => esc_html__('Enabled', 'event_espresso'),
80
+							'disable'                => esc_html__('Disabled', 'event_espresso'),
81
+						),
82
+						array(
83
+							'default'         => $reg_config->isConsentCheckboxEnabled()
84
+								? 'enable-privacy-consent'
85
+								: 'disable',
86
+							'html_label_text' => esc_html__('Privacy Consent Checkbox', 'event_espresso'),
87
+							'html_help_text'  => esc_html__(
88
+								'When enabled, a checkbox appears in the registration form requiring users to consent to your site\'s privacy policy.',
89
+								'event_espresso'
90
+							),
91
+						)
92
+					),
93
+					'enable-privacy-consent'   => new EE_Form_Section_Proper(
94
+						array(
95
+							'subsections' => array(
96
+								'consent_assertion' => new EE_Text_Area_Input(
97
+									array(
98
+										'default'               => $reg_config->getConsentCheckboxLabelText(),
99
+										'html_label_text'       => esc_html__('Consent Text', 'event_espresso'),
100
+										'html_help_text'        => esc_html__(
101
+											'Text describing what the registrant is consenting to by submitting their personal data in the registration form. To reset to default value, remove all this text and save.',
102
+											'event_espresso'
103
+										),
104
+										'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
105
+									)
106
+								),
107
+							),
108
+						)
109
+					),
110
+				),
111
+			)
112
+		);
113
+	}
114 114
 
115 115
 
116
-    /**
117
-     * After validating the form data, update the registration config
118
-     *
119
-     * @param array $submitted_form_data
120
-     * @return bool
121
-     */
122
-    public function process($submitted_form_data = array())
123
-    {
124
-        try {
125
-            $valid_data = parent::process($submitted_form_data);
126
-            $reg_config = $this->config->registration;
127
-            $reg_config->setConsentCheckboxEnabled($valid_data['enable'] === 'enable-privacy-consent');
128
-            $reg_config->setConsentCheckboxLabelText(
129
-                $valid_data['enable-privacy-consent']['consent_assertion']
130
-            );
131
-            return $this->config->update_espresso_config(false, false);
132
-        } catch (InvalidFormSubmissionException $e) {
133
-            // the form was invalid, it should be re-displayed with errors
134
-            return false;
135
-        }
136
-    }
116
+	/**
117
+	 * After validating the form data, update the registration config
118
+	 *
119
+	 * @param array $submitted_form_data
120
+	 * @return bool
121
+	 */
122
+	public function process($submitted_form_data = array())
123
+	{
124
+		try {
125
+			$valid_data = parent::process($submitted_form_data);
126
+			$reg_config = $this->config->registration;
127
+			$reg_config->setConsentCheckboxEnabled($valid_data['enable'] === 'enable-privacy-consent');
128
+			$reg_config->setConsentCheckboxLabelText(
129
+				$valid_data['enable-privacy-consent']['consent_assertion']
130
+			);
131
+			return $this->config->update_espresso_config(false, false);
132
+		} catch (InvalidFormSubmissionException $e) {
133
+			// the form was invalid, it should be re-displayed with errors
134
+			return false;
135
+		}
136
+	}
137 137
 }
138 138
 // End of file PrivacySettingsFormHandler.php
139 139
 // Location: EventEspresso\core\domain\services\admin\privacy\forms/PrivacySettingsFormHandler.php
Please login to merge, or discard this patch.
admin_pages/general_settings/OrganizationSettings.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -447,8 +447,8 @@  discard block
 block discarded – undo
447 447
         $this->organization_config->instagram = isset($form_data['organization_instagram'])
448 448
             ? esc_url_raw($form_data['organization_instagram'])
449 449
             : $this->organization_config->instagram;
450
-        $this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
451
-            ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
450
+        $this->core_config->ee_ueip_optin = isset($form_data[EE_Core_Config::OPTION_NAME_UXIP][0])
451
+            ? filter_var($form_data[EE_Core_Config::OPTION_NAME_UXIP][0], FILTER_VALIDATE_BOOLEAN)
452 452
             : false;
453 453
         $this->core_config->ee_ueip_has_notified = true;
454 454
 
@@ -479,10 +479,10 @@  discard block
 block discarded – undo
479 479
         if (empty($this->network_core_config->site_license_key)) {
480 480
             return false;
481 481
         }
482
-        $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
482
+        $ver_option_key = 'puvererr_'.basename(EE_PLUGIN_BASENAME);
483 483
         $verify_fail = get_option($ver_option_key, false);
484 484
         return $verify_fail === false
485
-                  || (! empty($this->network_core_config->site_license_key)
485
+                  || ( ! empty($this->network_core_config->site_license_key)
486 486
                         && $verify_fail === false
487 487
                   );
488 488
     }
@@ -528,6 +528,6 @@  discard block
 block discarded – undo
528 528
     private function getValidationIndicator()
529 529
     {
530 530
         $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
531
-        return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
531
+        return '<span class="dashicons dashicons-admin-network '.$verified_class.' ee-icon-size-20"></span>';
532 532
     }
533 533
 }
Please login to merge, or discard this patch.
Indentation   +505 added lines, -505 removed lines patch added patch discarded remove patch
@@ -44,530 +44,530 @@
 block discarded – undo
44 44
 class OrganizationSettings extends FormHandler
45 45
 {
46 46
 
47
-    /**
48
-     * @var EE_Organization_Config
49
-     */
50
-    protected $organization_config;
47
+	/**
48
+	 * @var EE_Organization_Config
49
+	 */
50
+	protected $organization_config;
51 51
 
52
-    /**
53
-     * @var EE_Core_Config
54
-     */
55
-    protected $core_config;
52
+	/**
53
+	 * @var EE_Core_Config
54
+	 */
55
+	protected $core_config;
56 56
 
57 57
 
58
-    /**
59
-     * @var EE_Network_Core_Config
60
-     */
61
-    protected $network_core_config;
58
+	/**
59
+	 * @var EE_Network_Core_Config
60
+	 */
61
+	protected $network_core_config;
62 62
 
63
-    /**
64
-     * @var CountrySubRegionDao $countrySubRegionDao
65
-     */
66
-    protected $countrySubRegionDao;
63
+	/**
64
+	 * @var CountrySubRegionDao $countrySubRegionDao
65
+	 */
66
+	protected $countrySubRegionDao;
67 67
 
68
-    /**
69
-     * Form constructor.
70
-     *
71
-     * @param EE_Registry             $registry
72
-     * @param EE_Organization_Config  $organization_config
73
-     * @param EE_Core_Config          $core_config
74
-     * @param EE_Network_Core_Config $network_core_config
75
-     * @param CountrySubRegionDao $countrySubRegionDao
76
-     * @throws InvalidArgumentException
77
-     * @throws InvalidDataTypeException
78
-     * @throws DomainException
79
-     */
80
-    public function __construct(
81
-        EE_Registry $registry,
82
-        EE_Organization_Config $organization_config,
83
-        EE_Core_Config $core_config,
84
-        EE_Network_Core_Config $network_core_config,
85
-        CountrySubRegionDao $countrySubRegionDao
86
-    ) {
87
-        $this->organization_config = $organization_config;
88
-        $this->core_config = $core_config;
89
-        $this->network_core_config = $network_core_config;
90
-        $this->countrySubRegionDao = $countrySubRegionDao;
91
-        parent::__construct(
92
-            esc_html__('Your Organization Settings', 'event_espresso'),
93
-            esc_html__('Your Organization Settings', 'event_espresso'),
94
-            'organization_settings',
95
-            '',
96
-            FormHandler::DO_NOT_SETUP_FORM,
97
-            $registry
98
-        );
99
-    }
68
+	/**
69
+	 * Form constructor.
70
+	 *
71
+	 * @param EE_Registry             $registry
72
+	 * @param EE_Organization_Config  $organization_config
73
+	 * @param EE_Core_Config          $core_config
74
+	 * @param EE_Network_Core_Config $network_core_config
75
+	 * @param CountrySubRegionDao $countrySubRegionDao
76
+	 * @throws InvalidArgumentException
77
+	 * @throws InvalidDataTypeException
78
+	 * @throws DomainException
79
+	 */
80
+	public function __construct(
81
+		EE_Registry $registry,
82
+		EE_Organization_Config $organization_config,
83
+		EE_Core_Config $core_config,
84
+		EE_Network_Core_Config $network_core_config,
85
+		CountrySubRegionDao $countrySubRegionDao
86
+	) {
87
+		$this->organization_config = $organization_config;
88
+		$this->core_config = $core_config;
89
+		$this->network_core_config = $network_core_config;
90
+		$this->countrySubRegionDao = $countrySubRegionDao;
91
+		parent::__construct(
92
+			esc_html__('Your Organization Settings', 'event_espresso'),
93
+			esc_html__('Your Organization Settings', 'event_espresso'),
94
+			'organization_settings',
95
+			'',
96
+			FormHandler::DO_NOT_SETUP_FORM,
97
+			$registry
98
+		);
99
+	}
100 100
 
101 101
 
102
-    /**
103
-     * creates and returns the actual form
104
-     *
105
-     * @return EE_Form_Section_Proper
106
-     * @throws EE_Error
107
-     * @throws InvalidArgumentException
108
-     * @throws InvalidDataTypeException
109
-     * @throws InvalidInterfaceException
110
-     * @throws ReflectionException
111
-     */
112
-    public function generate()
113
-    {
114
-        $has_sub_regions = EEM_State::instance()->count(
115
-            array(array('Country.CNT_ISO' => $this->organization_config->CNT_ISO))
116
-        );
117
-        $form = new EE_Form_Section_Proper(
118
-            array(
119
-                'name'            => 'organization_settings',
120
-                'html_id'         => 'organization_settings',
121
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
122
-                'subsections'     => array(
123
-                    'contact_information_hdr'        => new EE_Form_Section_HTML(
124
-                        EEH_HTML::h2(
125
-                            esc_html__('Contact Information', 'event_espresso')
126
-                            . ' '
127
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')),
128
-                            '',
129
-                            'contact-information-hdr'
130
-                        )
131
-                    ),
132
-                    'organization_name'      => new EE_Text_Input(
133
-                        array(
134
-                            'html_name' => 'organization_name',
135
-                            'html_label_text' => esc_html__('Organization Name', 'event_espresso'),
136
-                            'html_help_text'  => esc_html__(
137
-                                'Displayed on all emails and invoices.',
138
-                                'event_espresso'
139
-                            ),
140
-                            'default'         => $this->organization_config->get_pretty('name'),
141
-                            'required'        => false,
142
-                        )
143
-                    ),
144
-                    'organization_address_1'      => new EE_Text_Input(
145
-                        array(
146
-                            'html_name' => 'organization_address_1',
147
-                            'html_label_text' => esc_html__('Street Address', 'event_espresso'),
148
-                            'default'         => $this->organization_config->get_pretty('address_1'),
149
-                            'required'        => false,
150
-                        )
151
-                    ),
152
-                    'organization_address_2'      => new EE_Text_Input(
153
-                        array(
154
-                            'html_name' => 'organization_address_2',
155
-                            'html_label_text' => esc_html__('Street Address 2', 'event_espresso'),
156
-                            'default'         => $this->organization_config->get_pretty('address_2'),
157
-                            'required'        => false,
158
-                        )
159
-                    ),
160
-                    'organization_city'      => new EE_Text_Input(
161
-                        array(
162
-                            'html_name' => 'organization_city',
163
-                            'html_label_text' => esc_html__('City', 'event_espresso'),
164
-                            'default'         => $this->organization_config->get_pretty('city'),
165
-                            'required'        => false,
166
-                        )
167
-                    ),
168
-                    'organization_country'      => new EE_Country_Select_Input(
169
-                        null,
170
-                        array(
171
-                            EE_Country_Select_Input::OPTION_GET_KEY => EE_Country_Select_Input::OPTION_GET_ALL,
172
-                            'html_name'       => 'organization_country',
173
-                            'html_label_text' => esc_html__('Country', 'event_espresso'),
174
-                            'default'         => $this->organization_config->CNT_ISO,
175
-                            'required'        => false,
176
-                            'html_help_text'  => sprintf(
177
-                                esc_html__(
178
-                                    '%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s',
179
-                                    'event_espresso'
180
-                                ),
181
-                                '<span class="reminder-spn">',
182
-                                '</span>'
183
-                            ),
184
-                        )
185
-                    ),
186
-                    'organization_state' => new EE_State_Select_Input(
187
-                        null,
188
-                        array(
189
-                            'html_name'       => 'organization_state',
190
-                            'html_label_text' => esc_html__('State/Province', 'event_espresso'),
191
-                            'default'         => $this->organization_config->STA_ID,
192
-                            'required'        => false,
193
-                            'html_help_text' => empty($this->organization_config->STA_ID) || ! $has_sub_regions
194
-                                ? sprintf(
195
-                                    esc_html__(
196
-                                        'If the States/Provinces for the selected Country do not appear in this list, then click "Save".%3$sIf data exists, then the list will be populated when the page reloads and you will be able to make a selection at that time.%3$s%1$sMake sure you click "Save" again after selecting a State/Province that has just been loaded in order to keep that selection.%2$s',
197
-                                        'event_espresso'
198
-                                    ),
199
-                                    '<span class="reminder-spn">',
200
-                                    '</span>',
201
-                                    '<br />'
202
-                                )
203
-                                : '',
204
-                        )
205
-                    ),
206
-                    'organization_zip'      => new EE_Text_Input(
207
-                        array(
208
-                            'html_name' => 'organization_zip',
209
-                            'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'),
210
-                            'default'         => $this->organization_config->get_pretty('zip'),
211
-                            'required'        => false,
212
-                        )
213
-                    ),
214
-                    'organization_email'      => new EE_Text_Input(
215
-                        array(
216
-                            'html_name' => 'organization_email',
217
-                            'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'),
218
-                            'html_help_text'  => sprintf(
219
-                                esc_html__(
220
-                                    'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',
221
-                                    'event_espresso'
222
-                                ),
223
-                                '<code>[CO_FORMATTED_EMAIL]</code>',
224
-                                '<code>[CO_EMAIL]</code>'
225
-                            ),
226
-                            'default'         => $this->organization_config->get_pretty('email'),
227
-                            'required'        => false,
228
-                        )
229
-                    ),
230
-                    'organization_phone'      => new EE_Text_Input(
231
-                        array(
232
-                            'html_name' => 'organization_phone',
233
-                            'html_label_text' => esc_html__('Phone Number', 'event_espresso'),
234
-                            'html_help_text'  => esc_html__(
235
-                                'The phone number for your organization.',
236
-                                'event_espresso'
237
-                            ),
238
-                            'default'         => $this->organization_config->get_pretty('phone'),
239
-                            'required'        => false,
240
-                        )
241
-                    ),
242
-                    'organization_vat'      => new EE_Text_Input(
243
-                        array(
244
-                            'html_name' => 'organization_vat',
245
-                            'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'),
246
-                            'html_help_text'  => esc_html__(
247
-                                'The VAT/Tax Number may be displayed on invoices and receipts.',
248
-                                'event_espresso'
249
-                            ),
250
-                            'default'         => $this->organization_config->get_pretty('vat'),
251
-                            'required'        => false,
252
-                        )
253
-                    ),
254
-                    'company_logo_hdr'        => new EE_Form_Section_HTML(
255
-                        EEH_HTML::h2(
256
-                            esc_html__('Company Logo', 'event_espresso')
257
-                            . ' '
258
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')),
259
-                            '',
260
-                            'company-logo-hdr'
261
-                        )
262
-                    ),
263
-                    'organization_logo_url'      => new EE_Admin_File_Uploader_Input(
264
-                        array(
265
-                            'html_name' => 'organization_logo_url',
266
-                            'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'),
267
-                            'html_help_text'  => esc_html__(
268
-                                'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',
269
-                                'event_espresso'
270
-                            ),
271
-                            'default'         => $this->organization_config->get_pretty('logo_url'),
272
-                            'required'        => false,
273
-                        )
274
-                    ),
275
-                    'social_links_hdr'        => new EE_Form_Section_HTML(
276
-                        EEH_HTML::h2(
277
-                            esc_html__('Social Links', 'event_espresso')
278
-                            . ' '
279
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info'))
280
-                            . EEH_HTML::br()
281
-                            . EEH_HTML::p(
282
-                                esc_html__(
283
-                                    'Enter any links to social accounts for your organization here',
284
-                                    'event_espresso'
285
-                                ),
286
-                                '',
287
-                                'description'
288
-                            ),
289
-                            '',
290
-                            'social-links-hdr'
291
-                        )
292
-                    ),
293
-                    'organization_facebook'      => new EE_Text_Input(
294
-                        array(
295
-                            'html_name' => 'organization_facebook',
296
-                            'html_label_text' => esc_html__('Facebook', 'event_espresso'),
297
-                            'other_html_attributes' => ' placeholder="facebook.com/profile.name"',
298
-                            'default'         => $this->organization_config->get_pretty('facebook'),
299
-                            'required'        => false,
300
-                        )
301
-                    ),
302
-                    'organization_twitter'      => new EE_Text_Input(
303
-                        array(
304
-                            'html_name' => 'organization_twitter',
305
-                            'html_label_text' => esc_html__('Twitter', 'event_espresso'),
306
-                            'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',
307
-                            'default'         => $this->organization_config->get_pretty('twitter'),
308
-                            'required'        => false,
309
-                        )
310
-                    ),
311
-                    'organization_linkedin'      => new EE_Text_Input(
312
-                        array(
313
-                            'html_name' => 'organization_linkedin',
314
-                            'html_label_text' => esc_html__('LinkedIn', 'event_espresso'),
315
-                            'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',
316
-                            'default'         => $this->organization_config->get_pretty('linkedin'),
317
-                            'required'        => false,
318
-                        )
319
-                    ),
320
-                    'organization_pinterest'      => new EE_Text_Input(
321
-                        array(
322
-                            'html_name' => 'organization_pinterest',
323
-                            'html_label_text' => esc_html__('Pinterest', 'event_espresso'),
324
-                            'other_html_attributes' => ' placeholder="pinterest.com/profilename"',
325
-                            'default'         => $this->organization_config->get_pretty('pinterest'),
326
-                            'required'        => false,
327
-                        )
328
-                    ),
329
-                    'organization_instagram'      => new EE_Text_Input(
330
-                        array(
331
-                            'html_name' => 'organization_instagram',
332
-                            'html_label_text' => esc_html__('Instagram', 'event_espresso'),
333
-                            'other_html_attributes' => ' placeholder="instagram.com/handle"',
334
-                            'default'         => $this->organization_config->get_pretty('instagram'),
335
-                            'required'        => false,
336
-                        )
337
-                    ),
338
-                ),
339
-            )
340
-        );
341
-        if (is_main_site()) {
342
-            $form->add_subsections(
343
-                array(
344
-                    'site_license_key_hdr' => new EE_Form_Section_HTML(
345
-                        EEH_HTML::h2(
346
-                            esc_html__('Your Event Espresso License Key', 'event_espresso')
347
-                            . ' '
348
-                            . EEH_HTML::span(
349
-                                EEH_Template::get_help_tab_link('site_license_key_info')
350
-                            ),
351
-                            '',
352
-                            'site-license-key-hdr'
353
-                        )
354
-                    ),
355
-                    'site_license_key' => $this->getSiteLicenseKeyField()
356
-                )
357
-            );
358
-            $form->add_subsections(
359
-                array(
360
-                    'uxip_optin_hdr' => new EE_Form_Section_HTML(
361
-                        $this->uxipOptinText()
362
-                    ),
363
-                    'ueip_optin' => new EE_Checkbox_Multi_Input(
364
-                        array(
365
-                            true => esc_html__('Yes! I want to help improve Event Espresso!', 'event_espresso')
366
-                        ),
367
-                        array(
368
-                            'html_name' => EE_Core_Config::OPTION_NAME_UXIP,
369
-                            'html_label_text' => esc_html__(
370
-                                'UXIP Opt In?',
371
-                                'event_espresso'
372
-                            ),
373
-                            'default'         => isset($this->core_config->ee_ueip_optin)
374
-                                ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
375
-                                : false,
376
-                            'required'        => false,
377
-                        )
378
-                    ),
379
-                ),
380
-                'organization_instagram',
381
-                false
382
-            );
383
-        }
384
-        return $form;
385
-    }
102
+	/**
103
+	 * creates and returns the actual form
104
+	 *
105
+	 * @return EE_Form_Section_Proper
106
+	 * @throws EE_Error
107
+	 * @throws InvalidArgumentException
108
+	 * @throws InvalidDataTypeException
109
+	 * @throws InvalidInterfaceException
110
+	 * @throws ReflectionException
111
+	 */
112
+	public function generate()
113
+	{
114
+		$has_sub_regions = EEM_State::instance()->count(
115
+			array(array('Country.CNT_ISO' => $this->organization_config->CNT_ISO))
116
+		);
117
+		$form = new EE_Form_Section_Proper(
118
+			array(
119
+				'name'            => 'organization_settings',
120
+				'html_id'         => 'organization_settings',
121
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
122
+				'subsections'     => array(
123
+					'contact_information_hdr'        => new EE_Form_Section_HTML(
124
+						EEH_HTML::h2(
125
+							esc_html__('Contact Information', 'event_espresso')
126
+							. ' '
127
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')),
128
+							'',
129
+							'contact-information-hdr'
130
+						)
131
+					),
132
+					'organization_name'      => new EE_Text_Input(
133
+						array(
134
+							'html_name' => 'organization_name',
135
+							'html_label_text' => esc_html__('Organization Name', 'event_espresso'),
136
+							'html_help_text'  => esc_html__(
137
+								'Displayed on all emails and invoices.',
138
+								'event_espresso'
139
+							),
140
+							'default'         => $this->organization_config->get_pretty('name'),
141
+							'required'        => false,
142
+						)
143
+					),
144
+					'organization_address_1'      => new EE_Text_Input(
145
+						array(
146
+							'html_name' => 'organization_address_1',
147
+							'html_label_text' => esc_html__('Street Address', 'event_espresso'),
148
+							'default'         => $this->organization_config->get_pretty('address_1'),
149
+							'required'        => false,
150
+						)
151
+					),
152
+					'organization_address_2'      => new EE_Text_Input(
153
+						array(
154
+							'html_name' => 'organization_address_2',
155
+							'html_label_text' => esc_html__('Street Address 2', 'event_espresso'),
156
+							'default'         => $this->organization_config->get_pretty('address_2'),
157
+							'required'        => false,
158
+						)
159
+					),
160
+					'organization_city'      => new EE_Text_Input(
161
+						array(
162
+							'html_name' => 'organization_city',
163
+							'html_label_text' => esc_html__('City', 'event_espresso'),
164
+							'default'         => $this->organization_config->get_pretty('city'),
165
+							'required'        => false,
166
+						)
167
+					),
168
+					'organization_country'      => new EE_Country_Select_Input(
169
+						null,
170
+						array(
171
+							EE_Country_Select_Input::OPTION_GET_KEY => EE_Country_Select_Input::OPTION_GET_ALL,
172
+							'html_name'       => 'organization_country',
173
+							'html_label_text' => esc_html__('Country', 'event_espresso'),
174
+							'default'         => $this->organization_config->CNT_ISO,
175
+							'required'        => false,
176
+							'html_help_text'  => sprintf(
177
+								esc_html__(
178
+									'%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s',
179
+									'event_espresso'
180
+								),
181
+								'<span class="reminder-spn">',
182
+								'</span>'
183
+							),
184
+						)
185
+					),
186
+					'organization_state' => new EE_State_Select_Input(
187
+						null,
188
+						array(
189
+							'html_name'       => 'organization_state',
190
+							'html_label_text' => esc_html__('State/Province', 'event_espresso'),
191
+							'default'         => $this->organization_config->STA_ID,
192
+							'required'        => false,
193
+							'html_help_text' => empty($this->organization_config->STA_ID) || ! $has_sub_regions
194
+								? sprintf(
195
+									esc_html__(
196
+										'If the States/Provinces for the selected Country do not appear in this list, then click "Save".%3$sIf data exists, then the list will be populated when the page reloads and you will be able to make a selection at that time.%3$s%1$sMake sure you click "Save" again after selecting a State/Province that has just been loaded in order to keep that selection.%2$s',
197
+										'event_espresso'
198
+									),
199
+									'<span class="reminder-spn">',
200
+									'</span>',
201
+									'<br />'
202
+								)
203
+								: '',
204
+						)
205
+					),
206
+					'organization_zip'      => new EE_Text_Input(
207
+						array(
208
+							'html_name' => 'organization_zip',
209
+							'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'),
210
+							'default'         => $this->organization_config->get_pretty('zip'),
211
+							'required'        => false,
212
+						)
213
+					),
214
+					'organization_email'      => new EE_Text_Input(
215
+						array(
216
+							'html_name' => 'organization_email',
217
+							'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'),
218
+							'html_help_text'  => sprintf(
219
+								esc_html__(
220
+									'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',
221
+									'event_espresso'
222
+								),
223
+								'<code>[CO_FORMATTED_EMAIL]</code>',
224
+								'<code>[CO_EMAIL]</code>'
225
+							),
226
+							'default'         => $this->organization_config->get_pretty('email'),
227
+							'required'        => false,
228
+						)
229
+					),
230
+					'organization_phone'      => new EE_Text_Input(
231
+						array(
232
+							'html_name' => 'organization_phone',
233
+							'html_label_text' => esc_html__('Phone Number', 'event_espresso'),
234
+							'html_help_text'  => esc_html__(
235
+								'The phone number for your organization.',
236
+								'event_espresso'
237
+							),
238
+							'default'         => $this->organization_config->get_pretty('phone'),
239
+							'required'        => false,
240
+						)
241
+					),
242
+					'organization_vat'      => new EE_Text_Input(
243
+						array(
244
+							'html_name' => 'organization_vat',
245
+							'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'),
246
+							'html_help_text'  => esc_html__(
247
+								'The VAT/Tax Number may be displayed on invoices and receipts.',
248
+								'event_espresso'
249
+							),
250
+							'default'         => $this->organization_config->get_pretty('vat'),
251
+							'required'        => false,
252
+						)
253
+					),
254
+					'company_logo_hdr'        => new EE_Form_Section_HTML(
255
+						EEH_HTML::h2(
256
+							esc_html__('Company Logo', 'event_espresso')
257
+							. ' '
258
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')),
259
+							'',
260
+							'company-logo-hdr'
261
+						)
262
+					),
263
+					'organization_logo_url'      => new EE_Admin_File_Uploader_Input(
264
+						array(
265
+							'html_name' => 'organization_logo_url',
266
+							'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'),
267
+							'html_help_text'  => esc_html__(
268
+								'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',
269
+								'event_espresso'
270
+							),
271
+							'default'         => $this->organization_config->get_pretty('logo_url'),
272
+							'required'        => false,
273
+						)
274
+					),
275
+					'social_links_hdr'        => new EE_Form_Section_HTML(
276
+						EEH_HTML::h2(
277
+							esc_html__('Social Links', 'event_espresso')
278
+							. ' '
279
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info'))
280
+							. EEH_HTML::br()
281
+							. EEH_HTML::p(
282
+								esc_html__(
283
+									'Enter any links to social accounts for your organization here',
284
+									'event_espresso'
285
+								),
286
+								'',
287
+								'description'
288
+							),
289
+							'',
290
+							'social-links-hdr'
291
+						)
292
+					),
293
+					'organization_facebook'      => new EE_Text_Input(
294
+						array(
295
+							'html_name' => 'organization_facebook',
296
+							'html_label_text' => esc_html__('Facebook', 'event_espresso'),
297
+							'other_html_attributes' => ' placeholder="facebook.com/profile.name"',
298
+							'default'         => $this->organization_config->get_pretty('facebook'),
299
+							'required'        => false,
300
+						)
301
+					),
302
+					'organization_twitter'      => new EE_Text_Input(
303
+						array(
304
+							'html_name' => 'organization_twitter',
305
+							'html_label_text' => esc_html__('Twitter', 'event_espresso'),
306
+							'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',
307
+							'default'         => $this->organization_config->get_pretty('twitter'),
308
+							'required'        => false,
309
+						)
310
+					),
311
+					'organization_linkedin'      => new EE_Text_Input(
312
+						array(
313
+							'html_name' => 'organization_linkedin',
314
+							'html_label_text' => esc_html__('LinkedIn', 'event_espresso'),
315
+							'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',
316
+							'default'         => $this->organization_config->get_pretty('linkedin'),
317
+							'required'        => false,
318
+						)
319
+					),
320
+					'organization_pinterest'      => new EE_Text_Input(
321
+						array(
322
+							'html_name' => 'organization_pinterest',
323
+							'html_label_text' => esc_html__('Pinterest', 'event_espresso'),
324
+							'other_html_attributes' => ' placeholder="pinterest.com/profilename"',
325
+							'default'         => $this->organization_config->get_pretty('pinterest'),
326
+							'required'        => false,
327
+						)
328
+					),
329
+					'organization_instagram'      => new EE_Text_Input(
330
+						array(
331
+							'html_name' => 'organization_instagram',
332
+							'html_label_text' => esc_html__('Instagram', 'event_espresso'),
333
+							'other_html_attributes' => ' placeholder="instagram.com/handle"',
334
+							'default'         => $this->organization_config->get_pretty('instagram'),
335
+							'required'        => false,
336
+						)
337
+					),
338
+				),
339
+			)
340
+		);
341
+		if (is_main_site()) {
342
+			$form->add_subsections(
343
+				array(
344
+					'site_license_key_hdr' => new EE_Form_Section_HTML(
345
+						EEH_HTML::h2(
346
+							esc_html__('Your Event Espresso License Key', 'event_espresso')
347
+							. ' '
348
+							. EEH_HTML::span(
349
+								EEH_Template::get_help_tab_link('site_license_key_info')
350
+							),
351
+							'',
352
+							'site-license-key-hdr'
353
+						)
354
+					),
355
+					'site_license_key' => $this->getSiteLicenseKeyField()
356
+				)
357
+			);
358
+			$form->add_subsections(
359
+				array(
360
+					'uxip_optin_hdr' => new EE_Form_Section_HTML(
361
+						$this->uxipOptinText()
362
+					),
363
+					'ueip_optin' => new EE_Checkbox_Multi_Input(
364
+						array(
365
+							true => esc_html__('Yes! I want to help improve Event Espresso!', 'event_espresso')
366
+						),
367
+						array(
368
+							'html_name' => EE_Core_Config::OPTION_NAME_UXIP,
369
+							'html_label_text' => esc_html__(
370
+								'UXIP Opt In?',
371
+								'event_espresso'
372
+							),
373
+							'default'         => isset($this->core_config->ee_ueip_optin)
374
+								? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
375
+								: false,
376
+							'required'        => false,
377
+						)
378
+					),
379
+				),
380
+				'organization_instagram',
381
+				false
382
+			);
383
+		}
384
+		return $form;
385
+	}
386 386
 
387 387
 
388
-    /**
389
-     * takes the generated form and displays it along with ony other non-form HTML that may be required
390
-     * returns a string of HTML that can be directly echoed in a template
391
-     *
392
-     * @return string
393
-     * @throws EE_Error
394
-     * @throws InvalidArgumentException
395
-     * @throws InvalidDataTypeException
396
-     * @throws InvalidInterfaceException
397
-     * @throws LogicException
398
-     */
399
-    public function display()
400
-    {
401
-        $this->form()->enqueue_js();
402
-        return parent::display();
403
-    }
388
+	/**
389
+	 * takes the generated form and displays it along with ony other non-form HTML that may be required
390
+	 * returns a string of HTML that can be directly echoed in a template
391
+	 *
392
+	 * @return string
393
+	 * @throws EE_Error
394
+	 * @throws InvalidArgumentException
395
+	 * @throws InvalidDataTypeException
396
+	 * @throws InvalidInterfaceException
397
+	 * @throws LogicException
398
+	 */
399
+	public function display()
400
+	{
401
+		$this->form()->enqueue_js();
402
+		return parent::display();
403
+	}
404 404
 
405 405
 
406
-    /**
407
-     * handles processing the form submission
408
-     * returns true or false depending on whether the form was processed successfully or not
409
-     *
410
-     * @param array $form_data
411
-     * @return bool
412
-     * @throws InvalidFormSubmissionException
413
-     * @throws EE_Error
414
-     * @throws LogicException
415
-     * @throws InvalidArgumentException
416
-     * @throws InvalidDataTypeException
417
-     * @throws ReflectionException
418
-     */
419
-    public function process($form_data = array())
420
-    {
421
-        // process form
422
-        $valid_data = (array) parent::process($form_data);
423
-        if (empty($valid_data)) {
424
-            return false;
425
-        }
406
+	/**
407
+	 * handles processing the form submission
408
+	 * returns true or false depending on whether the form was processed successfully or not
409
+	 *
410
+	 * @param array $form_data
411
+	 * @return bool
412
+	 * @throws InvalidFormSubmissionException
413
+	 * @throws EE_Error
414
+	 * @throws LogicException
415
+	 * @throws InvalidArgumentException
416
+	 * @throws InvalidDataTypeException
417
+	 * @throws ReflectionException
418
+	 */
419
+	public function process($form_data = array())
420
+	{
421
+		// process form
422
+		$valid_data = (array) parent::process($form_data);
423
+		if (empty($valid_data)) {
424
+			return false;
425
+		}
426 426
 
427
-        if (is_main_site()) {
428
-            $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key'])
429
-                ? sanitize_text_field($form_data['ee_site_license_key'])
430
-                : $this->network_core_config->site_license_key;
431
-        }
432
-        $this->organization_config->name = isset($form_data['organization_name'])
433
-            ? sanitize_text_field($form_data['organization_name'])
434
-            : $this->organization_config->name;
435
-        $this->organization_config->address_1 = isset($form_data['organization_address_1'])
436
-            ? sanitize_text_field($form_data['organization_address_1'])
437
-            : $this->organization_config->address_1;
438
-        $this->organization_config->address_2 = isset($form_data['organization_address_2'])
439
-            ? sanitize_text_field($form_data['organization_address_2'])
440
-            : $this->organization_config->address_2;
441
-        $this->organization_config->city = isset($form_data['organization_city'])
442
-            ? sanitize_text_field($form_data['organization_city'])
443
-            : $this->organization_config->city;
444
-        $this->organization_config->STA_ID = isset($form_data['organization_state'])
445
-            ? absint($form_data['organization_state'])
446
-            : $this->organization_config->STA_ID;
447
-        $this->organization_config->CNT_ISO = isset($form_data['organization_country'])
448
-            ? sanitize_text_field($form_data['organization_country'])
449
-            : $this->organization_config->CNT_ISO;
450
-        $this->organization_config->zip = isset($form_data['organization_zip'])
451
-            ? sanitize_text_field($form_data['organization_zip'])
452
-            : $this->organization_config->zip;
453
-        $this->organization_config->email = isset($form_data['organization_email'])
454
-            ? sanitize_email($form_data['organization_email'])
455
-            : $this->organization_config->email;
456
-        $this->organization_config->vat = isset($form_data['organization_vat'])
457
-            ? sanitize_text_field($form_data['organization_vat'])
458
-            : $this->organization_config->vat;
459
-        $this->organization_config->phone = isset($form_data['organization_phone'])
460
-            ? sanitize_text_field($form_data['organization_phone'])
461
-            : $this->organization_config->phone;
462
-        $this->organization_config->logo_url = isset($form_data['organization_logo_url'])
463
-            ? esc_url_raw($form_data['organization_logo_url'])
464
-            : $this->organization_config->logo_url;
465
-        $this->organization_config->facebook = isset($form_data['organization_facebook'])
466
-            ? esc_url_raw($form_data['organization_facebook'])
467
-            : $this->organization_config->facebook;
468
-        $this->organization_config->twitter = isset($form_data['organization_twitter'])
469
-            ? esc_url_raw($form_data['organization_twitter'])
470
-            : $this->organization_config->twitter;
471
-        $this->organization_config->linkedin = isset($form_data['organization_linkedin'])
472
-            ? esc_url_raw($form_data['organization_linkedin'])
473
-            : $this->organization_config->linkedin;
474
-        $this->organization_config->pinterest = isset($form_data['organization_pinterest'])
475
-            ? esc_url_raw($form_data['organization_pinterest'])
476
-            : $this->organization_config->pinterest;
477
-        $this->organization_config->google = isset($form_data['organization_google'])
478
-            ? esc_url_raw($form_data['organization_google'])
479
-            : $this->organization_config->google;
480
-        $this->organization_config->instagram = isset($form_data['organization_instagram'])
481
-            ? esc_url_raw($form_data['organization_instagram'])
482
-            : $this->organization_config->instagram;
483
-        $this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
484
-            ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
485
-            : false;
486
-        $this->core_config->ee_ueip_has_notified = true;
427
+		if (is_main_site()) {
428
+			$this->network_core_config->site_license_key = isset($form_data['ee_site_license_key'])
429
+				? sanitize_text_field($form_data['ee_site_license_key'])
430
+				: $this->network_core_config->site_license_key;
431
+		}
432
+		$this->organization_config->name = isset($form_data['organization_name'])
433
+			? sanitize_text_field($form_data['organization_name'])
434
+			: $this->organization_config->name;
435
+		$this->organization_config->address_1 = isset($form_data['organization_address_1'])
436
+			? sanitize_text_field($form_data['organization_address_1'])
437
+			: $this->organization_config->address_1;
438
+		$this->organization_config->address_2 = isset($form_data['organization_address_2'])
439
+			? sanitize_text_field($form_data['organization_address_2'])
440
+			: $this->organization_config->address_2;
441
+		$this->organization_config->city = isset($form_data['organization_city'])
442
+			? sanitize_text_field($form_data['organization_city'])
443
+			: $this->organization_config->city;
444
+		$this->organization_config->STA_ID = isset($form_data['organization_state'])
445
+			? absint($form_data['organization_state'])
446
+			: $this->organization_config->STA_ID;
447
+		$this->organization_config->CNT_ISO = isset($form_data['organization_country'])
448
+			? sanitize_text_field($form_data['organization_country'])
449
+			: $this->organization_config->CNT_ISO;
450
+		$this->organization_config->zip = isset($form_data['organization_zip'])
451
+			? sanitize_text_field($form_data['organization_zip'])
452
+			: $this->organization_config->zip;
453
+		$this->organization_config->email = isset($form_data['organization_email'])
454
+			? sanitize_email($form_data['organization_email'])
455
+			: $this->organization_config->email;
456
+		$this->organization_config->vat = isset($form_data['organization_vat'])
457
+			? sanitize_text_field($form_data['organization_vat'])
458
+			: $this->organization_config->vat;
459
+		$this->organization_config->phone = isset($form_data['organization_phone'])
460
+			? sanitize_text_field($form_data['organization_phone'])
461
+			: $this->organization_config->phone;
462
+		$this->organization_config->logo_url = isset($form_data['organization_logo_url'])
463
+			? esc_url_raw($form_data['organization_logo_url'])
464
+			: $this->organization_config->logo_url;
465
+		$this->organization_config->facebook = isset($form_data['organization_facebook'])
466
+			? esc_url_raw($form_data['organization_facebook'])
467
+			: $this->organization_config->facebook;
468
+		$this->organization_config->twitter = isset($form_data['organization_twitter'])
469
+			? esc_url_raw($form_data['organization_twitter'])
470
+			: $this->organization_config->twitter;
471
+		$this->organization_config->linkedin = isset($form_data['organization_linkedin'])
472
+			? esc_url_raw($form_data['organization_linkedin'])
473
+			: $this->organization_config->linkedin;
474
+		$this->organization_config->pinterest = isset($form_data['organization_pinterest'])
475
+			? esc_url_raw($form_data['organization_pinterest'])
476
+			: $this->organization_config->pinterest;
477
+		$this->organization_config->google = isset($form_data['organization_google'])
478
+			? esc_url_raw($form_data['organization_google'])
479
+			: $this->organization_config->google;
480
+		$this->organization_config->instagram = isset($form_data['organization_instagram'])
481
+			? esc_url_raw($form_data['organization_instagram'])
482
+			: $this->organization_config->instagram;
483
+		$this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
484
+			? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
485
+			: false;
486
+		$this->core_config->ee_ueip_has_notified = true;
487 487
 
488
-        $this->registry->CFG->currency = new EE_Currency_Config(
489
-            $this->organization_config->CNT_ISO
490
-        );
491
-        /** @var EE_Country $country */
492
-        $country = EEM_Country::instance()->get_one_by_ID($this->organization_config->CNT_ISO);
493
-        if ($country instanceof EE_Country) {
494
-            $country->set('CNT_active', 1);
495
-            $country->save();
496
-            $this->countrySubRegionDao->saveCountrySubRegions($country);
497
-        }
498
-        return true;
499
-    }
488
+		$this->registry->CFG->currency = new EE_Currency_Config(
489
+			$this->organization_config->CNT_ISO
490
+		);
491
+		/** @var EE_Country $country */
492
+		$country = EEM_Country::instance()->get_one_by_ID($this->organization_config->CNT_ISO);
493
+		if ($country instanceof EE_Country) {
494
+			$country->set('CNT_active', 1);
495
+			$country->save();
496
+			$this->countrySubRegionDao->saveCountrySubRegions($country);
497
+		}
498
+		return true;
499
+	}
500 500
 
501 501
 
502
-    /**
503
-     * @return string
504
-     */
505
-    private function uxipOptinText()
506
-    {
507
-        ob_start();
508
-        Stats::optinText(false);
509
-        return ob_get_clean();
510
-    }
502
+	/**
503
+	 * @return string
504
+	 */
505
+	private function uxipOptinText()
506
+	{
507
+		ob_start();
508
+		Stats::optinText(false);
509
+		return ob_get_clean();
510
+	}
511 511
 
512 512
 
513
-    /**
514
-     * Return whether the site license key has been verified or not.
515
-     * @return bool
516
-     */
517
-    private function licenseKeyVerified()
518
-    {
519
-        if (empty($this->network_core_config->site_license_key)) {
520
-            return false;
521
-        }
522
-        $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
523
-        $verify_fail = get_option($ver_option_key, false);
524
-        return $verify_fail === false
525
-                  || (! empty($this->network_core_config->site_license_key)
526
-                        && $verify_fail === false
527
-                  );
528
-    }
513
+	/**
514
+	 * Return whether the site license key has been verified or not.
515
+	 * @return bool
516
+	 */
517
+	private function licenseKeyVerified()
518
+	{
519
+		if (empty($this->network_core_config->site_license_key)) {
520
+			return false;
521
+		}
522
+		$ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
523
+		$verify_fail = get_option($ver_option_key, false);
524
+		return $verify_fail === false
525
+				  || (! empty($this->network_core_config->site_license_key)
526
+						&& $verify_fail === false
527
+				  );
528
+	}
529 529
 
530 530
 
531
-    /**
532
-     * @return EE_Text_Input
533
-     */
534
-    private function getSiteLicenseKeyField()
535
-    {
536
-        $text_input = new EE_Text_Input(
537
-            array(
538
-                'html_name' => 'ee_site_license_key',
539
-                'html_id' => 'site_license_key',
540
-                'html_label_text' => esc_html__('Support License Key', 'event_espresso'),
541
-                /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
542
-                'html_help_text'  => sprintf(
543
-                    esc_html__(
544
-                        'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
545
-                        'event_espresso'
546
-                    ),
547
-                    '<strong>',
548
-                    '</strong>'
549
-                ),
550
-                /** phpcs:enable */
551
-                'default'         => isset($this->network_core_config->site_license_key)
552
-                    ? $this->network_core_config->site_license_key
553
-                    : '',
554
-                'required'        => false,
555
-                'form_html_filter' => new VsprintfFilter(
556
-                    '%2$s %1$s',
557
-                    array($this->getValidationIndicator())
558
-                )
559
-            )
560
-        );
561
-        return $text_input;
562
-    }
531
+	/**
532
+	 * @return EE_Text_Input
533
+	 */
534
+	private function getSiteLicenseKeyField()
535
+	{
536
+		$text_input = new EE_Text_Input(
537
+			array(
538
+				'html_name' => 'ee_site_license_key',
539
+				'html_id' => 'site_license_key',
540
+				'html_label_text' => esc_html__('Support License Key', 'event_espresso'),
541
+				/** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
542
+				'html_help_text'  => sprintf(
543
+					esc_html__(
544
+						'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
545
+						'event_espresso'
546
+					),
547
+					'<strong>',
548
+					'</strong>'
549
+				),
550
+				/** phpcs:enable */
551
+				'default'         => isset($this->network_core_config->site_license_key)
552
+					? $this->network_core_config->site_license_key
553
+					: '',
554
+				'required'        => false,
555
+				'form_html_filter' => new VsprintfFilter(
556
+					'%2$s %1$s',
557
+					array($this->getValidationIndicator())
558
+				)
559
+			)
560
+		);
561
+		return $text_input;
562
+	}
563 563
 
564 564
 
565
-    /**
566
-     * @return string
567
-     */
568
-    private function getValidationIndicator()
569
-    {
570
-        $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
571
-        return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
572
-    }
565
+	/**
566
+	 * @return string
567
+	 */
568
+	private function getValidationIndicator()
569
+	{
570
+		$verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
571
+		return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
572
+	}
573 573
 }
Please login to merge, or discard this patch.
strategies/display/EE_Radio_Button_Display_Strategy.strategy.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -11,61 +11,61 @@
 block discarded – undo
11 11
 class EE_Radio_Button_Display_Strategy extends EE_Compound_Input_Display_Strategy
12 12
 {
13 13
 
14
-    /**
15
-     *
16
-     * @throws EE_Error
17
-     * @return string of html to display the field
18
-     */
19
-    public function display()
20
-    {
21
-        $input = $this->get_input();
22
-        $input->set_label_sizes();
23
-        $label_size_class = $input->get_label_size_class();
24
-        $html = '';
25
-        foreach ($input->options() as $value => $display_text) {
26
-            $value = $input->get_normalization_strategy()->unnormalize($value);
14
+	/**
15
+	 *
16
+	 * @throws EE_Error
17
+	 * @return string of html to display the field
18
+	 */
19
+	public function display()
20
+	{
21
+		$input = $this->get_input();
22
+		$input->set_label_sizes();
23
+		$label_size_class = $input->get_label_size_class();
24
+		$html = '';
25
+		foreach ($input->options() as $value => $display_text) {
26
+			$value = $input->get_normalization_strategy()->unnormalize($value);
27 27
 
28
-            $html_id = $this->get_sub_input_id($value);
29
-            $html .= EEH_HTML::nl(0, 'radio');
28
+			$html_id = $this->get_sub_input_id($value);
29
+			$html .= EEH_HTML::nl(0, 'radio');
30 30
 
31
-            $html .= $this->_opening_tag('label');
32
-            $html .= $this->_attributes_string(
33
-                array(
34
-                    'for' => $html_id,
35
-                    'id' => $html_id . '-lbl',
36
-                    'class' => apply_filters(
37
-                        'FHEE__EE_Radio_Button_Display_Strategy__display__option_label_class',
38
-                        'ee-radio-label-after' . $label_size_class,
39
-                        $this,
40
-                        $input,
41
-                        $value
42
-                    )
43
-                )
44
-            );
45
-            $html .= '>';
46
-            $html .= EEH_HTML::nl(1, 'radio');
47
-            $html .= $this->_opening_tag('input');
48
-            $attributes = array(
49
-                'id' => $html_id,
50
-                'name' => $input->html_name(),
51
-                'class' => $input->html_class(),
52
-                'style' => $input->html_style(),
53
-                'type' => 'radio',
54
-                'value' => $value,
55
-                0 => $input->other_html_attributes(),
56
-                'data-question_label' => $input->html_label_id()
57
-            );
58
-            if ($input->raw_value() === $value) {
59
-                $attributes['checked'] = 'checked';
60
-            }
61
-            $html .= $this->_attributes_string($attributes);
31
+			$html .= $this->_opening_tag('label');
32
+			$html .= $this->_attributes_string(
33
+				array(
34
+					'for' => $html_id,
35
+					'id' => $html_id . '-lbl',
36
+					'class' => apply_filters(
37
+						'FHEE__EE_Radio_Button_Display_Strategy__display__option_label_class',
38
+						'ee-radio-label-after' . $label_size_class,
39
+						$this,
40
+						$input,
41
+						$value
42
+					)
43
+				)
44
+			);
45
+			$html .= '>';
46
+			$html .= EEH_HTML::nl(1, 'radio');
47
+			$html .= $this->_opening_tag('input');
48
+			$attributes = array(
49
+				'id' => $html_id,
50
+				'name' => $input->html_name(),
51
+				'class' => $input->html_class(),
52
+				'style' => $input->html_style(),
53
+				'type' => 'radio',
54
+				'value' => $value,
55
+				0 => $input->other_html_attributes(),
56
+				'data-question_label' => $input->html_label_id()
57
+			);
58
+			if ($input->raw_value() === $value) {
59
+				$attributes['checked'] = 'checked';
60
+			}
61
+			$html .= $this->_attributes_string($attributes);
62 62
 
63
-            $html .= '>&nbsp;';
64
-            $html .= $display_text;
65
-            $html .= EEH_HTML::nl(-1, 'radio') . '</label>';
66
-        }
67
-        $html .= EEH_HTML::div('', '', 'clear-float');
68
-        $html .= EEH_HTML::divx();
69
-        return apply_filters('FHEE__EE_Radio_Button_Display_Strategy__display', $html, $this, $this->_input);
70
-    }
63
+			$html .= '>&nbsp;';
64
+			$html .= $display_text;
65
+			$html .= EEH_HTML::nl(-1, 'radio') . '</label>';
66
+		}
67
+		$html .= EEH_HTML::div('', '', 'clear-float');
68
+		$html .= EEH_HTML::divx();
69
+		return apply_filters('FHEE__EE_Radio_Button_Display_Strategy__display', $html, $this, $this->_input);
70
+	}
71 71
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
             $html .= $this->_attributes_string(
33 33
                 array(
34 34
                     'for' => $html_id,
35
-                    'id' => $html_id . '-lbl',
35
+                    'id' => $html_id.'-lbl',
36 36
                     'class' => apply_filters(
37 37
                         'FHEE__EE_Radio_Button_Display_Strategy__display__option_label_class',
38
-                        'ee-radio-label-after' . $label_size_class,
38
+                        'ee-radio-label-after'.$label_size_class,
39 39
                         $this,
40 40
                         $input,
41 41
                         $value
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
             $html .= '>&nbsp;';
64 64
             $html .= $display_text;
65
-            $html .= EEH_HTML::nl(-1, 'radio') . '</label>';
65
+            $html .= EEH_HTML::nl(-1, 'radio').'</label>';
66 66
         }
67 67
         $html .= EEH_HTML::div('', '', 'clear-float');
68 68
         $html .= EEH_HTML::divx();
Please login to merge, or discard this patch.
core/domain/services/admin/privacy/erasure/EraseAttendeeData.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -16,74 +16,74 @@
 block discarded – undo
16 16
 class EraseAttendeeData implements PersonalDataEraserInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @var EEM_Attendee
21
-     */
22
-    protected $attendee_model;
19
+	/**
20
+	 * @var EEM_Attendee
21
+	 */
22
+	protected $attendee_model;
23 23
 
24 24
 
25
-    /**
26
-     * EraseAttendeeData constructor.
27
-     *
28
-     * @param EEM_Attendee $attendee_model
29
-     */
30
-    public function __construct(EEM_Attendee $attendee_model)
31
-    {
32
-        $this->attendee_model = $attendee_model;
33
-    }
25
+	/**
26
+	 * EraseAttendeeData constructor.
27
+	 *
28
+	 * @param EEM_Attendee $attendee_model
29
+	 */
30
+	public function __construct(EEM_Attendee $attendee_model)
31
+	{
32
+		$this->attendee_model = $attendee_model;
33
+	}
34 34
 
35 35
 
36
-    /**
37
-     * Gets a translated string name for the data eraser
38
-     *
39
-     * @return string
40
-     */
41
-    public function name()
42
-    {
43
-        return esc_html__('Event Espresso Attendee Data', 'event_espresso');
44
-    }
36
+	/**
37
+	 * Gets a translated string name for the data eraser
38
+	 *
39
+	 * @return string
40
+	 */
41
+	public function name()
42
+	{
43
+		return esc_html__('Event Espresso Attendee Data', 'event_espresso');
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * Erases a "page" of personal user data
49
-     *
50
-     * @return array {
51
-     * @type boolean $items_removed  whether items were removed successfully or not
52
-     * @type boolean $items_retained whether any items were skipped or not
53
-     * @type array   $messages       values are messages to show
54
-     * @type boolean $done           whether this eraser is done or has more pages
55
-     *               }
56
-     * @throws \EE_Error
57
-     */
58
-    public function erase($email_address, $page = 1)
59
-    {
60
-        $rows_updated = $this->attendee_model->update(
61
-            array(
62
-                'ATT_fname'    => esc_html__('Anonymous', 'event_espresso'),
63
-                'ATT_lname'    => '',
64
-                'ATT_email'    => '',
65
-                'ATT_address'  => '',
66
-                'ATT_address2' => '',
67
-                'ATT_city'     => '',
68
-                'STA_ID'       => 0,
69
-                'CNT_ISO'      => '',
70
-                'ATT_zip'      => '',
71
-                'ATT_phone'    => '',
72
-            ),
73
-            array(
74
-                array(
75
-                    'ATT_email' => $email_address,
76
-                ),
77
-            )
78
-        );
47
+	/**
48
+	 * Erases a "page" of personal user data
49
+	 *
50
+	 * @return array {
51
+	 * @type boolean $items_removed  whether items were removed successfully or not
52
+	 * @type boolean $items_retained whether any items were skipped or not
53
+	 * @type array   $messages       values are messages to show
54
+	 * @type boolean $done           whether this eraser is done or has more pages
55
+	 *               }
56
+	 * @throws \EE_Error
57
+	 */
58
+	public function erase($email_address, $page = 1)
59
+	{
60
+		$rows_updated = $this->attendee_model->update(
61
+			array(
62
+				'ATT_fname'    => esc_html__('Anonymous', 'event_espresso'),
63
+				'ATT_lname'    => '',
64
+				'ATT_email'    => '',
65
+				'ATT_address'  => '',
66
+				'ATT_address2' => '',
67
+				'ATT_city'     => '',
68
+				'STA_ID'       => 0,
69
+				'CNT_ISO'      => '',
70
+				'ATT_zip'      => '',
71
+				'ATT_phone'    => '',
72
+			),
73
+			array(
74
+				array(
75
+					'ATT_email' => $email_address,
76
+				),
77
+			)
78
+		);
79 79
 
80
-        return array(
81
-            'items_removed'  => (bool) $rows_updated,
82
-            'items_retained' => false, // always false in this example
83
-            'messages'       => array(),
84
-            'done'           => true,
85
-        );
86
-    }
80
+		return array(
81
+			'items_removed'  => (bool) $rows_updated,
82
+			'items_retained' => false, // always false in this example
83
+			'messages'       => array(),
84
+			'done'           => true,
85
+		);
86
+	}
87 87
 }
88 88
 // End of file EraseAttendeeData.php
89 89
 // Location: EventEspresso\core\domain\services\privacy\erasure/EraseAttendeeData.php
Please login to merge, or discard this patch.
core/domain/entities/editor/BlockInterface.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -22,70 +22,70 @@
 block discarded – undo
22 22
 interface BlockInterface
23 23
 {
24 24
 
25
-    const NAME_SPACE = 'eventespresso';
26
-
27
-    /**
28
-     * Perform any early setup required by the block
29
-     * including setting the block type and supported post types
30
-     *
31
-     * @return void
32
-     */
33
-    public function initialize();
34
-
35
-
36
-    /**
37
-     * @return string
38
-     */
39
-    public function blockType();
40
-
41
-
42
-    /**
43
-     * AssetRegister that this editor block uses for asset registration
44
-     *
45
-     * @return BlockAssetManagerInterface
46
-     */
47
-    public function assetManager();
48
-
49
-
50
-    /**
51
-     * Registers the Editor Block with WP core;
52
-     * Returns the registered block type on success, or false on failure.
53
-     *
54
-     * @return WP_Block_Type|false
55
-     */
56
-    public function registerBlock();
57
-
58
-
59
-    /**
60
-     * Un-registers the Editor Block with WP core;
61
-     * Returns the registered block type on success, or false on failure.
62
-     *
63
-     * @return WP_Block_Type|false
64
-     */
65
-    public function unRegisterBlock();
66
-
67
-
68
-    /**
69
-     * returns an array of fully qualified class names
70
-     * for RouteMatchSpecificationInterface objects
71
-     * that specify routes that the block should be loaded for.
72
-     *
73
-     * @return array
74
-     */
75
-    public function supportedRoutes();
76
-
77
-
78
-    /**
79
-     * @return array
80
-     */
81
-    public function getEditorContainer();
82
-
83
-
84
-    /**
85
-     * returns the rendered HTML for the block
86
-     *
87
-     * @param array $attributes
88
-     * @return string
89
-     */
90
-    public function renderBlock(array $attributes = array());
25
+	const NAME_SPACE = 'eventespresso';
26
+
27
+	/**
28
+	 * Perform any early setup required by the block
29
+	 * including setting the block type and supported post types
30
+	 *
31
+	 * @return void
32
+	 */
33
+	public function initialize();
34
+
35
+
36
+	/**
37
+	 * @return string
38
+	 */
39
+	public function blockType();
40
+
41
+
42
+	/**
43
+	 * AssetRegister that this editor block uses for asset registration
44
+	 *
45
+	 * @return BlockAssetManagerInterface
46
+	 */
47
+	public function assetManager();
48
+
49
+
50
+	/**
51
+	 * Registers the Editor Block with WP core;
52
+	 * Returns the registered block type on success, or false on failure.
53
+	 *
54
+	 * @return WP_Block_Type|false
55
+	 */
56
+	public function registerBlock();
57
+
58
+
59
+	/**
60
+	 * Un-registers the Editor Block with WP core;
61
+	 * Returns the registered block type on success, or false on failure.
62
+	 *
63
+	 * @return WP_Block_Type|false
64
+	 */
65
+	public function unRegisterBlock();
66
+
67
+
68
+	/**
69
+	 * returns an array of fully qualified class names
70
+	 * for RouteMatchSpecificationInterface objects
71
+	 * that specify routes that the block should be loaded for.
72
+	 *
73
+	 * @return array
74
+	 */
75
+	public function supportedRoutes();
76
+
77
+
78
+	/**
79
+	 * @return array
80
+	 */
81
+	public function getEditorContainer();
82
+
83
+
84
+	/**
85
+	 * returns the rendered HTML for the block
86
+	 *
87
+	 * @param array $attributes
88
+	 * @return string
89
+	 */
90
+	public function renderBlock(array $attributes = array());
91 91
 }
Please login to merge, or discard this patch.
core/services/editor/BlockManager.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -18,46 +18,46 @@
 block discarded – undo
18 18
 abstract class BlockManager
19 19
 {
20 20
 
21
-    /**
22
-     * @var CollectionInterface|BlockInterface[] $blocks
23
-     */
24
-    protected $blocks;
25
-
26
-    /**
27
-     * @var RequestInterface $request
28
-     */
29
-    protected $request;
30
-
31
-
32
-
33
-    /**
34
-     * BlockManager constructor.
35
-     *
36
-     * @param BlockCollection   $blocks
37
-     * @param RequestInterface  $request
38
-     */
39
-    public function __construct(
40
-        BlockCollection $blocks,
41
-        RequestInterface $request
42
-    ) {
43
-        $this->blocks            = $blocks;
44
-        $this->request           = $request;
45
-        add_action($this->initHook(), array($this, 'initialize'));
46
-    }
47
-
48
-
49
-    /**
50
-     *  Returns the name of a hookpoint to be used to call initialize()
51
-     *
52
-     * @return string
53
-     */
54
-    abstract public function initHook();
55
-
56
-
57
-    /**
58
-     * Perform any early setup required for block editors to functions
59
-     *
60
-     * @return void
61
-     */
62
-    abstract public function initialize();
21
+	/**
22
+	 * @var CollectionInterface|BlockInterface[] $blocks
23
+	 */
24
+	protected $blocks;
25
+
26
+	/**
27
+	 * @var RequestInterface $request
28
+	 */
29
+	protected $request;
30
+
31
+
32
+
33
+	/**
34
+	 * BlockManager constructor.
35
+	 *
36
+	 * @param BlockCollection   $blocks
37
+	 * @param RequestInterface  $request
38
+	 */
39
+	public function __construct(
40
+		BlockCollection $blocks,
41
+		RequestInterface $request
42
+	) {
43
+		$this->blocks            = $blocks;
44
+		$this->request           = $request;
45
+		add_action($this->initHook(), array($this, 'initialize'));
46
+	}
47
+
48
+
49
+	/**
50
+	 *  Returns the name of a hookpoint to be used to call initialize()
51
+	 *
52
+	 * @return string
53
+	 */
54
+	abstract public function initHook();
55
+
56
+
57
+	/**
58
+	 * Perform any early setup required for block editors to functions
59
+	 *
60
+	 * @return void
61
+	 */
62
+	abstract public function initialize();
63 63
 }
Please login to merge, or discard this patch.
core/services/collections/Collection.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     protected function setCollectionInterface($collection_interface)
68 68
     {
69
-        if (! (interface_exists($collection_interface) || class_exists($collection_interface))) {
69
+        if ( ! (interface_exists($collection_interface) || class_exists($collection_interface))) {
70 70
             throw new InvalidInterfaceException($collection_interface);
71 71
         }
72 72
         $this->collection_interface = $collection_interface;
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
     protected function setCollectionIdentifier()
112 112
     {
113 113
         // hash a few collection details
114
-        $identifier = md5(spl_object_hash($this) . $this->collection_interface . time());
114
+        $identifier = md5(spl_object_hash($this).$this->collection_interface.time());
115 115
         // grab a few characters from the start, middle, and end of the hash
116 116
         $id = array();
117 117
         for ($x = 0; $x < 19; $x += 9) {
118 118
             $id[] = substr($identifier, $x, 3);
119 119
         }
120
-        $this->collection_identifier = $this->collection_name . '-' . strtoupper(implode('-', $id));
120
+        $this->collection_identifier = $this->collection_name.'-'.strtoupper(implode('-', $id));
121 121
     }
122 122
 
123 123
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function add($object, $identifier = null)
137 137
     {
138
-        if (! $object instanceof $this->collection_interface) {
138
+        if ( ! $object instanceof $this->collection_interface) {
139 139
             throw new InvalidEntityException($object, $this->collection_interface);
140 140
         }
141 141
         if ($this->contains($object)) {
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
      */
352 352
     public function indexOf($object)
353 353
     {
354
-        if (! $this->contains($object)) {
354
+        if ( ! $this->contains($object)) {
355 355
             return false;
356 356
         }
357 357
         foreach ($this as $index => $obj) {
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
             $remaining_objects = $this->slice($index, $this->count() - $index);
421 421
             foreach ($remaining_objects as $key => $remaining_object) {
422 422
                 // we need to grab the identifiers for each object and use them as keys
423
-                $remaining_objects[ $remaining_object->getInfo() ] = $remaining_object;
423
+                $remaining_objects[$remaining_object->getInfo()] = $remaining_object;
424 424
                 // and then remove the object from the current tracking array
425
-                unset($remaining_objects[ $key ]);
425
+                unset($remaining_objects[$key]);
426 426
                 // and then remove it from the Collection
427 427
                 $this->detach($remaining_object);
428 428
             }
@@ -446,17 +446,17 @@  discard block
 block discarded – undo
446 446
      */
447 447
     public function insertAt($objects, $index)
448 448
     {
449
-        if (! is_array($objects)) {
449
+        if ( ! is_array($objects)) {
450 450
             $objects = array($objects);
451 451
         }
452 452
         // check to ensure that objects don't already exist in the collection
453 453
         foreach ($objects as $key => $object) {
454 454
             if ($this->contains($object)) {
455
-                unset($objects[ $key ]);
455
+                unset($objects[$key]);
456 456
             }
457 457
         }
458 458
         // do we have any objects left?
459
-        if (! $objects) {
459
+        if ( ! $objects) {
460 460
             return;
461 461
         }
462 462
         // detach any objects at or past this index
Please login to merge, or discard this patch.
Indentation   +500 added lines, -500 removed lines patch added patch discarded remove patch
@@ -19,504 +19,504 @@
 block discarded – undo
19 19
 class Collection extends SplObjectStorage implements CollectionInterface
20 20
 {
21 21
 
22
-    /**
23
-     * a unique string for identifying this collection
24
-     *
25
-     * @type string $collection_identifier
26
-     */
27
-    protected $collection_identifier;
28
-
29
-
30
-    /**
31
-     * an interface (or class) name to be used for restricting the type of objects added to the storage
32
-     * this should be set from within the child class constructor
33
-     *
34
-     * @type string $interface
35
-     */
36
-    protected $collection_interface;
37
-
38
-    /**
39
-     * a short dash separated string describing the contents of this collection
40
-     * used as the base for the $collection_identifier
41
-     * defaults to the class short name if not set
42
-     *
43
-     * @type string $collection_identifier
44
-     */
45
-    protected $collection_name;
46
-
47
-
48
-    /**
49
-     * Collection constructor
50
-     *
51
-     * @param string $collection_interface
52
-     * @param string $collection_name
53
-     * @throws InvalidInterfaceException
54
-     */
55
-    public function __construct($collection_interface, $collection_name = '')
56
-    {
57
-        $this->setCollectionInterface($collection_interface);
58
-        $this->setCollectionName($collection_name);
59
-        $this->setCollectionIdentifier();
60
-    }
61
-
62
-
63
-    /**
64
-     * setCollectionInterface
65
-     *
66
-     * @param  string $collection_interface
67
-     * @throws InvalidInterfaceException
68
-     */
69
-    protected function setCollectionInterface($collection_interface)
70
-    {
71
-        if (! (interface_exists($collection_interface) || class_exists($collection_interface))) {
72
-            throw new InvalidInterfaceException($collection_interface);
73
-        }
74
-        $this->collection_interface = $collection_interface;
75
-    }
76
-
77
-
78
-    /**
79
-     * @return string
80
-     */
81
-    public function collectionName()
82
-    {
83
-        return $this->collection_name;
84
-    }
85
-
86
-
87
-    /**
88
-     * @param string $collection_name
89
-     */
90
-    protected function setCollectionName($collection_name)
91
-    {
92
-        $this->collection_name = ! empty($collection_name)
93
-            ? sanitize_key($collection_name)
94
-            : basename(str_replace('\\', '/', get_class($this)));
95
-    }
96
-
97
-
98
-    /**
99
-     * @return string
100
-     */
101
-    public function collectionIdentifier()
102
-    {
103
-        return $this->collection_identifier;
104
-    }
105
-
106
-
107
-    /**
108
-     * creates a very readable unique 9 character identifier like:  CF2-532-DAC
109
-     * and appends it to the non-qualified class name, ex: ThingCollection-CF2-532-DAC
110
-     *
111
-     * @return void
112
-     */
113
-    protected function setCollectionIdentifier()
114
-    {
115
-        // hash a few collection details
116
-        $identifier = md5(spl_object_hash($this) . $this->collection_interface . time());
117
-        // grab a few characters from the start, middle, and end of the hash
118
-        $id = array();
119
-        for ($x = 0; $x < 19; $x += 9) {
120
-            $id[] = substr($identifier, $x, 3);
121
-        }
122
-        $this->collection_identifier = $this->collection_name . '-' . strtoupper(implode('-', $id));
123
-    }
124
-
125
-
126
-    /**
127
-     * add
128
-     * attaches an object to the Collection
129
-     * and sets any supplied data associated with the current iterator entry
130
-     * by calling EE_Object_Collection::set_identifier()
131
-     *
132
-     * @param        $object
133
-     * @param  mixed $identifier
134
-     * @return bool
135
-     * @throws InvalidEntityException
136
-     * @throws DuplicateCollectionIdentifierException
137
-     */
138
-    public function add($object, $identifier = null)
139
-    {
140
-        if (! $object instanceof $this->collection_interface) {
141
-            throw new InvalidEntityException($object, $this->collection_interface);
142
-        }
143
-        if ($this->contains($object)) {
144
-            throw new DuplicateCollectionIdentifierException($identifier);
145
-        }
146
-        $this->attach($object);
147
-        $this->setIdentifier($object, $identifier);
148
-        return $this->contains($object);
149
-    }
150
-
151
-
152
-    /**
153
-     * getIdentifier
154
-     * if no $identifier is supplied, then the spl_object_hash() is used
155
-     *
156
-     * @param        $object
157
-     * @param  mixed $identifier
158
-     * @return bool
159
-     */
160
-    public function getIdentifier($object, $identifier = null)
161
-    {
162
-        return ! empty($identifier)
163
-            ? $identifier
164
-            : spl_object_hash($object);
165
-    }
166
-
167
-
168
-    /**
169
-     * setIdentifier
170
-     * Sets the data associated with an object in the Collection
171
-     * if no $identifier is supplied, then the spl_object_hash() is used
172
-     *
173
-     * @param        $object
174
-     * @param  mixed $identifier
175
-     * @return bool
176
-     */
177
-    public function setIdentifier($object, $identifier = null)
178
-    {
179
-        $identifier = $this->getIdentifier($object, $identifier);
180
-        $this->rewind();
181
-        while ($this->valid()) {
182
-            if ($object === $this->current()) {
183
-                $this->setInfo($identifier);
184
-                $this->rewind();
185
-                return true;
186
-            }
187
-            $this->next();
188
-        }
189
-        return false;
190
-    }
191
-
192
-
193
-    /**
194
-     * get
195
-     * finds and returns an object in the Collection based on the identifier that was set using addObject()
196
-     * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
197
-     *
198
-     * @param mixed $identifier
199
-     * @return mixed
200
-     */
201
-    public function get($identifier)
202
-    {
203
-        $this->rewind();
204
-        while ($this->valid()) {
205
-            if ($identifier === $this->getInfo()) {
206
-                $object = $this->current();
207
-                $this->rewind();
208
-                return $object;
209
-            }
210
-            $this->next();
211
-        }
212
-        return null;
213
-    }
214
-
215
-
216
-    /**
217
-     * has
218
-     * returns TRUE or FALSE
219
-     * depending on whether the object is within the Collection
220
-     * based on the supplied $identifier
221
-     *
222
-     * @param  mixed $identifier
223
-     * @return bool
224
-     */
225
-    public function has($identifier)
226
-    {
227
-        $this->rewind();
228
-        while ($this->valid()) {
229
-            if ($identifier === $this->getInfo()) {
230
-                $this->rewind();
231
-                return true;
232
-            }
233
-            $this->next();
234
-        }
235
-        return false;
236
-    }
237
-
238
-
239
-    /**
240
-     * hasObject
241
-     * returns TRUE or FALSE depending on whether the supplied object is within the Collection
242
-     *
243
-     * @param $object
244
-     * @return bool
245
-     */
246
-    public function hasObject($object)
247
-    {
248
-        return $this->contains($object);
249
-    }
250
-
251
-
252
-    /**
253
-     * hasObjects
254
-     * returns true if there are objects within the Collection, and false if it is empty
255
-     *
256
-     * @return bool
257
-     */
258
-    public function hasObjects()
259
-    {
260
-        return $this->count() !== 0;
261
-    }
262
-
263
-
264
-    /**
265
-     * isEmpty
266
-     * returns true if there are no objects within the Collection, and false if there are
267
-     *
268
-     * @return bool
269
-     */
270
-    public function isEmpty()
271
-    {
272
-        return $this->count() === 0;
273
-    }
274
-
275
-
276
-    /**
277
-     * remove
278
-     * detaches an object from the Collection
279
-     *
280
-     * @param $object
281
-     * @return bool
282
-     */
283
-    public function remove($object)
284
-    {
285
-        $this->detach($object);
286
-        return true;
287
-    }
288
-
289
-
290
-    /**
291
-     * setCurrent
292
-     * advances pointer to the object whose identifier matches that which was provided
293
-     *
294
-     * @param mixed $identifier
295
-     * @return boolean
296
-     */
297
-    public function setCurrent($identifier)
298
-    {
299
-        $this->rewind();
300
-        while ($this->valid()) {
301
-            if ($identifier === $this->getInfo()) {
302
-                return true;
303
-            }
304
-            $this->next();
305
-        }
306
-        return false;
307
-    }
308
-
309
-
310
-    /**
311
-     * setCurrentUsingObject
312
-     * advances pointer to the provided object
313
-     *
314
-     * @param $object
315
-     * @return boolean
316
-     */
317
-    public function setCurrentUsingObject($object)
318
-    {
319
-        $this->rewind();
320
-        while ($this->valid()) {
321
-            if ($this->current() === $object) {
322
-                return true;
323
-            }
324
-            $this->next();
325
-        }
326
-        return false;
327
-    }
328
-
329
-
330
-    /**
331
-     * Returns the object occupying the index before the current object,
332
-     * unless this is already the first object, in which case it just returns the first object
333
-     *
334
-     * @return mixed
335
-     */
336
-    public function previous()
337
-    {
338
-        $index = $this->indexOf($this->current());
339
-        if ($index === 0) {
340
-            return $this->current();
341
-        }
342
-        $index--;
343
-        return $this->objectAtIndex($index);
344
-    }
345
-
346
-
347
-    /**
348
-     * Returns the index of a given object, or false if not found
349
-     *
350
-     * @see http://stackoverflow.com/a/8736013
351
-     * @param $object
352
-     * @return boolean|int|string
353
-     */
354
-    public function indexOf($object)
355
-    {
356
-        if (! $this->contains($object)) {
357
-            return false;
358
-        }
359
-        foreach ($this as $index => $obj) {
360
-            if ($obj === $object) {
361
-                return $index;
362
-            }
363
-        }
364
-        return false;
365
-    }
366
-
367
-
368
-    /**
369
-     * Returns the object at the given index
370
-     *
371
-     * @see http://stackoverflow.com/a/8736013
372
-     * @param int $index
373
-     * @return mixed
374
-     */
375
-    public function objectAtIndex($index)
376
-    {
377
-        $iterator = new LimitIterator($this, $index, 1);
378
-        $iterator->rewind();
379
-        return $iterator->current();
380
-    }
381
-
382
-
383
-    /**
384
-     * Returns the sequence of objects as specified by the offset and length
385
-     *
386
-     * @see http://stackoverflow.com/a/8736013
387
-     * @param int $offset
388
-     * @param int $length
389
-     * @return array
390
-     */
391
-    public function slice($offset, $length)
392
-    {
393
-        $slice = array();
394
-        $iterator = new LimitIterator($this, $offset, $length);
395
-        foreach ($iterator as $object) {
396
-            $slice[] = $object;
397
-        }
398
-        return $slice;
399
-    }
400
-
401
-
402
-    /**
403
-     * Inserts an object at a certain point
404
-     *
405
-     * @see http://stackoverflow.com/a/8736013
406
-     * @param mixed $object A single object
407
-     * @param int   $index
408
-     * @param mixed $identifier
409
-     * @return bool
410
-     * @throws DuplicateCollectionIdentifierException
411
-     * @throws InvalidEntityException
412
-     */
413
-    public function insertObjectAt($object, $index, $identifier = null)
414
-    {
415
-        // check to ensure that objects don't already exist in the collection
416
-        if ($this->has($identifier)) {
417
-            throw new DuplicateCollectionIdentifierException($identifier);
418
-        }
419
-        // detach any objects at or past this index
420
-        $remaining_objects = array();
421
-        if ($index < $this->count()) {
422
-            $remaining_objects = $this->slice($index, $this->count() - $index);
423
-            foreach ($remaining_objects as $key => $remaining_object) {
424
-                // we need to grab the identifiers for each object and use them as keys
425
-                $remaining_objects[ $remaining_object->getInfo() ] = $remaining_object;
426
-                // and then remove the object from the current tracking array
427
-                unset($remaining_objects[ $key ]);
428
-                // and then remove it from the Collection
429
-                $this->detach($remaining_object);
430
-            }
431
-        }
432
-        // add the new object we're splicing in
433
-        $this->add($object, $identifier);
434
-        // attach the objects we previously detached
435
-        foreach ($remaining_objects as $key => $remaining_object) {
436
-            $this->add($remaining_object, $key);
437
-        }
438
-        return $this->contains($object);
439
-    }
440
-
441
-
442
-    /**
443
-     * Inserts an object (or an array of objects) at a certain point
444
-     *
445
-     * @see http://stackoverflow.com/a/8736013
446
-     * @param mixed $objects A single object or an array of objects
447
-     * @param int   $index
448
-     */
449
-    public function insertAt($objects, $index)
450
-    {
451
-        if (! is_array($objects)) {
452
-            $objects = array($objects);
453
-        }
454
-        // check to ensure that objects don't already exist in the collection
455
-        foreach ($objects as $key => $object) {
456
-            if ($this->contains($object)) {
457
-                unset($objects[ $key ]);
458
-            }
459
-        }
460
-        // do we have any objects left?
461
-        if (! $objects) {
462
-            return;
463
-        }
464
-        // detach any objects at or past this index
465
-        $remaining = array();
466
-        if ($index < $this->count()) {
467
-            $remaining = $this->slice($index, $this->count() - $index);
468
-            foreach ($remaining as $object) {
469
-                $this->detach($object);
470
-            }
471
-        }
472
-        // add the new objects we're splicing in
473
-        foreach ($objects as $object) {
474
-            $this->attach($object);
475
-        }
476
-        // attach the objects we previously detached
477
-        foreach ($remaining as $object) {
478
-            $this->attach($object);
479
-        }
480
-    }
481
-
482
-
483
-    /**
484
-     * Removes the object at the given index
485
-     *
486
-     * @see http://stackoverflow.com/a/8736013
487
-     * @param int $index
488
-     */
489
-    public function removeAt($index)
490
-    {
491
-        $this->detach($this->objectAtIndex($index));
492
-    }
493
-
494
-
495
-    /**
496
-     * detaches ALL objects from the Collection
497
-     */
498
-    public function detachAll()
499
-    {
500
-        $this->rewind();
501
-        while ($this->valid()) {
502
-            $object = $this->current();
503
-            $this->next();
504
-            $this->detach($object);
505
-        }
506
-    }
507
-
508
-
509
-    /**
510
-     * unsets and detaches ALL objects from the Collection
511
-     */
512
-    public function trashAndDetachAll()
513
-    {
514
-        $this->rewind();
515
-        while ($this->valid()) {
516
-            $object = $this->current();
517
-            $this->next();
518
-            $this->detach($object);
519
-            unset($object);
520
-        }
521
-    }
22
+	/**
23
+	 * a unique string for identifying this collection
24
+	 *
25
+	 * @type string $collection_identifier
26
+	 */
27
+	protected $collection_identifier;
28
+
29
+
30
+	/**
31
+	 * an interface (or class) name to be used for restricting the type of objects added to the storage
32
+	 * this should be set from within the child class constructor
33
+	 *
34
+	 * @type string $interface
35
+	 */
36
+	protected $collection_interface;
37
+
38
+	/**
39
+	 * a short dash separated string describing the contents of this collection
40
+	 * used as the base for the $collection_identifier
41
+	 * defaults to the class short name if not set
42
+	 *
43
+	 * @type string $collection_identifier
44
+	 */
45
+	protected $collection_name;
46
+
47
+
48
+	/**
49
+	 * Collection constructor
50
+	 *
51
+	 * @param string $collection_interface
52
+	 * @param string $collection_name
53
+	 * @throws InvalidInterfaceException
54
+	 */
55
+	public function __construct($collection_interface, $collection_name = '')
56
+	{
57
+		$this->setCollectionInterface($collection_interface);
58
+		$this->setCollectionName($collection_name);
59
+		$this->setCollectionIdentifier();
60
+	}
61
+
62
+
63
+	/**
64
+	 * setCollectionInterface
65
+	 *
66
+	 * @param  string $collection_interface
67
+	 * @throws InvalidInterfaceException
68
+	 */
69
+	protected function setCollectionInterface($collection_interface)
70
+	{
71
+		if (! (interface_exists($collection_interface) || class_exists($collection_interface))) {
72
+			throw new InvalidInterfaceException($collection_interface);
73
+		}
74
+		$this->collection_interface = $collection_interface;
75
+	}
76
+
77
+
78
+	/**
79
+	 * @return string
80
+	 */
81
+	public function collectionName()
82
+	{
83
+		return $this->collection_name;
84
+	}
85
+
86
+
87
+	/**
88
+	 * @param string $collection_name
89
+	 */
90
+	protected function setCollectionName($collection_name)
91
+	{
92
+		$this->collection_name = ! empty($collection_name)
93
+			? sanitize_key($collection_name)
94
+			: basename(str_replace('\\', '/', get_class($this)));
95
+	}
96
+
97
+
98
+	/**
99
+	 * @return string
100
+	 */
101
+	public function collectionIdentifier()
102
+	{
103
+		return $this->collection_identifier;
104
+	}
105
+
106
+
107
+	/**
108
+	 * creates a very readable unique 9 character identifier like:  CF2-532-DAC
109
+	 * and appends it to the non-qualified class name, ex: ThingCollection-CF2-532-DAC
110
+	 *
111
+	 * @return void
112
+	 */
113
+	protected function setCollectionIdentifier()
114
+	{
115
+		// hash a few collection details
116
+		$identifier = md5(spl_object_hash($this) . $this->collection_interface . time());
117
+		// grab a few characters from the start, middle, and end of the hash
118
+		$id = array();
119
+		for ($x = 0; $x < 19; $x += 9) {
120
+			$id[] = substr($identifier, $x, 3);
121
+		}
122
+		$this->collection_identifier = $this->collection_name . '-' . strtoupper(implode('-', $id));
123
+	}
124
+
125
+
126
+	/**
127
+	 * add
128
+	 * attaches an object to the Collection
129
+	 * and sets any supplied data associated with the current iterator entry
130
+	 * by calling EE_Object_Collection::set_identifier()
131
+	 *
132
+	 * @param        $object
133
+	 * @param  mixed $identifier
134
+	 * @return bool
135
+	 * @throws InvalidEntityException
136
+	 * @throws DuplicateCollectionIdentifierException
137
+	 */
138
+	public function add($object, $identifier = null)
139
+	{
140
+		if (! $object instanceof $this->collection_interface) {
141
+			throw new InvalidEntityException($object, $this->collection_interface);
142
+		}
143
+		if ($this->contains($object)) {
144
+			throw new DuplicateCollectionIdentifierException($identifier);
145
+		}
146
+		$this->attach($object);
147
+		$this->setIdentifier($object, $identifier);
148
+		return $this->contains($object);
149
+	}
150
+
151
+
152
+	/**
153
+	 * getIdentifier
154
+	 * if no $identifier is supplied, then the spl_object_hash() is used
155
+	 *
156
+	 * @param        $object
157
+	 * @param  mixed $identifier
158
+	 * @return bool
159
+	 */
160
+	public function getIdentifier($object, $identifier = null)
161
+	{
162
+		return ! empty($identifier)
163
+			? $identifier
164
+			: spl_object_hash($object);
165
+	}
166
+
167
+
168
+	/**
169
+	 * setIdentifier
170
+	 * Sets the data associated with an object in the Collection
171
+	 * if no $identifier is supplied, then the spl_object_hash() is used
172
+	 *
173
+	 * @param        $object
174
+	 * @param  mixed $identifier
175
+	 * @return bool
176
+	 */
177
+	public function setIdentifier($object, $identifier = null)
178
+	{
179
+		$identifier = $this->getIdentifier($object, $identifier);
180
+		$this->rewind();
181
+		while ($this->valid()) {
182
+			if ($object === $this->current()) {
183
+				$this->setInfo($identifier);
184
+				$this->rewind();
185
+				return true;
186
+			}
187
+			$this->next();
188
+		}
189
+		return false;
190
+	}
191
+
192
+
193
+	/**
194
+	 * get
195
+	 * finds and returns an object in the Collection based on the identifier that was set using addObject()
196
+	 * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
197
+	 *
198
+	 * @param mixed $identifier
199
+	 * @return mixed
200
+	 */
201
+	public function get($identifier)
202
+	{
203
+		$this->rewind();
204
+		while ($this->valid()) {
205
+			if ($identifier === $this->getInfo()) {
206
+				$object = $this->current();
207
+				$this->rewind();
208
+				return $object;
209
+			}
210
+			$this->next();
211
+		}
212
+		return null;
213
+	}
214
+
215
+
216
+	/**
217
+	 * has
218
+	 * returns TRUE or FALSE
219
+	 * depending on whether the object is within the Collection
220
+	 * based on the supplied $identifier
221
+	 *
222
+	 * @param  mixed $identifier
223
+	 * @return bool
224
+	 */
225
+	public function has($identifier)
226
+	{
227
+		$this->rewind();
228
+		while ($this->valid()) {
229
+			if ($identifier === $this->getInfo()) {
230
+				$this->rewind();
231
+				return true;
232
+			}
233
+			$this->next();
234
+		}
235
+		return false;
236
+	}
237
+
238
+
239
+	/**
240
+	 * hasObject
241
+	 * returns TRUE or FALSE depending on whether the supplied object is within the Collection
242
+	 *
243
+	 * @param $object
244
+	 * @return bool
245
+	 */
246
+	public function hasObject($object)
247
+	{
248
+		return $this->contains($object);
249
+	}
250
+
251
+
252
+	/**
253
+	 * hasObjects
254
+	 * returns true if there are objects within the Collection, and false if it is empty
255
+	 *
256
+	 * @return bool
257
+	 */
258
+	public function hasObjects()
259
+	{
260
+		return $this->count() !== 0;
261
+	}
262
+
263
+
264
+	/**
265
+	 * isEmpty
266
+	 * returns true if there are no objects within the Collection, and false if there are
267
+	 *
268
+	 * @return bool
269
+	 */
270
+	public function isEmpty()
271
+	{
272
+		return $this->count() === 0;
273
+	}
274
+
275
+
276
+	/**
277
+	 * remove
278
+	 * detaches an object from the Collection
279
+	 *
280
+	 * @param $object
281
+	 * @return bool
282
+	 */
283
+	public function remove($object)
284
+	{
285
+		$this->detach($object);
286
+		return true;
287
+	}
288
+
289
+
290
+	/**
291
+	 * setCurrent
292
+	 * advances pointer to the object whose identifier matches that which was provided
293
+	 *
294
+	 * @param mixed $identifier
295
+	 * @return boolean
296
+	 */
297
+	public function setCurrent($identifier)
298
+	{
299
+		$this->rewind();
300
+		while ($this->valid()) {
301
+			if ($identifier === $this->getInfo()) {
302
+				return true;
303
+			}
304
+			$this->next();
305
+		}
306
+		return false;
307
+	}
308
+
309
+
310
+	/**
311
+	 * setCurrentUsingObject
312
+	 * advances pointer to the provided object
313
+	 *
314
+	 * @param $object
315
+	 * @return boolean
316
+	 */
317
+	public function setCurrentUsingObject($object)
318
+	{
319
+		$this->rewind();
320
+		while ($this->valid()) {
321
+			if ($this->current() === $object) {
322
+				return true;
323
+			}
324
+			$this->next();
325
+		}
326
+		return false;
327
+	}
328
+
329
+
330
+	/**
331
+	 * Returns the object occupying the index before the current object,
332
+	 * unless this is already the first object, in which case it just returns the first object
333
+	 *
334
+	 * @return mixed
335
+	 */
336
+	public function previous()
337
+	{
338
+		$index = $this->indexOf($this->current());
339
+		if ($index === 0) {
340
+			return $this->current();
341
+		}
342
+		$index--;
343
+		return $this->objectAtIndex($index);
344
+	}
345
+
346
+
347
+	/**
348
+	 * Returns the index of a given object, or false if not found
349
+	 *
350
+	 * @see http://stackoverflow.com/a/8736013
351
+	 * @param $object
352
+	 * @return boolean|int|string
353
+	 */
354
+	public function indexOf($object)
355
+	{
356
+		if (! $this->contains($object)) {
357
+			return false;
358
+		}
359
+		foreach ($this as $index => $obj) {
360
+			if ($obj === $object) {
361
+				return $index;
362
+			}
363
+		}
364
+		return false;
365
+	}
366
+
367
+
368
+	/**
369
+	 * Returns the object at the given index
370
+	 *
371
+	 * @see http://stackoverflow.com/a/8736013
372
+	 * @param int $index
373
+	 * @return mixed
374
+	 */
375
+	public function objectAtIndex($index)
376
+	{
377
+		$iterator = new LimitIterator($this, $index, 1);
378
+		$iterator->rewind();
379
+		return $iterator->current();
380
+	}
381
+
382
+
383
+	/**
384
+	 * Returns the sequence of objects as specified by the offset and length
385
+	 *
386
+	 * @see http://stackoverflow.com/a/8736013
387
+	 * @param int $offset
388
+	 * @param int $length
389
+	 * @return array
390
+	 */
391
+	public function slice($offset, $length)
392
+	{
393
+		$slice = array();
394
+		$iterator = new LimitIterator($this, $offset, $length);
395
+		foreach ($iterator as $object) {
396
+			$slice[] = $object;
397
+		}
398
+		return $slice;
399
+	}
400
+
401
+
402
+	/**
403
+	 * Inserts an object at a certain point
404
+	 *
405
+	 * @see http://stackoverflow.com/a/8736013
406
+	 * @param mixed $object A single object
407
+	 * @param int   $index
408
+	 * @param mixed $identifier
409
+	 * @return bool
410
+	 * @throws DuplicateCollectionIdentifierException
411
+	 * @throws InvalidEntityException
412
+	 */
413
+	public function insertObjectAt($object, $index, $identifier = null)
414
+	{
415
+		// check to ensure that objects don't already exist in the collection
416
+		if ($this->has($identifier)) {
417
+			throw new DuplicateCollectionIdentifierException($identifier);
418
+		}
419
+		// detach any objects at or past this index
420
+		$remaining_objects = array();
421
+		if ($index < $this->count()) {
422
+			$remaining_objects = $this->slice($index, $this->count() - $index);
423
+			foreach ($remaining_objects as $key => $remaining_object) {
424
+				// we need to grab the identifiers for each object and use them as keys
425
+				$remaining_objects[ $remaining_object->getInfo() ] = $remaining_object;
426
+				// and then remove the object from the current tracking array
427
+				unset($remaining_objects[ $key ]);
428
+				// and then remove it from the Collection
429
+				$this->detach($remaining_object);
430
+			}
431
+		}
432
+		// add the new object we're splicing in
433
+		$this->add($object, $identifier);
434
+		// attach the objects we previously detached
435
+		foreach ($remaining_objects as $key => $remaining_object) {
436
+			$this->add($remaining_object, $key);
437
+		}
438
+		return $this->contains($object);
439
+	}
440
+
441
+
442
+	/**
443
+	 * Inserts an object (or an array of objects) at a certain point
444
+	 *
445
+	 * @see http://stackoverflow.com/a/8736013
446
+	 * @param mixed $objects A single object or an array of objects
447
+	 * @param int   $index
448
+	 */
449
+	public function insertAt($objects, $index)
450
+	{
451
+		if (! is_array($objects)) {
452
+			$objects = array($objects);
453
+		}
454
+		// check to ensure that objects don't already exist in the collection
455
+		foreach ($objects as $key => $object) {
456
+			if ($this->contains($object)) {
457
+				unset($objects[ $key ]);
458
+			}
459
+		}
460
+		// do we have any objects left?
461
+		if (! $objects) {
462
+			return;
463
+		}
464
+		// detach any objects at or past this index
465
+		$remaining = array();
466
+		if ($index < $this->count()) {
467
+			$remaining = $this->slice($index, $this->count() - $index);
468
+			foreach ($remaining as $object) {
469
+				$this->detach($object);
470
+			}
471
+		}
472
+		// add the new objects we're splicing in
473
+		foreach ($objects as $object) {
474
+			$this->attach($object);
475
+		}
476
+		// attach the objects we previously detached
477
+		foreach ($remaining as $object) {
478
+			$this->attach($object);
479
+		}
480
+	}
481
+
482
+
483
+	/**
484
+	 * Removes the object at the given index
485
+	 *
486
+	 * @see http://stackoverflow.com/a/8736013
487
+	 * @param int $index
488
+	 */
489
+	public function removeAt($index)
490
+	{
491
+		$this->detach($this->objectAtIndex($index));
492
+	}
493
+
494
+
495
+	/**
496
+	 * detaches ALL objects from the Collection
497
+	 */
498
+	public function detachAll()
499
+	{
500
+		$this->rewind();
501
+		while ($this->valid()) {
502
+			$object = $this->current();
503
+			$this->next();
504
+			$this->detach($object);
505
+		}
506
+	}
507
+
508
+
509
+	/**
510
+	 * unsets and detaches ALL objects from the Collection
511
+	 */
512
+	public function trashAndDetachAll()
513
+	{
514
+		$this->rewind();
515
+		while ($this->valid()) {
516
+			$object = $this->current();
517
+			$this->next();
518
+			$this->detach($object);
519
+			unset($object);
520
+		}
521
+	}
522 522
 }
Please login to merge, or discard this patch.
core/services/collections/CollectionLoader.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     ) {
88 88
         try {
89 89
             $this->collection_details = $collection_details;
90
-            if (! $collection instanceof CollectionInterface) {
90
+            if ( ! $collection instanceof CollectionInterface) {
91 91
                 $collection = new Collection($this->collection_details->getCollectionInterface());
92 92
             }
93 93
             $this->collection = $collection;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     protected function loadAllFromFilepaths()
121 121
     {
122
-        if (! $this->file_locator instanceof FileLocator) {
122
+        if ( ! $this->file_locator instanceof FileLocator) {
123 123
             $this->file_locator = new FileLocator();
124 124
         }
125 125
         $this->file_locator->setFileMask($this->collection_details->getFileMask());
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
      */
153 153
     protected function loadClassFromFilepath($filepath)
154 154
     {
155
-        if (! is_string($filepath)) {
155
+        if ( ! is_string($filepath)) {
156 156
             throw new InvalidDataTypeException('$filepath', $filepath, 'string');
157 157
         }
158
-        if (! is_readable($filepath)) {
158
+        if ( ! is_readable($filepath)) {
159 159
             throw new InvalidFilePathException($filepath);
160 160
         }
161 161
         require_once $filepath;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         $file_name = basename($filepath);
164 164
         // now remove any file extensions
165 165
         $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($file_name);
166
-        if (! class_exists($class_name)) {
166
+        if ( ! class_exists($class_name)) {
167 167
             throw new InvalidClassException($class_name);
168 168
         }
169 169
         $entity = $this->entity_factory instanceof FactoryInterface
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
             // objects added to the collection based on entity callback, so the entity itself decides
238 238
             case CollectionDetails::ID_CALLBACK_METHOD:
239 239
                 $identifier_callback = $this->collection_details->identifierCallback();
240
-                if (! method_exists($entity, $identifier_callback)) {
240
+                if ( ! method_exists($entity, $identifier_callback)) {
241 241
                     throw new InvalidEntityException(
242 242
                         $entity,
243 243
                         $this->collection_details->getCollectionInterface(),
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
      */
304 304
     protected function loadClassFromFQCN($FQCN)
305 305
     {
306
-        if (! is_string($FQCN)) {
306
+        if ( ! is_string($FQCN)) {
307 307
             throw new InvalidDataTypeException('$FQCN', $FQCN, 'string');
308 308
         }
309
-        if (! class_exists($FQCN)) {
309
+        if ( ! class_exists($FQCN)) {
310 310
             throw new InvalidClassException($FQCN);
311 311
         }
312 312
         do_action(
Please login to merge, or discard this patch.
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -29,295 +29,295 @@
 block discarded – undo
29 29
 class CollectionLoader
30 30
 {
31 31
 
32
-    /**
33
-     * possible return value when adding entities to a collection.
34
-     * denotes that the entity was NOT ADDED to the collection
35
-     */
36
-    const ENTITY_NOT_ADDED = 'entity-not-added-to-collection';
32
+	/**
33
+	 * possible return value when adding entities to a collection.
34
+	 * denotes that the entity was NOT ADDED to the collection
35
+	 */
36
+	const ENTITY_NOT_ADDED = 'entity-not-added-to-collection';
37 37
 
38
-    /**
39
-     * possible return value when adding entities to a collection.
40
-     * denotes that the entity was SUCCESSFULLY ADDED to the collection
41
-     */
42
-    const ENTITY_ADDED = 'entity-added-to-collection';
38
+	/**
39
+	 * possible return value when adding entities to a collection.
40
+	 * denotes that the entity was SUCCESSFULLY ADDED to the collection
41
+	 */
42
+	const ENTITY_ADDED = 'entity-added-to-collection';
43 43
 
44
-    /**
45
-     * possible return value when adding entities to a collection.
46
-     * denotes that the entity was ALREADY ADDED to the collection,
47
-     * and therefore could not be added again.
48
-     */
49
-    const ENTITY_EXISTS = 'entity-already-in-collection';
44
+	/**
45
+	 * possible return value when adding entities to a collection.
46
+	 * denotes that the entity was ALREADY ADDED to the collection,
47
+	 * and therefore could not be added again.
48
+	 */
49
+	const ENTITY_EXISTS = 'entity-already-in-collection';
50 50
 
51 51
 
52
-    /**
53
-     * @var CollectionDetailsInterface $collection_details
54
-     */
55
-    protected $collection_details;
52
+	/**
53
+	 * @var CollectionDetailsInterface $collection_details
54
+	 */
55
+	protected $collection_details;
56 56
 
57
-    /**
58
-     * @var CollectionInterface $collection
59
-     */
60
-    protected $collection;
57
+	/**
58
+	 * @var CollectionInterface $collection
59
+	 */
60
+	protected $collection;
61 61
 
62
-    /**
63
-     * @var FactoryInterface $entity_factory
64
-     */
65
-    protected $entity_factory;
62
+	/**
63
+	 * @var FactoryInterface $entity_factory
64
+	 */
65
+	protected $entity_factory;
66 66
 
67
-    /**
68
-     * @var FileLocator $file_locator
69
-     */
70
-    protected $file_locator;
67
+	/**
68
+	 * @var FileLocator $file_locator
69
+	 */
70
+	protected $file_locator;
71 71
 
72 72
 
73
-    /**
74
-     * CollectionLoader constructor.
75
-     *
76
-     * @param CollectionDetailsInterface $collection_details
77
-     * @param CollectionInterface        $collection
78
-     * @param LocatorInterface           $file_locator
79
-     * @param FactoryInterface|null      $entity_factory
80
-     * @throws CollectionLoaderException
81
-     */
82
-    public function __construct(
83
-        CollectionDetailsInterface $collection_details,
84
-        CollectionInterface $collection = null,
85
-        LocatorInterface $file_locator = null,
86
-        FactoryInterface $entity_factory = null
87
-    ) {
88
-        try {
89
-            $this->collection_details = $collection_details;
90
-            if (! $collection instanceof CollectionInterface) {
91
-                $collection = new Collection($this->collection_details->getCollectionInterface());
92
-            }
93
-            $this->collection = $collection;
94
-            $this->file_locator = $file_locator;
95
-            $this->entity_factory = $entity_factory;
96
-            $this->loadAllFromFilepaths();
97
-            $this->loadFromFQCNs();
98
-        } catch (Exception $exception) {
99
-            throw new CollectionLoaderException($exception);
100
-        }
101
-    }
73
+	/**
74
+	 * CollectionLoader constructor.
75
+	 *
76
+	 * @param CollectionDetailsInterface $collection_details
77
+	 * @param CollectionInterface        $collection
78
+	 * @param LocatorInterface           $file_locator
79
+	 * @param FactoryInterface|null      $entity_factory
80
+	 * @throws CollectionLoaderException
81
+	 */
82
+	public function __construct(
83
+		CollectionDetailsInterface $collection_details,
84
+		CollectionInterface $collection = null,
85
+		LocatorInterface $file_locator = null,
86
+		FactoryInterface $entity_factory = null
87
+	) {
88
+		try {
89
+			$this->collection_details = $collection_details;
90
+			if (! $collection instanceof CollectionInterface) {
91
+				$collection = new Collection($this->collection_details->getCollectionInterface());
92
+			}
93
+			$this->collection = $collection;
94
+			$this->file_locator = $file_locator;
95
+			$this->entity_factory = $entity_factory;
96
+			$this->loadAllFromFilepaths();
97
+			$this->loadFromFQCNs();
98
+		} catch (Exception $exception) {
99
+			throw new CollectionLoaderException($exception);
100
+		}
101
+	}
102 102
 
103 103
 
104
-    /**
105
-     * @return CollectionInterface
106
-     */
107
-    public function getCollection()
108
-    {
109
-        return $this->collection;
110
-    }
104
+	/**
105
+	 * @return CollectionInterface
106
+	 */
107
+	public function getCollection()
108
+	{
109
+		return $this->collection;
110
+	}
111 111
 
112 112
 
113
-    /**
114
-     * @throws InvalidClassException
115
-     * @throws InvalidFilePathException
116
-     * @throws InvalidDataTypeException
117
-     * @throws InvalidEntityException
118
-     * @throws DuplicateCollectionIdentifierException
119
-     */
120
-    protected function loadAllFromFilepaths()
121
-    {
122
-        if (! $this->file_locator instanceof FileLocator) {
123
-            $this->file_locator = new FileLocator();
124
-        }
125
-        $this->file_locator->setFileMask($this->collection_details->getFileMask());
126
-        // find all of the files that match the file mask in the specified folder
127
-        $this->file_locator->locate($this->collection_details->getCollectionPaths());
128
-        // filter the results
129
-        $filepaths = (array) apply_filters(
130
-            'FHEE__CollectionLoader__loadAllFromFilepath__filepaths',
131
-            $this->file_locator->getFilePaths(),
132
-            $this->collection_details->collectionName(),
133
-            $this->collection_details
134
-        );
135
-        if (empty($filepaths)) {
136
-            return;
137
-        }
138
-        foreach ($filepaths as $filepath) {
139
-            $this->loadClassFromFilepath($filepath);
140
-        }
141
-    }
113
+	/**
114
+	 * @throws InvalidClassException
115
+	 * @throws InvalidFilePathException
116
+	 * @throws InvalidDataTypeException
117
+	 * @throws InvalidEntityException
118
+	 * @throws DuplicateCollectionIdentifierException
119
+	 */
120
+	protected function loadAllFromFilepaths()
121
+	{
122
+		if (! $this->file_locator instanceof FileLocator) {
123
+			$this->file_locator = new FileLocator();
124
+		}
125
+		$this->file_locator->setFileMask($this->collection_details->getFileMask());
126
+		// find all of the files that match the file mask in the specified folder
127
+		$this->file_locator->locate($this->collection_details->getCollectionPaths());
128
+		// filter the results
129
+		$filepaths = (array) apply_filters(
130
+			'FHEE__CollectionLoader__loadAllFromFilepath__filepaths',
131
+			$this->file_locator->getFilePaths(),
132
+			$this->collection_details->collectionName(),
133
+			$this->collection_details
134
+		);
135
+		if (empty($filepaths)) {
136
+			return;
137
+		}
138
+		foreach ($filepaths as $filepath) {
139
+			$this->loadClassFromFilepath($filepath);
140
+		}
141
+	}
142 142
 
143 143
 
144
-    /**
145
-     * @param  string $filepath
146
-     * @return string
147
-     * @throws InvalidEntityException
148
-     * @throws InvalidDataTypeException
149
-     * @throws InvalidFilePathException
150
-     * @throws InvalidClassException
151
-     * @throws DuplicateCollectionIdentifierException
152
-     */
153
-    protected function loadClassFromFilepath($filepath)
154
-    {
155
-        if (! is_string($filepath)) {
156
-            throw new InvalidDataTypeException('$filepath', $filepath, 'string');
157
-        }
158
-        if (! is_readable($filepath)) {
159
-            throw new InvalidFilePathException($filepath);
160
-        }
161
-        require_once $filepath;
162
-        // extract filename from path
163
-        $file_name = basename($filepath);
164
-        // now remove any file extensions
165
-        $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($file_name);
166
-        if (! class_exists($class_name)) {
167
-            throw new InvalidClassException($class_name);
168
-        }
169
-        $entity = $this->entity_factory instanceof FactoryInterface
170
-            ? call_user_func(array($this->entity_factory, 'create'), $class_name)
171
-            : new $class_name();
172
-        return $this->addEntityToCollection($entity, $file_name);
173
-    }
144
+	/**
145
+	 * @param  string $filepath
146
+	 * @return string
147
+	 * @throws InvalidEntityException
148
+	 * @throws InvalidDataTypeException
149
+	 * @throws InvalidFilePathException
150
+	 * @throws InvalidClassException
151
+	 * @throws DuplicateCollectionIdentifierException
152
+	 */
153
+	protected function loadClassFromFilepath($filepath)
154
+	{
155
+		if (! is_string($filepath)) {
156
+			throw new InvalidDataTypeException('$filepath', $filepath, 'string');
157
+		}
158
+		if (! is_readable($filepath)) {
159
+			throw new InvalidFilePathException($filepath);
160
+		}
161
+		require_once $filepath;
162
+		// extract filename from path
163
+		$file_name = basename($filepath);
164
+		// now remove any file extensions
165
+		$class_name = EEH_File::get_classname_from_filepath_with_standard_filename($file_name);
166
+		if (! class_exists($class_name)) {
167
+			throw new InvalidClassException($class_name);
168
+		}
169
+		$entity = $this->entity_factory instanceof FactoryInterface
170
+			? call_user_func(array($this->entity_factory, 'create'), $class_name)
171
+			: new $class_name();
172
+		return $this->addEntityToCollection($entity, $file_name);
173
+	}
174 174
 
175 175
 
176
-    /**
177
-     * @param        $entity
178
-     * @param  mixed $identifier
179
-     * @return string
180
-     * @throws InvalidEntityException
181
-     * @throws DuplicateCollectionIdentifierException
182
-     */
183
-    protected function addEntityToCollection($entity, $identifier)
184
-    {
185
-        do_action(
186
-            'FHEE__CollectionLoader__addEntityToCollection__entity',
187
-            $entity,
188
-            $this->collection_details->collectionName(),
189
-            $this->collection_details
190
-        );
191
-        $identifier = $this->setIdentifier($entity, $identifier);
192
-        if ($this->collection->has($identifier)) {
193
-            do_action(
194
-                'FHEE__CollectionLoader__addEntityToCollection__entity_already_added',
195
-                $this,
196
-                $this->collection_details->collectionName(),
197
-                $this->collection_details
198
-            );
199
-            return CollectionLoader::ENTITY_EXISTS;
200
-        }
201
-        if ($this->collection->add($entity, $identifier)) {
202
-            do_action(
203
-                'FHEE__CollectionLoader__addEntityToCollection__entity_added',
204
-                $this,
205
-                $this->collection_details->collectionName(),
206
-                $this->collection_details
207
-            );
208
-            return CollectionLoader::ENTITY_ADDED;
209
-        }
210
-        do_action(
211
-            'FHEE__CollectionLoader__addEntityToCollection__entity_not_added',
212
-            $this,
213
-            $this->collection_details->collectionName(),
214
-            $this->collection_details
215
-        );
216
-        return CollectionLoader::ENTITY_NOT_ADDED;
217
-    }
176
+	/**
177
+	 * @param        $entity
178
+	 * @param  mixed $identifier
179
+	 * @return string
180
+	 * @throws InvalidEntityException
181
+	 * @throws DuplicateCollectionIdentifierException
182
+	 */
183
+	protected function addEntityToCollection($entity, $identifier)
184
+	{
185
+		do_action(
186
+			'FHEE__CollectionLoader__addEntityToCollection__entity',
187
+			$entity,
188
+			$this->collection_details->collectionName(),
189
+			$this->collection_details
190
+		);
191
+		$identifier = $this->setIdentifier($entity, $identifier);
192
+		if ($this->collection->has($identifier)) {
193
+			do_action(
194
+				'FHEE__CollectionLoader__addEntityToCollection__entity_already_added',
195
+				$this,
196
+				$this->collection_details->collectionName(),
197
+				$this->collection_details
198
+			);
199
+			return CollectionLoader::ENTITY_EXISTS;
200
+		}
201
+		if ($this->collection->add($entity, $identifier)) {
202
+			do_action(
203
+				'FHEE__CollectionLoader__addEntityToCollection__entity_added',
204
+				$this,
205
+				$this->collection_details->collectionName(),
206
+				$this->collection_details
207
+			);
208
+			return CollectionLoader::ENTITY_ADDED;
209
+		}
210
+		do_action(
211
+			'FHEE__CollectionLoader__addEntityToCollection__entity_not_added',
212
+			$this,
213
+			$this->collection_details->collectionName(),
214
+			$this->collection_details
215
+		);
216
+		return CollectionLoader::ENTITY_NOT_ADDED;
217
+	}
218 218
 
219 219
 
220
-    /**
221
-     * @param        $entity
222
-     * @param  mixed $identifier
223
-     * @return string
224
-     * @throws InvalidEntityException
225
-     */
226
-    protected function setIdentifier($entity, $identifier)
227
-    {
228
-        switch ($this->collection_details->identifierType()) {
229
-            // every unique object gets added to the collection, but not duplicates of the exact same object
230
-            case CollectionDetails::ID_OBJECT_HASH:
231
-                $identifier = spl_object_hash($entity);
232
-                break;
233
-            // only one entity per class can be added to collection, like a singleton
234
-            case CollectionDetails::ID_CLASS_NAME:
235
-                $identifier = get_class($entity);
236
-                break;
237
-            // objects added to the collection based on entity callback, so the entity itself decides
238
-            case CollectionDetails::ID_CALLBACK_METHOD:
239
-                $identifier_callback = $this->collection_details->identifierCallback();
240
-                if (! method_exists($entity, $identifier_callback)) {
241
-                    throw new InvalidEntityException(
242
-                        $entity,
243
-                        $this->collection_details->getCollectionInterface(),
244
-                        sprintf(
245
-                            esc_html__(
246
-                                'The current collection is configured to use a method named "%1$s" when setting or retrieving objects. The supplied entity is an instance
220
+	/**
221
+	 * @param        $entity
222
+	 * @param  mixed $identifier
223
+	 * @return string
224
+	 * @throws InvalidEntityException
225
+	 */
226
+	protected function setIdentifier($entity, $identifier)
227
+	{
228
+		switch ($this->collection_details->identifierType()) {
229
+			// every unique object gets added to the collection, but not duplicates of the exact same object
230
+			case CollectionDetails::ID_OBJECT_HASH:
231
+				$identifier = spl_object_hash($entity);
232
+				break;
233
+			// only one entity per class can be added to collection, like a singleton
234
+			case CollectionDetails::ID_CLASS_NAME:
235
+				$identifier = get_class($entity);
236
+				break;
237
+			// objects added to the collection based on entity callback, so the entity itself decides
238
+			case CollectionDetails::ID_CALLBACK_METHOD:
239
+				$identifier_callback = $this->collection_details->identifierCallback();
240
+				if (! method_exists($entity, $identifier_callback)) {
241
+					throw new InvalidEntityException(
242
+						$entity,
243
+						$this->collection_details->getCollectionInterface(),
244
+						sprintf(
245
+							esc_html__(
246
+								'The current collection is configured to use a method named "%1$s" when setting or retrieving objects. The supplied entity is an instance
247 247
                                 of "%2$s", but does not contain this method.',
248
-                                'event_espresso'
249
-                            ),
250
-                            $identifier_callback,
251
-                            get_class($entity)
252
-                        )
253
-                    );
254
-                }
255
-                $identifier = $entity->{$identifier_callback}();
256
-                break;
257
-        }
258
-        return apply_filters(
259
-            'FHEE__CollectionLoader__addEntityToCollection__identifier',
260
-            $identifier,
261
-            $this->collection_details->collectionName(),
262
-            $this->collection_details
263
-        );
264
-    }
248
+								'event_espresso'
249
+							),
250
+							$identifier_callback,
251
+							get_class($entity)
252
+						)
253
+					);
254
+				}
255
+				$identifier = $entity->{$identifier_callback}();
256
+				break;
257
+		}
258
+		return apply_filters(
259
+			'FHEE__CollectionLoader__addEntityToCollection__identifier',
260
+			$identifier,
261
+			$this->collection_details->collectionName(),
262
+			$this->collection_details
263
+		);
264
+	}
265 265
 
266 266
 
267
-    /**
268
-     * @throws ReflectionException
269
-     * @throws InvalidArgumentException
270
-     * @throws InvalidInterfaceException
271
-     * @throws EE_Error
272
-     * @throws InvalidClassException
273
-     * @throws InvalidDataTypeException
274
-     * @throws InvalidEntityException
275
-     * @throws DuplicateCollectionIdentifierException
276
-     */
277
-    protected function loadFromFQCNs()
278
-    {
279
-        $FQCNs = $this->collection_details->getCollectionFQCNs();
280
-        $FQCNs = (array) apply_filters(
281
-            'FHEE__CollectionLoader__loadAllFromFQCNs__FQCNs',
282
-            $FQCNs,
283
-            $this->collection_details->collectionName(),
284
-            $this->collection_details
285
-        );
286
-        foreach ($FQCNs as $FQCN) {
287
-            $this->loadClassFromFQCN($FQCN);
288
-        }
289
-    }
267
+	/**
268
+	 * @throws ReflectionException
269
+	 * @throws InvalidArgumentException
270
+	 * @throws InvalidInterfaceException
271
+	 * @throws EE_Error
272
+	 * @throws InvalidClassException
273
+	 * @throws InvalidDataTypeException
274
+	 * @throws InvalidEntityException
275
+	 * @throws DuplicateCollectionIdentifierException
276
+	 */
277
+	protected function loadFromFQCNs()
278
+	{
279
+		$FQCNs = $this->collection_details->getCollectionFQCNs();
280
+		$FQCNs = (array) apply_filters(
281
+			'FHEE__CollectionLoader__loadAllFromFQCNs__FQCNs',
282
+			$FQCNs,
283
+			$this->collection_details->collectionName(),
284
+			$this->collection_details
285
+		);
286
+		foreach ($FQCNs as $FQCN) {
287
+			$this->loadClassFromFQCN($FQCN);
288
+		}
289
+	}
290 290
 
291 291
 
292
-    /**
293
-     * @param  string $FQCN Fully Qualified Class Name
294
-     * @return string
295
-     * @throws InvalidArgumentException
296
-     * @throws InvalidInterfaceException
297
-     * @throws ReflectionException
298
-     * @throws EE_Error
299
-     * @throws InvalidEntityException
300
-     * @throws InvalidDataTypeException
301
-     * @throws InvalidClassException
302
-     * @throws DuplicateCollectionIdentifierException
303
-     */
304
-    protected function loadClassFromFQCN($FQCN)
305
-    {
306
-        if (! is_string($FQCN)) {
307
-            throw new InvalidDataTypeException('$FQCN', $FQCN, 'string');
308
-        }
309
-        if (! class_exists($FQCN)) {
310
-            throw new InvalidClassException($FQCN);
311
-        }
312
-        do_action(
313
-            'FHEE__CollectionLoader__loadClassFromFQCN__beforeLoading',
314
-            $FQCN,
315
-            $this->collection_details->collectionName(),
316
-            $this->collection_details
317
-        );
318
-        $entity = $this->entity_factory instanceof FactoryInterface
319
-            ? call_user_func(array($this->entity_factory, 'create'), $FQCN)
320
-            : EE_Registry::instance()->create($FQCN);
321
-        return $this->addEntityToCollection($entity, $FQCN);
322
-    }
292
+	/**
293
+	 * @param  string $FQCN Fully Qualified Class Name
294
+	 * @return string
295
+	 * @throws InvalidArgumentException
296
+	 * @throws InvalidInterfaceException
297
+	 * @throws ReflectionException
298
+	 * @throws EE_Error
299
+	 * @throws InvalidEntityException
300
+	 * @throws InvalidDataTypeException
301
+	 * @throws InvalidClassException
302
+	 * @throws DuplicateCollectionIdentifierException
303
+	 */
304
+	protected function loadClassFromFQCN($FQCN)
305
+	{
306
+		if (! is_string($FQCN)) {
307
+			throw new InvalidDataTypeException('$FQCN', $FQCN, 'string');
308
+		}
309
+		if (! class_exists($FQCN)) {
310
+			throw new InvalidClassException($FQCN);
311
+		}
312
+		do_action(
313
+			'FHEE__CollectionLoader__loadClassFromFQCN__beforeLoading',
314
+			$FQCN,
315
+			$this->collection_details->collectionName(),
316
+			$this->collection_details
317
+		);
318
+		$entity = $this->entity_factory instanceof FactoryInterface
319
+			? call_user_func(array($this->entity_factory, 'create'), $FQCN)
320
+			: EE_Registry::instance()->create($FQCN);
321
+		return $this->addEntityToCollection($entity, $FQCN);
322
+	}
323 323
 }
Please login to merge, or discard this patch.