Completed
Branch back-compat-edtr-taxes (752e0e)
by
unknown
12:08 queued 09:43
created
modules/ticket_selector/TicketSelectorSimple.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,6 +72,6 @@
 block discarded – undo
72 72
         }
73 73
         $this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription();
74 74
         $this->template_args['template_path']      =
75
-            TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
75
+            TICKET_SELECTOR_TEMPLATES_PATH.'simple_ticket_selector.template.php';
76 76
     }
77 77
 }
Please login to merge, or discard this patch.
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -20,59 +20,59 @@
 block discarded – undo
20 20
 class TicketSelectorSimple extends TicketSelector
21 21
 {
22 22
 
23
-    /**
24
-     * @var EE_Ticket $ticket
25
-     */
26
-    protected $ticket;
23
+	/**
24
+	 * @var EE_Ticket $ticket
25
+	 */
26
+	protected $ticket;
27 27
 
28 28
 
29
-    /**
30
-     * TicketSelectorSimple constructor.
31
-     *
32
-     * @param EE_Event  $event
33
-     * @param EE_Ticket $ticket
34
-     * @param int       $max_attendees
35
-     * @param array     $template_args
36
-     * @throws EE_Error
37
-     */
38
-    public function __construct(EE_Event $event, EE_Ticket $ticket, $max_attendees, array $template_args)
39
-    {
40
-        $this->ticket = $ticket;
41
-        parent::__construct(
42
-            $event,
43
-            [$this->ticket],
44
-            $max_attendees,
45
-            $template_args
46
-        );
47
-    }
29
+	/**
30
+	 * TicketSelectorSimple constructor.
31
+	 *
32
+	 * @param EE_Event  $event
33
+	 * @param EE_Ticket $ticket
34
+	 * @param int       $max_attendees
35
+	 * @param array     $template_args
36
+	 * @throws EE_Error
37
+	 */
38
+	public function __construct(EE_Event $event, EE_Ticket $ticket, $max_attendees, array $template_args)
39
+	{
40
+		$this->ticket = $ticket;
41
+		parent::__construct(
42
+			$event,
43
+			[$this->ticket],
44
+			$max_attendees,
45
+			$template_args
46
+		);
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * sets any and all template args that are required for this Ticket Selector
52
-     *
53
-     * @return void
54
-     * @throws UnexpectedEntityException
55
-     * @throws EE_Error
56
-     */
57
-    protected function addTemplateArgs()
58
-    {
59
-        $this->ticket_rows = 1;
60
-        unset($this->template_args['tickets']);
61
-        $this->template_args['ticket'] = $this->ticket;
62
-        $ticket_selector_row           = new TicketSelectorRowSimple(
63
-            $this->ticket,
64
-            $this->max_attendees,
65
-            $this->template_args['date_format'],
66
-            $this->template_args['event_status']
67
-        );
68
-        $this->template_args['TKT_ID'] = $this->ticket->ID();
69
-        $ticket_selector_row->setupTicketStatusDisplay();
70
-        $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay();
71
-        if (empty($this->template_args['ticket_status_display'])) {
72
-            add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
73
-        }
74
-        $this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription();
75
-        $this->template_args['template_path']      =
76
-            TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
77
-    }
50
+	/**
51
+	 * sets any and all template args that are required for this Ticket Selector
52
+	 *
53
+	 * @return void
54
+	 * @throws UnexpectedEntityException
55
+	 * @throws EE_Error
56
+	 */
57
+	protected function addTemplateArgs()
58
+	{
59
+		$this->ticket_rows = 1;
60
+		unset($this->template_args['tickets']);
61
+		$this->template_args['ticket'] = $this->ticket;
62
+		$ticket_selector_row           = new TicketSelectorRowSimple(
63
+			$this->ticket,
64
+			$this->max_attendees,
65
+			$this->template_args['date_format'],
66
+			$this->template_args['event_status']
67
+		);
68
+		$this->template_args['TKT_ID'] = $this->ticket->ID();
69
+		$ticket_selector_row->setupTicketStatusDisplay();
70
+		$this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay();
71
+		if (empty($this->template_args['ticket_status_display'])) {
72
+			add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
73
+		}
74
+		$this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription();
75
+		$this->template_args['template_path']      =
76
+			TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
77
+	}
78 78
 }
Please login to merge, or discard this patch.
modules/feeds/EED_Feeds.module.php 2 patches
Indentation   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -12,218 +12,218 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * @return EED_Feeds
17
-     */
18
-    public static function instance()
19
-    {
20
-        return parent::get_instance(__CLASS__);
21
-    }
22
-
23
-
24
-    /**
25
-     *    set_hooks - for hooking into EE Core, other modules, etc
26
-     *
27
-     * @access    public
28
-     * @return    void
29
-     */
30
-    public static function set_hooks()
31
-    {
32
-        add_action('parse_request', array('EED_Feeds', 'parse_request'), 10);
33
-        add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1);
34
-        add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2);
35
-        add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2);
36
-    }
37
-
38
-    /**
39
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
40
-     *
41
-     * @access    public
42
-     * @return    void
43
-     */
44
-    public static function set_hooks_admin()
45
-    {
46
-    }
47
-
48
-
49
-    /**
50
-     *    run - initial module setup
51
-     *
52
-     * @access    public
53
-     * @return    void
54
-     */
55
-    public function run($WP)
56
-    {
57
-    }
58
-
59
-
60
-    /**
61
-     *    default_feed
62
-     *
63
-     * @access    public
64
-     * @param    type    rss2, atom, rss, rdf, rssjs
65
-     * @return    string
66
-     */
67
-    public static function default_feed($type = 'rss2')
68
-    {
69
-        // rss2, atom, rss, rdf, rssjs
70
-        $type = 'rss2';
71
-        return $type;
72
-    }
73
-
74
-
75
-    /**
76
-     *    parse_request
77
-     *
78
-     * @access    public
79
-     * @return    void
80
-     */
81
-    public static function parse_request()
82
-    {
83
-        $request = self::getRequest();
84
-        if ($request->requestParamIsSet('post_type')) {
85
-            // define path to templates
86
-            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
87
-            // what kinda post_type are we dealing with ?
88
-            switch ($request->getRequestParam('post_type')) {
89
-                case 'espresso_events':
90
-                    // for rss2, atom, rss, rdf
91
-                    add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1);
92
-                    add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1);
93
-                    // for json ( also uses the above filter )
94
-                    add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1);
95
-                    break;
96
-                case 'espresso_venues':
97
-                    // for rss2, atom, rss, rdf
98
-                    add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1);
99
-                    add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1);
100
-                    // for json ( also uses the above filter )
101
-                    add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1);
102
-                    break;
103
-            }
104
-        }
105
-    }
106
-
107
-
108
-    /**
109
-     *    comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
110
-     *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
111
-     *    so this little snippet of SQL taps into the comment feed query and removes comments for the
112
-     *    espresso_attendees post_type
113
-     *
114
-     * @access    public
115
-     * @param    string $SQL the JOIN clause for the comment feed query
116
-     * @return    void
117
-     */
118
-    public static function comment_feed_join($SQL)
119
-    {
120
-        global $wpdb;
121
-        // check for wp_posts table in JOIN clause
122
-        if (strpos($SQL, $wpdb->posts) !== false) {
123
-            add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true');
124
-        }
125
-        return $SQL;
126
-    }
127
-
128
-
129
-    /**
130
-     *    comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
131
-     *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
132
-     *    so this little snippet of SQL taps into the comment feed query and removes comments for the
133
-     *    espresso_attendees post_type
134
-     *
135
-     * @access    public
136
-     * @param    string $SQL the WHERE clause for the comment feed query
137
-     * @return    void
138
-     */
139
-    public static function comment_feed_where($SQL)
140
-    {
141
-        global $wp_query, $wpdb;
142
-        if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) {
143
-            $SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'";
144
-        }
145
-        return $SQL;
146
-    }
147
-
148
-
149
-    /**
150
-     *    the_event_feed
151
-     *
152
-     * @access    public
153
-     * @param    string $content
154
-     * @return    void
155
-     */
156
-    public static function the_event_feed($content)
157
-    {
158
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
159
-            global $post;
160
-            $template_args = array(
161
-                'EVT_ID'            => $post->ID,
162
-                'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
163
-            );
164
-            $content = EEH_Template::display_template(
165
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
166
-                $template_args,
167
-                true
168
-            );
169
-        }
170
-        return $content;
171
-    }
172
-
173
-
174
-    /**
175
-     *    the_event_rssjs_feed
176
-     *
177
-     * @access    public
178
-     * @param    object $item
179
-     * @return    void
180
-     */
181
-    public static function the_event_rssjs_feed($item)
182
-    {
183
-        if (is_feed() && isset($item->description)) {
184
-            $item->description = EED_Feeds::the_event_feed($item->description);
185
-        }
186
-        return $item;
187
-    }
188
-
189
-
190
-    /**
191
-     *    the_venue_feed
192
-     *
193
-     * @access    public
194
-     * @param    string $content
195
-     * @return    void
196
-     */
197
-    public static function the_venue_feed($content)
198
-    {
199
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
200
-            global $post;
201
-            $template_args = array(
202
-                'VNU_ID'            => $post->ID,
203
-                'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
204
-            );
205
-            $content = EEH_Template::display_template(
206
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
207
-                $template_args,
208
-                true
209
-            );
210
-        }
211
-        return $content;
212
-    }
213
-
214
-
215
-    /**
216
-     *    the_venue_rssjs_feed
217
-     *
218
-     * @access    public
219
-     * @param    object $item
220
-     * @return    void
221
-     */
222
-    public static function the_venue_rssjs_feed($item)
223
-    {
224
-        if (is_feed() && isset($item->description)) {
225
-            $item->description = EED_Feeds::the_venue_feed($item->description);
226
-        }
227
-        return $item;
228
-    }
15
+	/**
16
+	 * @return EED_Feeds
17
+	 */
18
+	public static function instance()
19
+	{
20
+		return parent::get_instance(__CLASS__);
21
+	}
22
+
23
+
24
+	/**
25
+	 *    set_hooks - for hooking into EE Core, other modules, etc
26
+	 *
27
+	 * @access    public
28
+	 * @return    void
29
+	 */
30
+	public static function set_hooks()
31
+	{
32
+		add_action('parse_request', array('EED_Feeds', 'parse_request'), 10);
33
+		add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1);
34
+		add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2);
35
+		add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2);
36
+	}
37
+
38
+	/**
39
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
40
+	 *
41
+	 * @access    public
42
+	 * @return    void
43
+	 */
44
+	public static function set_hooks_admin()
45
+	{
46
+	}
47
+
48
+
49
+	/**
50
+	 *    run - initial module setup
51
+	 *
52
+	 * @access    public
53
+	 * @return    void
54
+	 */
55
+	public function run($WP)
56
+	{
57
+	}
58
+
59
+
60
+	/**
61
+	 *    default_feed
62
+	 *
63
+	 * @access    public
64
+	 * @param    type    rss2, atom, rss, rdf, rssjs
65
+	 * @return    string
66
+	 */
67
+	public static function default_feed($type = 'rss2')
68
+	{
69
+		// rss2, atom, rss, rdf, rssjs
70
+		$type = 'rss2';
71
+		return $type;
72
+	}
73
+
74
+
75
+	/**
76
+	 *    parse_request
77
+	 *
78
+	 * @access    public
79
+	 * @return    void
80
+	 */
81
+	public static function parse_request()
82
+	{
83
+		$request = self::getRequest();
84
+		if ($request->requestParamIsSet('post_type')) {
85
+			// define path to templates
86
+			define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
87
+			// what kinda post_type are we dealing with ?
88
+			switch ($request->getRequestParam('post_type')) {
89
+				case 'espresso_events':
90
+					// for rss2, atom, rss, rdf
91
+					add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1);
92
+					add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1);
93
+					// for json ( also uses the above filter )
94
+					add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1);
95
+					break;
96
+				case 'espresso_venues':
97
+					// for rss2, atom, rss, rdf
98
+					add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1);
99
+					add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1);
100
+					// for json ( also uses the above filter )
101
+					add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1);
102
+					break;
103
+			}
104
+		}
105
+	}
106
+
107
+
108
+	/**
109
+	 *    comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
110
+	 *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
111
+	 *    so this little snippet of SQL taps into the comment feed query and removes comments for the
112
+	 *    espresso_attendees post_type
113
+	 *
114
+	 * @access    public
115
+	 * @param    string $SQL the JOIN clause for the comment feed query
116
+	 * @return    void
117
+	 */
118
+	public static function comment_feed_join($SQL)
119
+	{
120
+		global $wpdb;
121
+		// check for wp_posts table in JOIN clause
122
+		if (strpos($SQL, $wpdb->posts) !== false) {
123
+			add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true');
124
+		}
125
+		return $SQL;
126
+	}
127
+
128
+
129
+	/**
130
+	 *    comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
131
+	 *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
132
+	 *    so this little snippet of SQL taps into the comment feed query and removes comments for the
133
+	 *    espresso_attendees post_type
134
+	 *
135
+	 * @access    public
136
+	 * @param    string $SQL the WHERE clause for the comment feed query
137
+	 * @return    void
138
+	 */
139
+	public static function comment_feed_where($SQL)
140
+	{
141
+		global $wp_query, $wpdb;
142
+		if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) {
143
+			$SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'";
144
+		}
145
+		return $SQL;
146
+	}
147
+
148
+
149
+	/**
150
+	 *    the_event_feed
151
+	 *
152
+	 * @access    public
153
+	 * @param    string $content
154
+	 * @return    void
155
+	 */
156
+	public static function the_event_feed($content)
157
+	{
158
+		if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
159
+			global $post;
160
+			$template_args = array(
161
+				'EVT_ID'            => $post->ID,
162
+				'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
163
+			);
164
+			$content = EEH_Template::display_template(
165
+				RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
166
+				$template_args,
167
+				true
168
+			);
169
+		}
170
+		return $content;
171
+	}
172
+
173
+
174
+	/**
175
+	 *    the_event_rssjs_feed
176
+	 *
177
+	 * @access    public
178
+	 * @param    object $item
179
+	 * @return    void
180
+	 */
181
+	public static function the_event_rssjs_feed($item)
182
+	{
183
+		if (is_feed() && isset($item->description)) {
184
+			$item->description = EED_Feeds::the_event_feed($item->description);
185
+		}
186
+		return $item;
187
+	}
188
+
189
+
190
+	/**
191
+	 *    the_venue_feed
192
+	 *
193
+	 * @access    public
194
+	 * @param    string $content
195
+	 * @return    void
196
+	 */
197
+	public static function the_venue_feed($content)
198
+	{
199
+		if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
200
+			global $post;
201
+			$template_args = array(
202
+				'VNU_ID'            => $post->ID,
203
+				'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
204
+			);
205
+			$content = EEH_Template::display_template(
206
+				RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
207
+				$template_args,
208
+				true
209
+			);
210
+		}
211
+		return $content;
212
+	}
213
+
214
+
215
+	/**
216
+	 *    the_venue_rssjs_feed
217
+	 *
218
+	 * @access    public
219
+	 * @param    object $item
220
+	 * @return    void
221
+	 */
222
+	public static function the_venue_rssjs_feed($item)
223
+	{
224
+		if (is_feed() && isset($item->description)) {
225
+			$item->description = EED_Feeds::the_venue_feed($item->description);
226
+		}
227
+		return $item;
228
+	}
229 229
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         $request = self::getRequest();
84 84
         if ($request->requestParamIsSet('post_type')) {
85 85
             // define path to templates
86
-            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
86
+            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/');
87 87
             // what kinda post_type are we dealing with ?
88 88
             switch ($request->getRequestParam('post_type')) {
89 89
                 case 'espresso_events':
@@ -155,14 +155,14 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public static function the_event_feed($content)
157 157
     {
158
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
158
+        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php')) {
159 159
             global $post;
160 160
             $template_args = array(
161 161
                 'EVT_ID'            => $post->ID,
162 162
                 'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
163 163
             );
164 164
             $content = EEH_Template::display_template(
165
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
165
+                RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php',
166 166
                 $template_args,
167 167
                 true
168 168
             );
@@ -196,14 +196,14 @@  discard block
 block discarded – undo
196 196
      */
197 197
     public static function the_venue_feed($content)
198 198
     {
199
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
199
+        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php')) {
200 200
             global $post;
201 201
             $template_args = array(
202 202
                 'VNU_ID'            => $post->ID,
203 203
                 'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
204 204
             );
205 205
             $content = EEH_Template::display_template(
206
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
206
+                RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php',
207 207
                 $template_args,
208 208
                 true
209 209
             );
Please login to merge, or discard this patch.
modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
      */
229 229
     public function set_submit_button_text($submit_button_text = '')
230 230
     {
231
-        if (! empty($submit_button_text)) {
231
+        if ( ! empty($submit_button_text)) {
232 232
             $this->_submit_button_text = $submit_button_text;
233 233
         } elseif ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
234 234
             if ($this->checkout->revisit) {
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
     public function reg_form_name()
389 389
     {
390 390
         if (empty($this->_reg_form_name)) {
391
-            $this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form');
391
+            $this->set_reg_form_name('ee-spco-'.$this->slug().'-reg-step-form');
392 392
         }
393 393
         return $this->_reg_form_name;
394 394
     }
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
     public function reg_step_url($action = '')
413 413
     {
414 414
         $query_args = ['step' => $this->slug()];
415
-        if (! empty($action)) {
415
+        if ( ! empty($action)) {
416 416
             $query_args['action'] = $action;
417 417
         }
418 418
         // final step has no display
@@ -442,12 +442,12 @@  discard block
 block discarded – undo
442 442
             return new EE_Form_Section_Proper(
443 443
                 [
444 444
                     'layout_strategy' => new EE_Div_Per_Section_Layout(),
445
-                    'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
445
+                    'html_id'         => 'ee-'.$this->slug().'-hidden-inputs',
446 446
                     'subsections'     => [
447 447
                         'next_step' => new EE_Fixed_Hidden_Input(
448 448
                             [
449 449
                                 'html_name' => 'next_step',
450
-                                'html_id'   => 'spco-' . $this->slug() . '-next-step',
450
+                                'html_id'   => 'spco-'.$this->slug().'-next-step',
451 451
                                 'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
452 452
                                     ? $this->checkout->next_step->slug()
453 453
                                     : '',
@@ -461,12 +461,12 @@  discard block
 block discarded – undo
461 461
         return new EE_Form_Section_Proper(
462 462
             [
463 463
                 'layout_strategy' => new EE_Div_Per_Section_Layout(),
464
-                'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
464
+                'html_id'         => 'ee-'.$this->slug().'-hidden-inputs',
465 465
                 'subsections'     => [
466 466
                     'action'         => new EE_Fixed_Hidden_Input(
467 467
                         [
468 468
                             'html_name' => 'action',
469
-                            'html_id'   => 'spco-' . $this->slug() . '-action',
469
+                            'html_id'   => 'spco-'.$this->slug().'-action',
470 470
                             'default'   => apply_filters(
471 471
                                 'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action',
472 472
                                 empty($this->checkout->reg_url_link)
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
                     'next_step'      => new EE_Fixed_Hidden_Input(
480 480
                         [
481 481
                             'html_name' => 'next_step',
482
-                            'html_id'   => 'spco-' . $this->slug() . '-next-step',
482
+                            'html_id'   => 'spco-'.$this->slug().'-next-step',
483 483
                             'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
484 484
                                 ? $this->checkout->next_step->slug()
485 485
                                 : '',
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
      */
514 514
     public function generate_reg_form_for_actions($actions = [])
515 515
     {
516
-        $actions                           = array_merge(
516
+        $actions = array_merge(
517 517
             [
518 518
                 'generate_reg_form',
519 519
                 'display_spco_reg_step',
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
      */
557 557
     public function reg_step_submit_button()
558 558
     {
559
-        if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
559
+        if ( ! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
560 560
             return '';
561 561
         }
562 562
         ob_start();
@@ -570,18 +570,18 @@  discard block
 block discarded – undo
570 570
         // generate submit button
571 571
         $submit_btn = new EE_Submit_Input(
572 572
             [
573
-                'html_name'             => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
574
-                'html_id'               => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
573
+                'html_name'             => 'spco-go-to-step-'.$this->checkout->next_step->slug(),
574
+                'html_id'               => 'spco-go-to-step-'.$this->checkout->next_step->slug(),
575 575
                 'html_class'            => 'spco-next-step-btn',
576
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
576
+                'other_html_attributes' => ' rel="'.$this->slug().'"',
577 577
                 'default'               => $this->submit_button_text(),
578 578
             ]
579 579
         );
580 580
         $submit_btn->set_button_css_attributes(true, 'large');
581 581
         $submit_btn_html = $submit_btn->get_html_for_input();
582
-        $html            .= EEH_HTML::div(
582
+        $html .= EEH_HTML::div(
583 583
             apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $submit_btn_html, $this),
584
-            'spco-' . $this->slug() . '-whats-next-buttons-dv',
584
+            'spco-'.$this->slug().'-whats-next-buttons-dv',
585 585
             'spco-whats-next-buttons'
586 586
         );
587 587
         return $html;
Please login to merge, or discard this patch.
Indentation   +644 added lines, -644 removed lines patch added patch discarded remove patch
@@ -14,648 +14,648 @@
 block discarded – undo
14 14
 abstract class EE_SPCO_Reg_Step
15 15
 {
16 16
 
17
-    /**
18
-     *    $_completed - TRUE if this step has fully completed it's duties
19
-     *
20
-     * @access protected
21
-     * @type bool $_completed
22
-     */
23
-    protected $_completed = false;
24
-
25
-    /**
26
-     *    $_is_current_step - TRUE if this is the current step
27
-     *
28
-     * @access protected
29
-     * @type bool $_is_current_step
30
-     */
31
-    protected $_is_current_step = false;
32
-
33
-    /**
34
-     *    $_order - when the reg step should be run relative to other steps
35
-     *
36
-     * @access protected
37
-     * @type int $_template
38
-     */
39
-    protected $_order = 0;
40
-
41
-    /**
42
-     *    $_slug - URL param for this step
43
-     *
44
-     * @access protected
45
-     * @type string $_slug
46
-     */
47
-    protected $_slug;
48
-
49
-    /**
50
-     *    $_name - Step Name - translatable string
51
-     *
52
-     * @access protected
53
-     * @type string $_slug
54
-     */
55
-    protected $_name;
56
-
57
-    /**
58
-     *    $_submit_button_text - translatable string that appears on this step's submit button
59
-     *
60
-     * @access protected
61
-     * @type string $_slug
62
-     */
63
-    protected $_submit_button_text;
64
-
65
-    /**
66
-     *    $_template - template name
67
-     *
68
-     * @access protected
69
-     * @type string $_template
70
-     */
71
-    protected $_template;
72
-
73
-    /**
74
-     *    $_reg_form_name - the form input name and id attribute
75
-     *
76
-     * @access protected
77
-     * @var string $_reg_form_name
78
-     */
79
-    protected $_reg_form_name;
80
-
81
-    /**
82
-     *    $_success_message - text to display upon successful form submission
83
-     *
84
-     * @access private
85
-     * @var string $_success_message
86
-     */
87
-    protected $_success_message;
88
-
89
-    /**
90
-     *    $_instructions - a brief description of how to complete the reg step.
91
-     *    Usually displayed in conjunction with the previous step's success message.
92
-     *
93
-     * @access private
94
-     * @var string $_instructions
95
-     */
96
-    protected $_instructions;
97
-
98
-    /**
99
-     *    $_valid_data - the normalized and validated data for this step
100
-     *
101
-     * @access public
102
-     * @var array $_valid_data
103
-     */
104
-    protected $_valid_data = [];
105
-
106
-    /**
107
-     *    $reg_form - the registration form for this step
108
-     *
109
-     * @access public
110
-     * @var EE_Form_Section_Proper $reg_form
111
-     */
112
-    public $reg_form;
113
-
114
-    /**
115
-     *    $checkout - EE_Checkout object for handling the properties of the current checkout process
116
-     *
117
-     * @access public
118
-     * @var EE_Checkout $checkout
119
-     */
120
-    public $checkout;
121
-
122
-    /**
123
-     * @var RequestInterface $request
124
-     */
125
-    protected $request;
126
-
127
-
128
-    /**
129
-     * @return void
130
-     */
131
-    abstract public function translate_js_strings();
132
-
133
-
134
-    /**
135
-     * @return void
136
-     */
137
-    abstract public function enqueue_styles_and_scripts();
138
-
139
-
140
-    /**
141
-     * @return boolean
142
-     */
143
-    abstract public function initialize_reg_step();
144
-
145
-
146
-    /**
147
-     * @return string
148
-     */
149
-    abstract public function generate_reg_form();
150
-
151
-
152
-    /**
153
-     * @return boolean
154
-     */
155
-    abstract public function process_reg_step();
156
-
157
-
158
-    /**
159
-     * @return boolean
160
-     */
161
-    abstract public function update_reg_step();
162
-
163
-
164
-    /**
165
-     * @return boolean
166
-     */
167
-    public function completed()
168
-    {
169
-        return $this->_completed;
170
-    }
171
-
172
-
173
-    /**
174
-     * set_completed - toggles $_completed to TRUE
175
-     */
176
-    public function set_completed()
177
-    {
178
-        // DEBUG LOG
179
-        // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
180
-        $this->_completed = apply_filters('FHEE__EE_SPCO_Reg_Step__set_completed___completed', true, $this);
181
-    }
182
-
183
-
184
-    /**
185
-     * set_completed - toggles $_completed to FALSE
186
-     */
187
-    public function set_not_completed()
188
-    {
189
-        $this->_completed = false;
190
-    }
191
-
192
-
193
-    /**
194
-     * @return string
195
-     */
196
-    public function name()
197
-    {
198
-        return $this->_name;
199
-    }
200
-
201
-
202
-    /**
203
-     * @return string
204
-     */
205
-    public function slug()
206
-    {
207
-        return $this->_slug;
208
-    }
209
-
210
-
211
-    /**
212
-     * submit_button_text
213
-     * the text that appears on the reg step form submit button
214
-     *
215
-     * @return string
216
-     */
217
-    public function submit_button_text()
218
-    {
219
-        return $this->_submit_button_text;
220
-    }
221
-
222
-
223
-    /**
224
-     * set_submit_button_text
225
-     * sets the text that appears on the reg step form submit button
226
-     *
227
-     * @param string $submit_button_text
228
-     */
229
-    public function set_submit_button_text($submit_button_text = '')
230
-    {
231
-        if (! empty($submit_button_text)) {
232
-            $this->_submit_button_text = $submit_button_text;
233
-        } elseif ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
234
-            if ($this->checkout->revisit) {
235
-                $this->_submit_button_text = sprintf(
236
-                    esc_html__('Update %s', 'event_espresso'),
237
-                    $this->checkout->current_step->name()
238
-                );
239
-            } else {
240
-                $this->_submit_button_text = sprintf(
241
-                    esc_html__('Proceed to %s', 'event_espresso'),
242
-                    $this->checkout->next_step->name()
243
-                );
244
-            }
245
-        }
246
-        // filters the submit button text
247
-        $this->_submit_button_text = apply_filters(
248
-            'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
249
-            $this->_submit_button_text,
250
-            $this->checkout
251
-        );
252
-    }
253
-
254
-
255
-    /**
256
-     * @param boolean $is_current_step
257
-     */
258
-    public function set_is_current_step($is_current_step)
259
-    {
260
-        $this->_is_current_step = $is_current_step;
261
-    }
262
-
263
-
264
-    /**
265
-     * @return boolean
266
-     */
267
-    public function is_current_step()
268
-    {
269
-        return $this->_is_current_step;
270
-    }
271
-
272
-
273
-    /**
274
-     * @return boolean
275
-     */
276
-    public function is_final_step()
277
-    {
278
-        return $this instanceof EE_SPCO_Reg_Step_Finalize_Registration;
279
-    }
280
-
281
-
282
-    /**
283
-     * @param int $order
284
-     */
285
-    public function set_order($order)
286
-    {
287
-        $this->_order = $order;
288
-    }
289
-
290
-
291
-    /**
292
-     * @return int
293
-     */
294
-    public function order()
295
-    {
296
-        return $this->_order;
297
-    }
298
-
299
-
300
-    /**
301
-     * @return string
302
-     */
303
-    public function template()
304
-    {
305
-        return $this->_template;
306
-    }
307
-
308
-
309
-    /**
310
-     * @return string
311
-     */
312
-    public function success_message()
313
-    {
314
-        return $this->_success_message;
315
-    }
316
-
317
-
318
-    /**
319
-     * _set_success_message
320
-     *
321
-     * @param string $success_message
322
-     */
323
-    protected function _set_success_message($success_message)
324
-    {
325
-        $this->_success_message = $success_message;
326
-    }
327
-
328
-
329
-    /**
330
-     * _reset_success_message
331
-     *
332
-     * @return void
333
-     */
334
-    protected function _reset_success_message()
335
-    {
336
-        $this->_success_message = '';
337
-    }
338
-
339
-
340
-    /**
341
-     * @return string
342
-     */
343
-    public function _instructions()
344
-    {
345
-        return $this->_instructions;
346
-    }
347
-
348
-
349
-    /**
350
-     * @param string $instructions
351
-     */
352
-    public function set_instructions($instructions)
353
-    {
354
-        $this->_instructions = apply_filters(
355
-            'FHEE__EE_SPCO_Reg_Step__set_instructions__instructions',
356
-            $instructions,
357
-            $this
358
-        );
359
-    }
360
-
361
-
362
-    /**
363
-     * @param array $valid_data
364
-     */
365
-    public function set_valid_data($valid_data)
366
-    {
367
-        $this->_valid_data = $valid_data;
368
-    }
369
-
370
-
371
-    /**
372
-     * @return array
373
-     * @throws EE_Error
374
-     * @throws EE_Error
375
-     */
376
-    public function valid_data()
377
-    {
378
-        if (empty($this->_valid_data)) {
379
-            $this->_valid_data = $this->reg_form->valid_data();
380
-        }
381
-        return $this->_valid_data;
382
-    }
383
-
384
-
385
-    /**
386
-     * @return string
387
-     */
388
-    public function reg_form_name()
389
-    {
390
-        if (empty($this->_reg_form_name)) {
391
-            $this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form');
392
-        }
393
-        return $this->_reg_form_name;
394
-    }
395
-
396
-
397
-    /**
398
-     * @param string $reg_form_name
399
-     */
400
-    protected function set_reg_form_name($reg_form_name)
401
-    {
402
-        $this->_reg_form_name = $reg_form_name;
403
-    }
404
-
405
-
406
-    /**
407
-     * reg_step_url
408
-     *
409
-     * @param string $action
410
-     * @return string
411
-     */
412
-    public function reg_step_url($action = '')
413
-    {
414
-        $query_args = ['step' => $this->slug()];
415
-        if (! empty($action)) {
416
-            $query_args['action'] = $action;
417
-        }
418
-        // final step has no display
419
-        if ($this instanceof EE_SPCO_Reg_Step_Finalize_Registration && $action === 'display_spco_reg_step') {
420
-            $query_args['action'] = 'process_reg_step';
421
-        }
422
-        if ($this->checkout->revisit) {
423
-            $query_args['revisit'] = true;
424
-        }
425
-        if ($this->checkout->reg_url_link) {
426
-            $query_args['e_reg_url_link'] = $this->checkout->reg_url_link;
427
-        }
428
-        return add_query_arg($query_args, $this->checkout->reg_page_base_url);
429
-    }
430
-
431
-
432
-    /**
433
-     * creates the default hidden inputs section
434
-     *
435
-     * @return EE_Form_Section_Proper
436
-     * @throws EE_Error
437
-     */
438
-    public function reg_step_hidden_inputs()
439
-    {
440
-        // hidden inputs for admin registrations
441
-        if ($this->checkout->admin_request) {
442
-            return new EE_Form_Section_Proper(
443
-                [
444
-                    'layout_strategy' => new EE_Div_Per_Section_Layout(),
445
-                    'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
446
-                    'subsections'     => [
447
-                        'next_step' => new EE_Fixed_Hidden_Input(
448
-                            [
449
-                                'html_name' => 'next_step',
450
-                                'html_id'   => 'spco-' . $this->slug() . '-next-step',
451
-                                'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
452
-                                    ? $this->checkout->next_step->slug()
453
-                                    : '',
454
-                            ]
455
-                        ),
456
-                    ],
457
-                ]
458
-            );
459
-        }
460
-        // hidden inputs for frontend registrations
461
-        return new EE_Form_Section_Proper(
462
-            [
463
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
464
-                'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
465
-                'subsections'     => [
466
-                    'action'         => new EE_Fixed_Hidden_Input(
467
-                        [
468
-                            'html_name' => 'action',
469
-                            'html_id'   => 'spco-' . $this->slug() . '-action',
470
-                            'default'   => apply_filters(
471
-                                'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action',
472
-                                empty($this->checkout->reg_url_link)
473
-                                    ? 'process_reg_step'
474
-                                    : 'update_reg_step',
475
-                                $this
476
-                            ),
477
-                        ]
478
-                    ),
479
-                    'next_step'      => new EE_Fixed_Hidden_Input(
480
-                        [
481
-                            'html_name' => 'next_step',
482
-                            'html_id'   => 'spco-' . $this->slug() . '-next-step',
483
-                            'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
484
-                                ? $this->checkout->next_step->slug()
485
-                                : '',
486
-                        ]
487
-                    ),
488
-                    'e_reg_url_link' => new EE_Fixed_Hidden_Input(
489
-                        [
490
-                            'html_name' => 'e_reg_url_link',
491
-                            'html_id'   => 'spco-reg_url_link',
492
-                            'default'   => $this->checkout->reg_url_link,
493
-                        ]
494
-                    ),
495
-                    'revisit'        => new EE_Fixed_Hidden_Input(
496
-                        [
497
-                            'html_name' => 'revisit',
498
-                            'html_id'   => 'spco-revisit',
499
-                            'default'   => $this->checkout->revisit,
500
-                        ]
501
-                    ),
502
-                ],
503
-            ]
504
-        );
505
-    }
506
-
507
-
508
-    /**
509
-     * generate_reg_form_for_actions
510
-     *
511
-     * @param array $actions
512
-     * @return void
513
-     */
514
-    public function generate_reg_form_for_actions($actions = [])
515
-    {
516
-        $actions                           = array_merge(
517
-            [
518
-                'generate_reg_form',
519
-                'display_spco_reg_step',
520
-                'process_reg_step',
521
-                'update_reg_step',
522
-            ],
523
-            $actions
524
-        );
525
-        $this->checkout->generate_reg_form = in_array($this->checkout->action, $actions, true);
526
-    }
527
-
528
-
529
-    /**
530
-     * @return string
531
-     * @throws EE_Error
532
-     */
533
-    public function display_reg_form()
534
-    {
535
-        $html = '';
536
-        if ($this->reg_form instanceof EE_Form_Section_Proper) {
537
-            do_action('AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form', $this->reg_form, $this);
538
-            $html .= ! $this->checkout->admin_request ? $this->reg_form->form_open($this->reg_step_url()) : '';
539
-            if ($this->request->isAjax()) {
540
-                $this->reg_form->localize_validation_rules();
541
-                $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
542
-            }
543
-            $html .= $this->reg_form->get_html();
544
-            $html .= ! $this->checkout->admin_request ? $this->reg_step_submit_button() : '';
545
-            $html .= ! $this->checkout->admin_request ? $this->reg_form->form_close() : '';
546
-        }
547
-        return $html;
548
-    }
549
-
550
-
551
-    /**
552
-     * div_class - returns nothing for current step, but a css class of "hidden" for others
553
-     *
554
-     * @return string
555
-     * @throws EE_Error
556
-     */
557
-    public function reg_step_submit_button()
558
-    {
559
-        if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
560
-            return '';
561
-        }
562
-        ob_start();
563
-        do_action(
564
-            'AHEE__before_spco_whats_next_buttons',
565
-            $this->slug(),
566
-            $this->checkout->next_step->slug(),
567
-            $this->checkout
568
-        );
569
-        $html = ob_get_clean();
570
-        // generate submit button
571
-        $submit_btn = new EE_Submit_Input(
572
-            [
573
-                'html_name'             => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
574
-                'html_id'               => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
575
-                'html_class'            => 'spco-next-step-btn',
576
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
577
-                'default'               => $this->submit_button_text(),
578
-            ]
579
-        );
580
-        $submit_btn->set_button_css_attributes(true, 'large');
581
-        $submit_btn_html = $submit_btn->get_html_for_input();
582
-        $html            .= EEH_HTML::div(
583
-            apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $submit_btn_html, $this),
584
-            'spco-' . $this->slug() . '-whats-next-buttons-dv',
585
-            'spco-whats-next-buttons'
586
-        );
587
-        return $html;
588
-    }
589
-
590
-
591
-    /**
592
-     * div_class - returns nothing for current step, but a css class of "hidden" for others
593
-     *
594
-     * @return string
595
-     */
596
-    public function div_class()
597
-    {
598
-        return $this->is_current_step() ? '' : ' hidden';
599
-    }
600
-
601
-
602
-    /**
603
-     * div_class - returns  a css class of "hidden" for current step, but nothing for others
604
-     *
605
-     * @return string
606
-     */
607
-    public function edit_lnk_url()
608
-    {
609
-        return add_query_arg(['step' => $this->slug()], $this->checkout->reg_page_base_url);
610
-    }
611
-
612
-
613
-    /**
614
-     * div_class - returns  a css class of "hidden" for current step, but nothing for others
615
-     *
616
-     * @return string
617
-     */
618
-    public function edit_link_class()
619
-    {
620
-        return $this->is_current_step() ? ' hidden' : '';
621
-    }
622
-
623
-
624
-    /**
625
-     * update_checkout with changes that have been made to the cart
626
-     *
627
-     * @return void
628
-     * @throws EE_Error
629
-     * @throws ReflectionException
630
-     */
631
-    public function update_checkout()
632
-    {
633
-        // grab the cart grand total and reset TXN total
634
-        $this->checkout->transaction->set_total($this->checkout->cart->get_cart_grand_total());
635
-        $this->checkout->stash_transaction_and_checkout();
636
-    }
637
-
638
-
639
-    /**
640
-     *    __sleep
641
-     * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
642
-     * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
643
-     * reg form, because if needed, it will be regenerated anyways
644
-     *
645
-     * @return array
646
-     */
647
-    public function __sleep()
648
-    {
649
-        // remove the reg form and the checkout
650
-        return array_diff(array_keys(get_object_vars($this)), ['reg_form', 'checkout']);
651
-    }
652
-
653
-
654
-    /**
655
-     * @param RequestInterface $request
656
-     */
657
-    public function setRequest(RequestInterface $request)
658
-    {
659
-        $this->request = $request;
660
-    }
17
+	/**
18
+	 *    $_completed - TRUE if this step has fully completed it's duties
19
+	 *
20
+	 * @access protected
21
+	 * @type bool $_completed
22
+	 */
23
+	protected $_completed = false;
24
+
25
+	/**
26
+	 *    $_is_current_step - TRUE if this is the current step
27
+	 *
28
+	 * @access protected
29
+	 * @type bool $_is_current_step
30
+	 */
31
+	protected $_is_current_step = false;
32
+
33
+	/**
34
+	 *    $_order - when the reg step should be run relative to other steps
35
+	 *
36
+	 * @access protected
37
+	 * @type int $_template
38
+	 */
39
+	protected $_order = 0;
40
+
41
+	/**
42
+	 *    $_slug - URL param for this step
43
+	 *
44
+	 * @access protected
45
+	 * @type string $_slug
46
+	 */
47
+	protected $_slug;
48
+
49
+	/**
50
+	 *    $_name - Step Name - translatable string
51
+	 *
52
+	 * @access protected
53
+	 * @type string $_slug
54
+	 */
55
+	protected $_name;
56
+
57
+	/**
58
+	 *    $_submit_button_text - translatable string that appears on this step's submit button
59
+	 *
60
+	 * @access protected
61
+	 * @type string $_slug
62
+	 */
63
+	protected $_submit_button_text;
64
+
65
+	/**
66
+	 *    $_template - template name
67
+	 *
68
+	 * @access protected
69
+	 * @type string $_template
70
+	 */
71
+	protected $_template;
72
+
73
+	/**
74
+	 *    $_reg_form_name - the form input name and id attribute
75
+	 *
76
+	 * @access protected
77
+	 * @var string $_reg_form_name
78
+	 */
79
+	protected $_reg_form_name;
80
+
81
+	/**
82
+	 *    $_success_message - text to display upon successful form submission
83
+	 *
84
+	 * @access private
85
+	 * @var string $_success_message
86
+	 */
87
+	protected $_success_message;
88
+
89
+	/**
90
+	 *    $_instructions - a brief description of how to complete the reg step.
91
+	 *    Usually displayed in conjunction with the previous step's success message.
92
+	 *
93
+	 * @access private
94
+	 * @var string $_instructions
95
+	 */
96
+	protected $_instructions;
97
+
98
+	/**
99
+	 *    $_valid_data - the normalized and validated data for this step
100
+	 *
101
+	 * @access public
102
+	 * @var array $_valid_data
103
+	 */
104
+	protected $_valid_data = [];
105
+
106
+	/**
107
+	 *    $reg_form - the registration form for this step
108
+	 *
109
+	 * @access public
110
+	 * @var EE_Form_Section_Proper $reg_form
111
+	 */
112
+	public $reg_form;
113
+
114
+	/**
115
+	 *    $checkout - EE_Checkout object for handling the properties of the current checkout process
116
+	 *
117
+	 * @access public
118
+	 * @var EE_Checkout $checkout
119
+	 */
120
+	public $checkout;
121
+
122
+	/**
123
+	 * @var RequestInterface $request
124
+	 */
125
+	protected $request;
126
+
127
+
128
+	/**
129
+	 * @return void
130
+	 */
131
+	abstract public function translate_js_strings();
132
+
133
+
134
+	/**
135
+	 * @return void
136
+	 */
137
+	abstract public function enqueue_styles_and_scripts();
138
+
139
+
140
+	/**
141
+	 * @return boolean
142
+	 */
143
+	abstract public function initialize_reg_step();
144
+
145
+
146
+	/**
147
+	 * @return string
148
+	 */
149
+	abstract public function generate_reg_form();
150
+
151
+
152
+	/**
153
+	 * @return boolean
154
+	 */
155
+	abstract public function process_reg_step();
156
+
157
+
158
+	/**
159
+	 * @return boolean
160
+	 */
161
+	abstract public function update_reg_step();
162
+
163
+
164
+	/**
165
+	 * @return boolean
166
+	 */
167
+	public function completed()
168
+	{
169
+		return $this->_completed;
170
+	}
171
+
172
+
173
+	/**
174
+	 * set_completed - toggles $_completed to TRUE
175
+	 */
176
+	public function set_completed()
177
+	{
178
+		// DEBUG LOG
179
+		// $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
180
+		$this->_completed = apply_filters('FHEE__EE_SPCO_Reg_Step__set_completed___completed', true, $this);
181
+	}
182
+
183
+
184
+	/**
185
+	 * set_completed - toggles $_completed to FALSE
186
+	 */
187
+	public function set_not_completed()
188
+	{
189
+		$this->_completed = false;
190
+	}
191
+
192
+
193
+	/**
194
+	 * @return string
195
+	 */
196
+	public function name()
197
+	{
198
+		return $this->_name;
199
+	}
200
+
201
+
202
+	/**
203
+	 * @return string
204
+	 */
205
+	public function slug()
206
+	{
207
+		return $this->_slug;
208
+	}
209
+
210
+
211
+	/**
212
+	 * submit_button_text
213
+	 * the text that appears on the reg step form submit button
214
+	 *
215
+	 * @return string
216
+	 */
217
+	public function submit_button_text()
218
+	{
219
+		return $this->_submit_button_text;
220
+	}
221
+
222
+
223
+	/**
224
+	 * set_submit_button_text
225
+	 * sets the text that appears on the reg step form submit button
226
+	 *
227
+	 * @param string $submit_button_text
228
+	 */
229
+	public function set_submit_button_text($submit_button_text = '')
230
+	{
231
+		if (! empty($submit_button_text)) {
232
+			$this->_submit_button_text = $submit_button_text;
233
+		} elseif ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
234
+			if ($this->checkout->revisit) {
235
+				$this->_submit_button_text = sprintf(
236
+					esc_html__('Update %s', 'event_espresso'),
237
+					$this->checkout->current_step->name()
238
+				);
239
+			} else {
240
+				$this->_submit_button_text = sprintf(
241
+					esc_html__('Proceed to %s', 'event_espresso'),
242
+					$this->checkout->next_step->name()
243
+				);
244
+			}
245
+		}
246
+		// filters the submit button text
247
+		$this->_submit_button_text = apply_filters(
248
+			'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
249
+			$this->_submit_button_text,
250
+			$this->checkout
251
+		);
252
+	}
253
+
254
+
255
+	/**
256
+	 * @param boolean $is_current_step
257
+	 */
258
+	public function set_is_current_step($is_current_step)
259
+	{
260
+		$this->_is_current_step = $is_current_step;
261
+	}
262
+
263
+
264
+	/**
265
+	 * @return boolean
266
+	 */
267
+	public function is_current_step()
268
+	{
269
+		return $this->_is_current_step;
270
+	}
271
+
272
+
273
+	/**
274
+	 * @return boolean
275
+	 */
276
+	public function is_final_step()
277
+	{
278
+		return $this instanceof EE_SPCO_Reg_Step_Finalize_Registration;
279
+	}
280
+
281
+
282
+	/**
283
+	 * @param int $order
284
+	 */
285
+	public function set_order($order)
286
+	{
287
+		$this->_order = $order;
288
+	}
289
+
290
+
291
+	/**
292
+	 * @return int
293
+	 */
294
+	public function order()
295
+	{
296
+		return $this->_order;
297
+	}
298
+
299
+
300
+	/**
301
+	 * @return string
302
+	 */
303
+	public function template()
304
+	{
305
+		return $this->_template;
306
+	}
307
+
308
+
309
+	/**
310
+	 * @return string
311
+	 */
312
+	public function success_message()
313
+	{
314
+		return $this->_success_message;
315
+	}
316
+
317
+
318
+	/**
319
+	 * _set_success_message
320
+	 *
321
+	 * @param string $success_message
322
+	 */
323
+	protected function _set_success_message($success_message)
324
+	{
325
+		$this->_success_message = $success_message;
326
+	}
327
+
328
+
329
+	/**
330
+	 * _reset_success_message
331
+	 *
332
+	 * @return void
333
+	 */
334
+	protected function _reset_success_message()
335
+	{
336
+		$this->_success_message = '';
337
+	}
338
+
339
+
340
+	/**
341
+	 * @return string
342
+	 */
343
+	public function _instructions()
344
+	{
345
+		return $this->_instructions;
346
+	}
347
+
348
+
349
+	/**
350
+	 * @param string $instructions
351
+	 */
352
+	public function set_instructions($instructions)
353
+	{
354
+		$this->_instructions = apply_filters(
355
+			'FHEE__EE_SPCO_Reg_Step__set_instructions__instructions',
356
+			$instructions,
357
+			$this
358
+		);
359
+	}
360
+
361
+
362
+	/**
363
+	 * @param array $valid_data
364
+	 */
365
+	public function set_valid_data($valid_data)
366
+	{
367
+		$this->_valid_data = $valid_data;
368
+	}
369
+
370
+
371
+	/**
372
+	 * @return array
373
+	 * @throws EE_Error
374
+	 * @throws EE_Error
375
+	 */
376
+	public function valid_data()
377
+	{
378
+		if (empty($this->_valid_data)) {
379
+			$this->_valid_data = $this->reg_form->valid_data();
380
+		}
381
+		return $this->_valid_data;
382
+	}
383
+
384
+
385
+	/**
386
+	 * @return string
387
+	 */
388
+	public function reg_form_name()
389
+	{
390
+		if (empty($this->_reg_form_name)) {
391
+			$this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form');
392
+		}
393
+		return $this->_reg_form_name;
394
+	}
395
+
396
+
397
+	/**
398
+	 * @param string $reg_form_name
399
+	 */
400
+	protected function set_reg_form_name($reg_form_name)
401
+	{
402
+		$this->_reg_form_name = $reg_form_name;
403
+	}
404
+
405
+
406
+	/**
407
+	 * reg_step_url
408
+	 *
409
+	 * @param string $action
410
+	 * @return string
411
+	 */
412
+	public function reg_step_url($action = '')
413
+	{
414
+		$query_args = ['step' => $this->slug()];
415
+		if (! empty($action)) {
416
+			$query_args['action'] = $action;
417
+		}
418
+		// final step has no display
419
+		if ($this instanceof EE_SPCO_Reg_Step_Finalize_Registration && $action === 'display_spco_reg_step') {
420
+			$query_args['action'] = 'process_reg_step';
421
+		}
422
+		if ($this->checkout->revisit) {
423
+			$query_args['revisit'] = true;
424
+		}
425
+		if ($this->checkout->reg_url_link) {
426
+			$query_args['e_reg_url_link'] = $this->checkout->reg_url_link;
427
+		}
428
+		return add_query_arg($query_args, $this->checkout->reg_page_base_url);
429
+	}
430
+
431
+
432
+	/**
433
+	 * creates the default hidden inputs section
434
+	 *
435
+	 * @return EE_Form_Section_Proper
436
+	 * @throws EE_Error
437
+	 */
438
+	public function reg_step_hidden_inputs()
439
+	{
440
+		// hidden inputs for admin registrations
441
+		if ($this->checkout->admin_request) {
442
+			return new EE_Form_Section_Proper(
443
+				[
444
+					'layout_strategy' => new EE_Div_Per_Section_Layout(),
445
+					'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
446
+					'subsections'     => [
447
+						'next_step' => new EE_Fixed_Hidden_Input(
448
+							[
449
+								'html_name' => 'next_step',
450
+								'html_id'   => 'spco-' . $this->slug() . '-next-step',
451
+								'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
452
+									? $this->checkout->next_step->slug()
453
+									: '',
454
+							]
455
+						),
456
+					],
457
+				]
458
+			);
459
+		}
460
+		// hidden inputs for frontend registrations
461
+		return new EE_Form_Section_Proper(
462
+			[
463
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
464
+				'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
465
+				'subsections'     => [
466
+					'action'         => new EE_Fixed_Hidden_Input(
467
+						[
468
+							'html_name' => 'action',
469
+							'html_id'   => 'spco-' . $this->slug() . '-action',
470
+							'default'   => apply_filters(
471
+								'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action',
472
+								empty($this->checkout->reg_url_link)
473
+									? 'process_reg_step'
474
+									: 'update_reg_step',
475
+								$this
476
+							),
477
+						]
478
+					),
479
+					'next_step'      => new EE_Fixed_Hidden_Input(
480
+						[
481
+							'html_name' => 'next_step',
482
+							'html_id'   => 'spco-' . $this->slug() . '-next-step',
483
+							'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
484
+								? $this->checkout->next_step->slug()
485
+								: '',
486
+						]
487
+					),
488
+					'e_reg_url_link' => new EE_Fixed_Hidden_Input(
489
+						[
490
+							'html_name' => 'e_reg_url_link',
491
+							'html_id'   => 'spco-reg_url_link',
492
+							'default'   => $this->checkout->reg_url_link,
493
+						]
494
+					),
495
+					'revisit'        => new EE_Fixed_Hidden_Input(
496
+						[
497
+							'html_name' => 'revisit',
498
+							'html_id'   => 'spco-revisit',
499
+							'default'   => $this->checkout->revisit,
500
+						]
501
+					),
502
+				],
503
+			]
504
+		);
505
+	}
506
+
507
+
508
+	/**
509
+	 * generate_reg_form_for_actions
510
+	 *
511
+	 * @param array $actions
512
+	 * @return void
513
+	 */
514
+	public function generate_reg_form_for_actions($actions = [])
515
+	{
516
+		$actions                           = array_merge(
517
+			[
518
+				'generate_reg_form',
519
+				'display_spco_reg_step',
520
+				'process_reg_step',
521
+				'update_reg_step',
522
+			],
523
+			$actions
524
+		);
525
+		$this->checkout->generate_reg_form = in_array($this->checkout->action, $actions, true);
526
+	}
527
+
528
+
529
+	/**
530
+	 * @return string
531
+	 * @throws EE_Error
532
+	 */
533
+	public function display_reg_form()
534
+	{
535
+		$html = '';
536
+		if ($this->reg_form instanceof EE_Form_Section_Proper) {
537
+			do_action('AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form', $this->reg_form, $this);
538
+			$html .= ! $this->checkout->admin_request ? $this->reg_form->form_open($this->reg_step_url()) : '';
539
+			if ($this->request->isAjax()) {
540
+				$this->reg_form->localize_validation_rules();
541
+				$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
542
+			}
543
+			$html .= $this->reg_form->get_html();
544
+			$html .= ! $this->checkout->admin_request ? $this->reg_step_submit_button() : '';
545
+			$html .= ! $this->checkout->admin_request ? $this->reg_form->form_close() : '';
546
+		}
547
+		return $html;
548
+	}
549
+
550
+
551
+	/**
552
+	 * div_class - returns nothing for current step, but a css class of "hidden" for others
553
+	 *
554
+	 * @return string
555
+	 * @throws EE_Error
556
+	 */
557
+	public function reg_step_submit_button()
558
+	{
559
+		if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
560
+			return '';
561
+		}
562
+		ob_start();
563
+		do_action(
564
+			'AHEE__before_spco_whats_next_buttons',
565
+			$this->slug(),
566
+			$this->checkout->next_step->slug(),
567
+			$this->checkout
568
+		);
569
+		$html = ob_get_clean();
570
+		// generate submit button
571
+		$submit_btn = new EE_Submit_Input(
572
+			[
573
+				'html_name'             => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
574
+				'html_id'               => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
575
+				'html_class'            => 'spco-next-step-btn',
576
+				'other_html_attributes' => ' rel="' . $this->slug() . '"',
577
+				'default'               => $this->submit_button_text(),
578
+			]
579
+		);
580
+		$submit_btn->set_button_css_attributes(true, 'large');
581
+		$submit_btn_html = $submit_btn->get_html_for_input();
582
+		$html            .= EEH_HTML::div(
583
+			apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $submit_btn_html, $this),
584
+			'spco-' . $this->slug() . '-whats-next-buttons-dv',
585
+			'spco-whats-next-buttons'
586
+		);
587
+		return $html;
588
+	}
589
+
590
+
591
+	/**
592
+	 * div_class - returns nothing for current step, but a css class of "hidden" for others
593
+	 *
594
+	 * @return string
595
+	 */
596
+	public function div_class()
597
+	{
598
+		return $this->is_current_step() ? '' : ' hidden';
599
+	}
600
+
601
+
602
+	/**
603
+	 * div_class - returns  a css class of "hidden" for current step, but nothing for others
604
+	 *
605
+	 * @return string
606
+	 */
607
+	public function edit_lnk_url()
608
+	{
609
+		return add_query_arg(['step' => $this->slug()], $this->checkout->reg_page_base_url);
610
+	}
611
+
612
+
613
+	/**
614
+	 * div_class - returns  a css class of "hidden" for current step, but nothing for others
615
+	 *
616
+	 * @return string
617
+	 */
618
+	public function edit_link_class()
619
+	{
620
+		return $this->is_current_step() ? ' hidden' : '';
621
+	}
622
+
623
+
624
+	/**
625
+	 * update_checkout with changes that have been made to the cart
626
+	 *
627
+	 * @return void
628
+	 * @throws EE_Error
629
+	 * @throws ReflectionException
630
+	 */
631
+	public function update_checkout()
632
+	{
633
+		// grab the cart grand total and reset TXN total
634
+		$this->checkout->transaction->set_total($this->checkout->cart->get_cart_grand_total());
635
+		$this->checkout->stash_transaction_and_checkout();
636
+	}
637
+
638
+
639
+	/**
640
+	 *    __sleep
641
+	 * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
642
+	 * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
643
+	 * reg form, because if needed, it will be regenerated anyways
644
+	 *
645
+	 * @return array
646
+	 */
647
+	public function __sleep()
648
+	{
649
+		// remove the reg form and the checkout
650
+		return array_diff(array_keys(get_object_vars($this)), ['reg_form', 'checkout']);
651
+	}
652
+
653
+
654
+	/**
655
+	 * @param RequestInterface $request
656
+	 */
657
+	public function setRequest(RequestInterface $request)
658
+	{
659
+		$this->request = $request;
660
+	}
661 661
 }
Please login to merge, or discard this patch.
core/services/container/RegistryContainer.php 2 patches
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -17,165 +17,165 @@
 block discarded – undo
17 17
 class RegistryContainer implements ArrayAccess, CountableTraversableAggregate
18 18
 {
19 19
 
20
-    /**
21
-     * @var array $container
22
-     */
23
-    private $container = [];
24
-
25
-    /**
26
-     * RegistryContainer constructor.
27
-     * Container data can be seeded by passing parameters to constructor.
28
-     * Each parameter will become its own element in the container
29
-     */
30
-    public function __construct()
31
-    {
32
-    }
33
-
34
-
35
-    /**
36
-     * @param mixed $offset
37
-     * @param mixed $value
38
-     */
39
-    public function offsetSet($offset, $value)
40
-    {
41
-        $this->container[ $offset ] = $value;
42
-    }
43
-
44
-
45
-    /**
46
-     * @param mixed $offset
47
-     * @return bool
48
-     */
49
-    public function offsetExists($offset)
50
-    {
51
-        return isset($this->container[ $offset ]);
52
-    }
53
-
54
-
55
-    /**
56
-     * @param mixed $offset
57
-     */
58
-    public function offsetUnset($offset)
59
-    {
60
-        unset($this->container[ $offset ]);
61
-    }
62
-
63
-
64
-    /**
65
-     * @param mixed $offset
66
-     * @return mixed|null
67
-     */
68
-    public function offsetGet($offset)
69
-    {
70
-        return $this->offsetExists($offset) ? $this->container[ $offset ] : null;
71
-    }
72
-
73
-
74
-    /**
75
-     * @return int
76
-     */
77
-    public function count()
78
-    {
79
-        return count($this->container);
80
-    }
81
-
82
-
83
-    /**
84
-     * @return ArrayIterator
85
-     */
86
-    public function getIterator()
87
-    {
88
-        return new ArrayIterator($this->container);
89
-    }
90
-
91
-
92
-    /**
93
-     * @param $offset
94
-     * @param $value
95
-     */
96
-    public function __set($offset, $value)
97
-    {
98
-        $this->offsetSet($offset, $value);
99
-    }
100
-
101
-
102
-    /**
103
-     * @param $offset
104
-     * @return mixed
105
-     * @throws OutOfBoundsException
106
-     */
107
-    public function __get($offset)
108
-    {
109
-        if (! array_key_exists($offset, $this->container)) {
110
-            $trace = debug_backtrace();
111
-            throw new OutOfBoundsException(
112
-                sprintf(
113
-                    esc_html__('Invalid offset: %1$s %2$sCalled from %3$s on line %4$d', 'event_espresso'),
114
-                    $offset,
115
-                    '<br  />',
116
-                    $trace[0]['file'],
117
-                    $trace[0]['line']
118
-                )
119
-            );
120
-        }
121
-        return $this->offsetGet($offset);
122
-    }
123
-
124
-
125
-    /**
126
-     * @param $offset
127
-     * @return bool
128
-     */
129
-    public function __isset($offset)
130
-    {
131
-        return $this->offsetExists($offset);
132
-    }
133
-
134
-
135
-    /**
136
-     * @param $offset
137
-     */
138
-    public function __unset($offset)
139
-    {
140
-        $this->offsetUnset($offset);
141
-    }
142
-
143
-
144
-    /**
145
-     * @param $offset
146
-     * @param $value
147
-     */
148
-    public function add($offset, $value)
149
-    {
150
-        $this->offsetSet($offset, $value);
151
-    }
152
-
153
-
154
-    /**
155
-     * @param $offset
156
-     */
157
-    public function remove($offset)
158
-    {
159
-        $this->offsetUnset($offset);
160
-    }
161
-
162
-
163
-    /**
164
-     * @param $offset
165
-     * @return bool
166
-     */
167
-    public function has($offset)
168
-    {
169
-        return $this->offsetExists($offset);
170
-    }
171
-
172
-
173
-    /**
174
-     * @param $offset
175
-     * @return mixed|null
176
-     */
177
-    public function get($offset)
178
-    {
179
-        return $this->offsetGet($offset);
180
-    }
20
+	/**
21
+	 * @var array $container
22
+	 */
23
+	private $container = [];
24
+
25
+	/**
26
+	 * RegistryContainer constructor.
27
+	 * Container data can be seeded by passing parameters to constructor.
28
+	 * Each parameter will become its own element in the container
29
+	 */
30
+	public function __construct()
31
+	{
32
+	}
33
+
34
+
35
+	/**
36
+	 * @param mixed $offset
37
+	 * @param mixed $value
38
+	 */
39
+	public function offsetSet($offset, $value)
40
+	{
41
+		$this->container[ $offset ] = $value;
42
+	}
43
+
44
+
45
+	/**
46
+	 * @param mixed $offset
47
+	 * @return bool
48
+	 */
49
+	public function offsetExists($offset)
50
+	{
51
+		return isset($this->container[ $offset ]);
52
+	}
53
+
54
+
55
+	/**
56
+	 * @param mixed $offset
57
+	 */
58
+	public function offsetUnset($offset)
59
+	{
60
+		unset($this->container[ $offset ]);
61
+	}
62
+
63
+
64
+	/**
65
+	 * @param mixed $offset
66
+	 * @return mixed|null
67
+	 */
68
+	public function offsetGet($offset)
69
+	{
70
+		return $this->offsetExists($offset) ? $this->container[ $offset ] : null;
71
+	}
72
+
73
+
74
+	/**
75
+	 * @return int
76
+	 */
77
+	public function count()
78
+	{
79
+		return count($this->container);
80
+	}
81
+
82
+
83
+	/**
84
+	 * @return ArrayIterator
85
+	 */
86
+	public function getIterator()
87
+	{
88
+		return new ArrayIterator($this->container);
89
+	}
90
+
91
+
92
+	/**
93
+	 * @param $offset
94
+	 * @param $value
95
+	 */
96
+	public function __set($offset, $value)
97
+	{
98
+		$this->offsetSet($offset, $value);
99
+	}
100
+
101
+
102
+	/**
103
+	 * @param $offset
104
+	 * @return mixed
105
+	 * @throws OutOfBoundsException
106
+	 */
107
+	public function __get($offset)
108
+	{
109
+		if (! array_key_exists($offset, $this->container)) {
110
+			$trace = debug_backtrace();
111
+			throw new OutOfBoundsException(
112
+				sprintf(
113
+					esc_html__('Invalid offset: %1$s %2$sCalled from %3$s on line %4$d', 'event_espresso'),
114
+					$offset,
115
+					'<br  />',
116
+					$trace[0]['file'],
117
+					$trace[0]['line']
118
+				)
119
+			);
120
+		}
121
+		return $this->offsetGet($offset);
122
+	}
123
+
124
+
125
+	/**
126
+	 * @param $offset
127
+	 * @return bool
128
+	 */
129
+	public function __isset($offset)
130
+	{
131
+		return $this->offsetExists($offset);
132
+	}
133
+
134
+
135
+	/**
136
+	 * @param $offset
137
+	 */
138
+	public function __unset($offset)
139
+	{
140
+		$this->offsetUnset($offset);
141
+	}
142
+
143
+
144
+	/**
145
+	 * @param $offset
146
+	 * @param $value
147
+	 */
148
+	public function add($offset, $value)
149
+	{
150
+		$this->offsetSet($offset, $value);
151
+	}
152
+
153
+
154
+	/**
155
+	 * @param $offset
156
+	 */
157
+	public function remove($offset)
158
+	{
159
+		$this->offsetUnset($offset);
160
+	}
161
+
162
+
163
+	/**
164
+	 * @param $offset
165
+	 * @return bool
166
+	 */
167
+	public function has($offset)
168
+	{
169
+		return $this->offsetExists($offset);
170
+	}
171
+
172
+
173
+	/**
174
+	 * @param $offset
175
+	 * @return mixed|null
176
+	 */
177
+	public function get($offset)
178
+	{
179
+		return $this->offsetGet($offset);
180
+	}
181 181
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function offsetSet($offset, $value)
40 40
     {
41
-        $this->container[ $offset ] = $value;
41
+        $this->container[$offset] = $value;
42 42
     }
43 43
 
44 44
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function offsetExists($offset)
50 50
     {
51
-        return isset($this->container[ $offset ]);
51
+        return isset($this->container[$offset]);
52 52
     }
53 53
 
54 54
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function offsetUnset($offset)
59 59
     {
60
-        unset($this->container[ $offset ]);
60
+        unset($this->container[$offset]);
61 61
     }
62 62
 
63 63
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function offsetGet($offset)
69 69
     {
70
-        return $this->offsetExists($offset) ? $this->container[ $offset ] : null;
70
+        return $this->offsetExists($offset) ? $this->container[$offset] : null;
71 71
     }
72 72
 
73 73
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function __get($offset)
108 108
     {
109
-        if (! array_key_exists($offset, $this->container)) {
109
+        if ( ! array_key_exists($offset, $this->container)) {
110 110
             $trace = debug_backtrace();
111 111
             throw new OutOfBoundsException(
112 112
                 sprintf(
Please login to merge, or discard this patch.
core/services/loaders/Loader.php 1 patch
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -15,127 +15,127 @@
 block discarded – undo
15 15
 class Loader implements LoaderInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @var LoaderDecoratorInterface $new_loader
20
-     */
21
-    private $new_loader;
22
-
23
-    /**
24
-     * @var LoaderDecoratorInterface $shared_loader
25
-     */
26
-    private $shared_loader;
27
-
28
-    /**
29
-     * @var ClassInterfaceCache $class_cache
30
-     */
31
-    private $class_cache;
32
-
33
-    /**
34
-     * Loader constructor.
35
-     *
36
-     * @param LoaderDecoratorInterface        $new_loader
37
-     * @param CachingLoaderDecoratorInterface $shared_loader
38
-     * @param ClassInterfaceCache             $class_cache
39
-     */
40
-    public function __construct(
41
-        LoaderDecoratorInterface $new_loader,
42
-        CachingLoaderDecoratorInterface $shared_loader,
43
-        ClassInterfaceCache $class_cache
44
-    ) {
45
-        $this->new_loader    = $new_loader;
46
-        $this->shared_loader = $shared_loader;
47
-        $this->class_cache   = $class_cache;
48
-    }
49
-
50
-
51
-    /**
52
-     * @return LoaderDecoratorInterface
53
-     */
54
-    public function getNewLoader()
55
-    {
56
-        return $this->new_loader;
57
-    }
58
-
59
-
60
-    /**
61
-     * @return CachingLoaderDecoratorInterface
62
-     */
63
-    public function getSharedLoader()
64
-    {
65
-        return $this->shared_loader;
66
-    }
67
-
68
-
69
-    /**
70
-     * @param FullyQualifiedName|string $fqcn
71
-     * @param array                     $arguments
72
-     * @param bool                      $shared
73
-     * @return mixed
74
-     */
75
-    public function load($fqcn, array $arguments = array(), $shared = true)
76
-    {
77
-        $fqcn = $this->class_cache->getFqn($fqcn);
78
-        if ($this->class_cache->hasInterface($fqcn, 'EventEspresso\core\interfaces\ReservedInstanceInterface')) {
79
-            $shared = true;
80
-        }
81
-        return $shared
82
-            ? $this->getSharedLoader()->load($fqcn, $arguments, $shared)
83
-            : $this->getNewLoader()->load($fqcn, $arguments, $shared);
84
-    }
85
-
86
-
87
-    /**
88
-     * @param FullyQualifiedName|string $fqcn
89
-     * @param array                     $arguments
90
-     * @return mixed
91
-     */
92
-    public function getNew($fqcn, array $arguments = array())
93
-    {
94
-        return $this->load($fqcn, $arguments, false);
95
-    }
96
-
97
-
98
-    /**
99
-     * @param FullyQualifiedName|string $fqcn
100
-     * @param array                     $arguments
101
-     * @return mixed
102
-     */
103
-    public function getShared($fqcn, array $arguments = array())
104
-    {
105
-        return $this->load($fqcn, $arguments);
106
-    }
107
-
108
-
109
-    /**
110
-     * @param FullyQualifiedName|string $fqcn
111
-     * @param mixed                     $object
112
-     * @return bool
113
-     * @throws InvalidArgumentException
114
-     */
115
-    public function share($fqcn, $object)
116
-    {
117
-        $fqcn = $this->class_cache->getFqn($fqcn);
118
-        return $this->getSharedLoader()->share($fqcn, $object);
119
-    }
120
-
121
-
122
-    /**
123
-     * @param FullyQualifiedName|string $fqcn
124
-     * @return bool
125
-     * @throws InvalidArgumentException
126
-     */
127
-    public function remove($fqcn, array $arguments = [])
128
-    {
129
-        $fqcn = $this->class_cache->getFqn($fqcn);
130
-        return $this->getSharedLoader()->remove($fqcn, $arguments);
131
-    }
132
-
133
-
134
-    /**
135
-     * calls reset() on loaders if that method exists
136
-     */
137
-    public function reset()
138
-    {
139
-        $this->shared_loader->reset();
140
-    }
18
+	/**
19
+	 * @var LoaderDecoratorInterface $new_loader
20
+	 */
21
+	private $new_loader;
22
+
23
+	/**
24
+	 * @var LoaderDecoratorInterface $shared_loader
25
+	 */
26
+	private $shared_loader;
27
+
28
+	/**
29
+	 * @var ClassInterfaceCache $class_cache
30
+	 */
31
+	private $class_cache;
32
+
33
+	/**
34
+	 * Loader constructor.
35
+	 *
36
+	 * @param LoaderDecoratorInterface        $new_loader
37
+	 * @param CachingLoaderDecoratorInterface $shared_loader
38
+	 * @param ClassInterfaceCache             $class_cache
39
+	 */
40
+	public function __construct(
41
+		LoaderDecoratorInterface $new_loader,
42
+		CachingLoaderDecoratorInterface $shared_loader,
43
+		ClassInterfaceCache $class_cache
44
+	) {
45
+		$this->new_loader    = $new_loader;
46
+		$this->shared_loader = $shared_loader;
47
+		$this->class_cache   = $class_cache;
48
+	}
49
+
50
+
51
+	/**
52
+	 * @return LoaderDecoratorInterface
53
+	 */
54
+	public function getNewLoader()
55
+	{
56
+		return $this->new_loader;
57
+	}
58
+
59
+
60
+	/**
61
+	 * @return CachingLoaderDecoratorInterface
62
+	 */
63
+	public function getSharedLoader()
64
+	{
65
+		return $this->shared_loader;
66
+	}
67
+
68
+
69
+	/**
70
+	 * @param FullyQualifiedName|string $fqcn
71
+	 * @param array                     $arguments
72
+	 * @param bool                      $shared
73
+	 * @return mixed
74
+	 */
75
+	public function load($fqcn, array $arguments = array(), $shared = true)
76
+	{
77
+		$fqcn = $this->class_cache->getFqn($fqcn);
78
+		if ($this->class_cache->hasInterface($fqcn, 'EventEspresso\core\interfaces\ReservedInstanceInterface')) {
79
+			$shared = true;
80
+		}
81
+		return $shared
82
+			? $this->getSharedLoader()->load($fqcn, $arguments, $shared)
83
+			: $this->getNewLoader()->load($fqcn, $arguments, $shared);
84
+	}
85
+
86
+
87
+	/**
88
+	 * @param FullyQualifiedName|string $fqcn
89
+	 * @param array                     $arguments
90
+	 * @return mixed
91
+	 */
92
+	public function getNew($fqcn, array $arguments = array())
93
+	{
94
+		return $this->load($fqcn, $arguments, false);
95
+	}
96
+
97
+
98
+	/**
99
+	 * @param FullyQualifiedName|string $fqcn
100
+	 * @param array                     $arguments
101
+	 * @return mixed
102
+	 */
103
+	public function getShared($fqcn, array $arguments = array())
104
+	{
105
+		return $this->load($fqcn, $arguments);
106
+	}
107
+
108
+
109
+	/**
110
+	 * @param FullyQualifiedName|string $fqcn
111
+	 * @param mixed                     $object
112
+	 * @return bool
113
+	 * @throws InvalidArgumentException
114
+	 */
115
+	public function share($fqcn, $object)
116
+	{
117
+		$fqcn = $this->class_cache->getFqn($fqcn);
118
+		return $this->getSharedLoader()->share($fqcn, $object);
119
+	}
120
+
121
+
122
+	/**
123
+	 * @param FullyQualifiedName|string $fqcn
124
+	 * @return bool
125
+	 * @throws InvalidArgumentException
126
+	 */
127
+	public function remove($fqcn, array $arguments = [])
128
+	{
129
+		$fqcn = $this->class_cache->getFqn($fqcn);
130
+		return $this->getSharedLoader()->remove($fqcn, $arguments);
131
+	}
132
+
133
+
134
+	/**
135
+	 * calls reset() on loaders if that method exists
136
+	 */
137
+	public function reset()
138
+	{
139
+		$this->shared_loader->reset();
140
+	}
141 141
 }
Please login to merge, or discard this patch.
core/services/loaders/CachingLoaderDecoratorInterface.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,20 +11,20 @@
 block discarded – undo
11 11
 interface CachingLoaderDecoratorInterface extends LoaderDecoratorInterface
12 12
 {
13 13
 
14
-    /**
15
-     * @param string $fqcn
16
-     * @param mixed  $object
17
-     * @return bool
18
-     * @throws InvalidArgumentException
19
-     */
20
-    public function share($fqcn, $object);
14
+	/**
15
+	 * @param string $fqcn
16
+	 * @param mixed  $object
17
+	 * @return bool
18
+	 * @throws InvalidArgumentException
19
+	 */
20
+	public function share($fqcn, $object);
21 21
 
22 22
 
23
-    /**
24
-     * @param string $fqcn
25
-     * @param array  $arguments
26
-     * @return bool
27
-     * @throws InvalidArgumentException
28
-     */
29
-    public function remove($fqcn, array $arguments = []);
23
+	/**
24
+	 * @param string $fqcn
25
+	 * @param array  $arguments
26
+	 * @return bool
27
+	 * @throws InvalidArgumentException
28
+	 */
29
+	public function remove($fqcn, array $arguments = []);
30 30
 }
Please login to merge, or discard this patch.
core/services/loaders/LoaderInterface.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -8,57 +8,57 @@
 block discarded – undo
8 8
 interface LoaderInterface
9 9
 {
10 10
 
11
-    /**
12
-     * Can be for instantiating a new instance of a class,
13
-     * or for getting a shared instance of a class (default)
14
-     *
15
-     * @param FullyQualifiedName|string $fqcn
16
-     * @param array                     $arguments
17
-     * @param bool                      $shared
18
-     * @return mixed
19
-     */
20
-    public function load($fqcn, array $arguments = array(), $shared = true);
11
+	/**
12
+	 * Can be for instantiating a new instance of a class,
13
+	 * or for getting a shared instance of a class (default)
14
+	 *
15
+	 * @param FullyQualifiedName|string $fqcn
16
+	 * @param array                     $arguments
17
+	 * @param bool                      $shared
18
+	 * @return mixed
19
+	 */
20
+	public function load($fqcn, array $arguments = array(), $shared = true);
21 21
 
22 22
 
23
-    /**
24
-     * Used for instantiating a new instance of a class
25
-     *
26
-     * @param FullyQualifiedName|string $fqcn
27
-     * @param array                     $arguments
28
-     * @return mixed
29
-     */
30
-    public function getNew($fqcn, array $arguments = array());
23
+	/**
24
+	 * Used for instantiating a new instance of a class
25
+	 *
26
+	 * @param FullyQualifiedName|string $fqcn
27
+	 * @param array                     $arguments
28
+	 * @return mixed
29
+	 */
30
+	public function getNew($fqcn, array $arguments = array());
31 31
 
32 32
 
33
-    /**
34
-     * Used for getting a shared instance of a class
35
-     *
36
-     * @param FullyQualifiedName|string $fqcn
37
-     * @param array                     $arguments
38
-     * @return mixed
39
-     */
40
-    public function getShared($fqcn, array $arguments = array());
33
+	/**
34
+	 * Used for getting a shared instance of a class
35
+	 *
36
+	 * @param FullyQualifiedName|string $fqcn
37
+	 * @param array                     $arguments
38
+	 * @return mixed
39
+	 */
40
+	public function getShared($fqcn, array $arguments = array());
41 41
 
42 42
 
43
-    /**
44
-     * @param FullyQualifiedName|string $fqcn
45
-     * @param mixed                     $object
46
-     * @return bool
47
-     * @throws InvalidArgumentException
48
-     */
49
-    public function share($fqcn, $object);
43
+	/**
44
+	 * @param FullyQualifiedName|string $fqcn
45
+	 * @param mixed                     $object
46
+	 * @return bool
47
+	 * @throws InvalidArgumentException
48
+	 */
49
+	public function share($fqcn, $object);
50 50
 
51 51
 
52
-    /**
53
-     * @param FullyQualifiedName|string $fqcn
54
-     * @return bool
55
-     * @throws InvalidArgumentException
56
-     */
57
-    public function remove($fqcn);
52
+	/**
53
+	 * @param FullyQualifiedName|string $fqcn
54
+	 * @return bool
55
+	 * @throws InvalidArgumentException
56
+	 */
57
+	public function remove($fqcn);
58 58
 
59 59
 
60
-    /**
61
-     * calls reset() on loader if method exists
62
-     */
63
-    public function reset();
60
+	/**
61
+	 * calls reset() on loader if method exists
62
+	 */
63
+	public function reset();
64 64
 }
Please login to merge, or discard this patch.
core/services/request/files/FilesDataHandler.php 2 patches
Indentation   +251 added lines, -251 removed lines patch added patch discarded remove patch
@@ -40,279 +40,279 @@
 block discarded – undo
40 40
  */
41 41
 class FilesDataHandler
42 42
 {
43
-    /**
44
-     * @var Request
45
-     */
46
-    protected $request;
43
+	/**
44
+	 * @var Request
45
+	 */
46
+	protected $request;
47 47
 
48
-    /**
49
-     * @var CollectionInterface | FileSubmissionInterface[]
50
-     */
51
-    protected $file_objects;
48
+	/**
49
+	 * @var CollectionInterface | FileSubmissionInterface[]
50
+	 */
51
+	protected $file_objects;
52 52
 
53
-    /**
54
-     * @var bool
55
-     */
56
-    protected $initialized = false;
53
+	/**
54
+	 * @var bool
55
+	 */
56
+	protected $initialized = false;
57 57
 
58 58
 
59
-    /**
60
-     * FilesDataHandler constructor.
61
-     *
62
-     * @param Request $request
63
-     */
64
-    public function __construct(Request $request)
65
-    {
66
-        $this->request = $request;
67
-    }
59
+	/**
60
+	 * FilesDataHandler constructor.
61
+	 *
62
+	 * @param Request $request
63
+	 */
64
+	public function __construct(Request $request)
65
+	{
66
+		$this->request = $request;
67
+	}
68 68
 
69 69
 
70
-    /**
71
-     * @return CollectionInterface | FileSubmissionInterface[]
72
-     * @throws UnexpectedValueException
73
-     * @throws InvalidArgumentException
74
-     * @since 4.9.80.p
75
-     */
76
-    protected function getFileObjects()
77
-    {
78
-        $this->initialize();
79
-        return $this->file_objects;
80
-    }
70
+	/**
71
+	 * @return CollectionInterface | FileSubmissionInterface[]
72
+	 * @throws UnexpectedValueException
73
+	 * @throws InvalidArgumentException
74
+	 * @since 4.9.80.p
75
+	 */
76
+	protected function getFileObjects()
77
+	{
78
+		$this->initialize();
79
+		return $this->file_objects;
80
+	}
81 81
 
82 82
 
83
-    /**
84
-     * Sets up the file objects from the request's $_FILES data.
85
-     *
86
-     * @throws UnexpectedValueException
87
-     * @throws InvalidArgumentException
88
-     * @throws InvalidInterfaceException
89
-     * @since 4.9.80.p
90
-     */
91
-    protected function initialize()
92
-    {
93
-        if ($this->initialized) {
94
-            return;
95
-        }
96
-        $this->file_objects = new Collection(
97
-        // collection interface
98
-            'EventEspresso\core\services\request\files\FileSubmissionInterface',
99
-            // collection name
100
-            'submitted_files'
101
-        );
102
-        $files_raw_data     = $this->request->filesParams();
103
-        if (empty($files_raw_data)) {
104
-            return;
105
-        }
106
-        if ($this->isStrangeFilesArray($files_raw_data)) {
107
-            $data = $this->fixFilesDataArray($files_raw_data);
108
-        } else {
109
-            $data = $files_raw_data;
110
-        }
111
-        $this->createFileObjects($data);
112
-        $this->initialized = true;
113
-    }
83
+	/**
84
+	 * Sets up the file objects from the request's $_FILES data.
85
+	 *
86
+	 * @throws UnexpectedValueException
87
+	 * @throws InvalidArgumentException
88
+	 * @throws InvalidInterfaceException
89
+	 * @since 4.9.80.p
90
+	 */
91
+	protected function initialize()
92
+	{
93
+		if ($this->initialized) {
94
+			return;
95
+		}
96
+		$this->file_objects = new Collection(
97
+		// collection interface
98
+			'EventEspresso\core\services\request\files\FileSubmissionInterface',
99
+			// collection name
100
+			'submitted_files'
101
+		);
102
+		$files_raw_data     = $this->request->filesParams();
103
+		if (empty($files_raw_data)) {
104
+			return;
105
+		}
106
+		if ($this->isStrangeFilesArray($files_raw_data)) {
107
+			$data = $this->fixFilesDataArray($files_raw_data);
108
+		} else {
109
+			$data = $files_raw_data;
110
+		}
111
+		$this->createFileObjects($data);
112
+		$this->initialized = true;
113
+	}
114 114
 
115 115
 
116
-    /**
117
-     * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not.
118
-     *
119
-     * @param $files_data
120
-     * @return bool
121
-     * @throws UnexpectedValueException
122
-     * @since 4.9.80.p
123
-     */
124
-    protected function isStrangeFilesArray($files_data)
125
-    {
126
-        if (! is_array($files_data)) {
127
-            throw new UnexpectedValueException(
128
-                sprintf(
129
-                    esc_html__(
130
-                        'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
131
-                        'event_espresso'
132
-                    ),
133
-                    (string) $files_data
134
-                )
135
-            );
136
-        }
137
-        $first_value = reset($files_data);
138
-        if (! is_array($first_value)) {
139
-            throw new UnexpectedValueException(
140
-                sprintf(
141
-                    esc_html__(
142
-                        'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
143
-                        'event_espresso'
144
-                    ),
145
-                    (string) $first_value
146
-                )
147
-            );
148
-        }
149
-        $first_sub_array_item = reset($first_value);
150
-        if (is_array($first_sub_array_item)) {
151
-            // not just a 2d array
152
-            return true;
153
-        }
154
-        // yep, just 2d array
155
-        return false;
156
-    }
116
+	/**
117
+	 * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not.
118
+	 *
119
+	 * @param $files_data
120
+	 * @return bool
121
+	 * @throws UnexpectedValueException
122
+	 * @since 4.9.80.p
123
+	 */
124
+	protected function isStrangeFilesArray($files_data)
125
+	{
126
+		if (! is_array($files_data)) {
127
+			throw new UnexpectedValueException(
128
+				sprintf(
129
+					esc_html__(
130
+						'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
131
+						'event_espresso'
132
+					),
133
+					(string) $files_data
134
+				)
135
+			);
136
+		}
137
+		$first_value = reset($files_data);
138
+		if (! is_array($first_value)) {
139
+			throw new UnexpectedValueException(
140
+				sprintf(
141
+					esc_html__(
142
+						'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
143
+						'event_espresso'
144
+					),
145
+					(string) $first_value
146
+				)
147
+			);
148
+		}
149
+		$first_sub_array_item = reset($first_value);
150
+		if (is_array($first_sub_array_item)) {
151
+			// not just a 2d array
152
+			return true;
153
+		}
154
+		// yep, just 2d array
155
+		return false;
156
+	}
157 157
 
158 158
 
159
-    /**
160
-     * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file"
161
-     * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with
162
-     * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]",
163
-     * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird.
164
-     *
165
-     * @param $files_data
166
-     * @return array
167
-     * @since 4.9.80.p
168
-     */
169
-    protected function fixFilesDataArray($files_data)
170
-    {
171
-        $sane_files_array = [];
172
-        foreach ($files_data as $top_level_name => $top_level_children) {
173
-            $sub_array                           = [];
174
-            $sane_files_array[ $top_level_name ] = [];
175
-            foreach ($top_level_children as $file_data_part => $second_level_children) {
176
-                foreach ($second_level_children as $next_level_name => $sub_values) {
177
-                    $sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part);
178
-                }
179
-                $sane_files_array[ $top_level_name ] = array_replace_recursive(
180
-                    $sub_array,
181
-                    $sane_files_array[ $top_level_name ]
182
-                );
183
-            }
184
-        }
185
-        return $sane_files_array;
186
-    }
159
+	/**
160
+	 * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file"
161
+	 * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with
162
+	 * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]",
163
+	 * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird.
164
+	 *
165
+	 * @param $files_data
166
+	 * @return array
167
+	 * @since 4.9.80.p
168
+	 */
169
+	protected function fixFilesDataArray($files_data)
170
+	{
171
+		$sane_files_array = [];
172
+		foreach ($files_data as $top_level_name => $top_level_children) {
173
+			$sub_array                           = [];
174
+			$sane_files_array[ $top_level_name ] = [];
175
+			foreach ($top_level_children as $file_data_part => $second_level_children) {
176
+				foreach ($second_level_children as $next_level_name => $sub_values) {
177
+					$sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part);
178
+				}
179
+				$sane_files_array[ $top_level_name ] = array_replace_recursive(
180
+					$sub_array,
181
+					$sane_files_array[ $top_level_name ]
182
+				);
183
+			}
184
+		}
185
+		return $sane_files_array;
186
+	}
187 187
 
188 188
 
189
-    /**
190
-     * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it.
191
-     *
192
-     * @param $data array|string
193
-     * @param $type 'name', 'tmp_name', 'size', or 'error'
194
-     * @return array
195
-     * @since 4.9.80.p
196
-     */
197
-    protected function organizeFilesData($data, $type)
198
-    {
199
-        if (! is_array($data)) {
200
-            return [
201
-                $type => $data,
202
-            ];
203
-        }
204
-        $organized_data = [];
205
-        foreach ($data as $input_name_part => $sub_inputs_or_value) {
206
-            if (is_array($sub_inputs_or_value)) {
207
-                $organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type);
208
-            } else {
209
-                $organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value;
210
-            }
211
-        }
212
-        return $organized_data;
213
-    }
189
+	/**
190
+	 * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it.
191
+	 *
192
+	 * @param $data array|string
193
+	 * @param $type 'name', 'tmp_name', 'size', or 'error'
194
+	 * @return array
195
+	 * @since 4.9.80.p
196
+	 */
197
+	protected function organizeFilesData($data, $type)
198
+	{
199
+		if (! is_array($data)) {
200
+			return [
201
+				$type => $data,
202
+			];
203
+		}
204
+		$organized_data = [];
205
+		foreach ($data as $input_name_part => $sub_inputs_or_value) {
206
+			if (is_array($sub_inputs_or_value)) {
207
+				$organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type);
208
+			} else {
209
+				$organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value;
210
+			}
211
+		}
212
+		return $organized_data;
213
+	}
214 214
 
215 215
 
216
-    /**
217
-     * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input
218
-     * to be in post data, with all the file's data located side-by-side in an array) and creates a
219
-     * multi-dimensional array of FileSubmissionInterface objects. Stores it in `$this->file_objects`.
220
-     *
221
-     * @param array $organized_files   $_FILES but organized like $_POST
222
-     * @param array $name_parts_so_far for multidimensional HTML form names,
223
-     * @throws UnexpectedValueException
224
-     * @throws InvalidArgumentException
225
-     * @since 4.9.80.p
226
-     */
227
-    protected function createFileObjects($organized_files, $name_parts_so_far = [])
228
-    {
229
-        if (! is_array($organized_files)) {
230
-            throw new UnexpectedValueException(
231
-                sprintf(
232
-                    esc_html__(
233
-                        'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.',
234
-                        'event_espresso'
235
-                    ),
236
-                    (string) $organized_files
237
-                )
238
-            );
239
-        }
240
-        foreach ($organized_files as $key => $value) {
241
-            $this_input_name_parts = $name_parts_so_far;
242
-            array_push(
243
-                $this_input_name_parts,
244
-                $key
245
-            );
246
-            if (isset($value['name'], $value['tmp_name'], $value['size'])) {
247
-                $html_name = $this->inputNameFromParts($this_input_name_parts);
248
-                $this->file_objects->add(
249
-                    new FileSubmission(
250
-                        $value['name'],
251
-                        $value['tmp_name'],
252
-                        $value['size'],
253
-                        $value['error']
254
-                    ),
255
-                    $html_name
256
-                );
257
-            } else {
258
-                $this->createFileObjects($value, $this_input_name_parts);
259
-            }
260
-        }
261
-    }
216
+	/**
217
+	 * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input
218
+	 * to be in post data, with all the file's data located side-by-side in an array) and creates a
219
+	 * multi-dimensional array of FileSubmissionInterface objects. Stores it in `$this->file_objects`.
220
+	 *
221
+	 * @param array $organized_files   $_FILES but organized like $_POST
222
+	 * @param array $name_parts_so_far for multidimensional HTML form names,
223
+	 * @throws UnexpectedValueException
224
+	 * @throws InvalidArgumentException
225
+	 * @since 4.9.80.p
226
+	 */
227
+	protected function createFileObjects($organized_files, $name_parts_so_far = [])
228
+	{
229
+		if (! is_array($organized_files)) {
230
+			throw new UnexpectedValueException(
231
+				sprintf(
232
+					esc_html__(
233
+						'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.',
234
+						'event_espresso'
235
+					),
236
+					(string) $organized_files
237
+				)
238
+			);
239
+		}
240
+		foreach ($organized_files as $key => $value) {
241
+			$this_input_name_parts = $name_parts_so_far;
242
+			array_push(
243
+				$this_input_name_parts,
244
+				$key
245
+			);
246
+			if (isset($value['name'], $value['tmp_name'], $value['size'])) {
247
+				$html_name = $this->inputNameFromParts($this_input_name_parts);
248
+				$this->file_objects->add(
249
+					new FileSubmission(
250
+						$value['name'],
251
+						$value['tmp_name'],
252
+						$value['size'],
253
+						$value['error']
254
+					),
255
+					$html_name
256
+				);
257
+			} else {
258
+				$this->createFileObjects($value, $this_input_name_parts);
259
+			}
260
+		}
261
+	}
262 262
 
263 263
 
264
-    /**
265
-     * Takes the input name parts, like `['my', 'great', 'file', 'input1']`
266
-     * and returns the HTML name for it, "my[great][file][input1]"
267
-     *
268
-     * @throws UnexpectedValueException
269
-     * @since 4.9.80.p
270
-     */
271
-    protected function inputNameFromParts($parts)
272
-    {
273
-        if (! is_array($parts)) {
274
-            throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
275
-        }
276
-        $generated_string = '';
277
-        foreach ($parts as $part) {
278
-            $part = (string) $part;
279
-            // wrap all but the first part in []
280
-            $generated_string .= $generated_string === '' ? $part : '[' . $part . ']';
281
-        }
282
-        return $generated_string;
283
-    }
264
+	/**
265
+	 * Takes the input name parts, like `['my', 'great', 'file', 'input1']`
266
+	 * and returns the HTML name for it, "my[great][file][input1]"
267
+	 *
268
+	 * @throws UnexpectedValueException
269
+	 * @since 4.9.80.p
270
+	 */
271
+	protected function inputNameFromParts($parts)
272
+	{
273
+		if (! is_array($parts)) {
274
+			throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
275
+		}
276
+		$generated_string = '';
277
+		foreach ($parts as $part) {
278
+			$part = (string) $part;
279
+			// wrap all but the first part in []
280
+			$generated_string .= $generated_string === '' ? $part : '[' . $part . ']';
281
+		}
282
+		return $generated_string;
283
+	}
284 284
 
285 285
 
286
-    /**
287
-     * Gets the input by the indicated $name_parts.
288
-     * Eg if you're looking for an input named "my[great][file][input1]", $name_parts
289
-     * should be `['my', 'great', 'file', 'input1']`.
290
-     * Alternatively, you could use `FileDataHandler::getFileObject('my[great][file][input1]');`
291
-     *
292
-     * @param $name_parts
293
-     * @return FileSubmissionInterface
294
-     * @throws UnexpectedValueException
295
-     * @since 4.9.80.p
296
-     */
297
-    public function getFileObjectFromNameParts($name_parts)
298
-    {
299
-        return $this->getFileObjects()->get($this->inputNameFromParts($name_parts));
300
-    }
286
+	/**
287
+	 * Gets the input by the indicated $name_parts.
288
+	 * Eg if you're looking for an input named "my[great][file][input1]", $name_parts
289
+	 * should be `['my', 'great', 'file', 'input1']`.
290
+	 * Alternatively, you could use `FileDataHandler::getFileObject('my[great][file][input1]');`
291
+	 *
292
+	 * @param $name_parts
293
+	 * @return FileSubmissionInterface
294
+	 * @throws UnexpectedValueException
295
+	 * @since 4.9.80.p
296
+	 */
297
+	public function getFileObjectFromNameParts($name_parts)
298
+	{
299
+		return $this->getFileObjects()->get($this->inputNameFromParts($name_parts));
300
+	}
301 301
 
302 302
 
303
-    /**
304
-     * Gets the FileSubmissionInterface corresponding to the HTML name provided.
305
-     *
306
-     * @param $html_name
307
-     * @return mixed
308
-     * @throws InvalidArgumentException
309
-     * @throws UnexpectedValueException
310
-     * @since 4.9.80.p
311
-     */
312
-    public function getFileObject($html_name)
313
-    {
314
-        return $this->getFileObjects()->get($html_name);
315
-    }
303
+	/**
304
+	 * Gets the FileSubmissionInterface corresponding to the HTML name provided.
305
+	 *
306
+	 * @param $html_name
307
+	 * @return mixed
308
+	 * @throws InvalidArgumentException
309
+	 * @throws UnexpectedValueException
310
+	 * @since 4.9.80.p
311
+	 */
312
+	public function getFileObject($html_name)
313
+	{
314
+		return $this->getFileObjects()->get($html_name);
315
+	}
316 316
 }
317 317
 // End of file FilesDataHandler.php
318 318
 // Location: EventEspresso\core\services\request\files/FilesDataHandler.php
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             // collection name
100 100
             'submitted_files'
101 101
         );
102
-        $files_raw_data     = $this->request->filesParams();
102
+        $files_raw_data = $this->request->filesParams();
103 103
         if (empty($files_raw_data)) {
104 104
             return;
105 105
         }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      */
124 124
     protected function isStrangeFilesArray($files_data)
125 125
     {
126
-        if (! is_array($files_data)) {
126
+        if ( ! is_array($files_data)) {
127 127
             throw new UnexpectedValueException(
128 128
                 sprintf(
129 129
                     esc_html__(
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             );
136 136
         }
137 137
         $first_value = reset($files_data);
138
-        if (! is_array($first_value)) {
138
+        if ( ! is_array($first_value)) {
139 139
             throw new UnexpectedValueException(
140 140
                 sprintf(
141 141
                     esc_html__(
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
         $sane_files_array = [];
172 172
         foreach ($files_data as $top_level_name => $top_level_children) {
173 173
             $sub_array                           = [];
174
-            $sane_files_array[ $top_level_name ] = [];
174
+            $sane_files_array[$top_level_name] = [];
175 175
             foreach ($top_level_children as $file_data_part => $second_level_children) {
176 176
                 foreach ($second_level_children as $next_level_name => $sub_values) {
177
-                    $sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part);
177
+                    $sub_array[$next_level_name] = $this->organizeFilesData($sub_values, $file_data_part);
178 178
                 }
179
-                $sane_files_array[ $top_level_name ] = array_replace_recursive(
179
+                $sane_files_array[$top_level_name] = array_replace_recursive(
180 180
                     $sub_array,
181
-                    $sane_files_array[ $top_level_name ]
181
+                    $sane_files_array[$top_level_name]
182 182
                 );
183 183
             }
184 184
         }
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
      */
197 197
     protected function organizeFilesData($data, $type)
198 198
     {
199
-        if (! is_array($data)) {
199
+        if ( ! is_array($data)) {
200 200
             return [
201 201
                 $type => $data,
202 202
             ];
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
         $organized_data = [];
205 205
         foreach ($data as $input_name_part => $sub_inputs_or_value) {
206 206
             if (is_array($sub_inputs_or_value)) {
207
-                $organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type);
207
+                $organized_data[$input_name_part] = $this->organizeFilesData($sub_inputs_or_value, $type);
208 208
             } else {
209
-                $organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value;
209
+                $organized_data[$input_name_part][$type] = $sub_inputs_or_value;
210 210
             }
211 211
         }
212 212
         return $organized_data;
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
      */
227 227
     protected function createFileObjects($organized_files, $name_parts_so_far = [])
228 228
     {
229
-        if (! is_array($organized_files)) {
229
+        if ( ! is_array($organized_files)) {
230 230
             throw new UnexpectedValueException(
231 231
                 sprintf(
232 232
                     esc_html__(
@@ -270,14 +270,14 @@  discard block
 block discarded – undo
270 270
      */
271 271
     protected function inputNameFromParts($parts)
272 272
     {
273
-        if (! is_array($parts)) {
273
+        if ( ! is_array($parts)) {
274 274
             throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
275 275
         }
276 276
         $generated_string = '';
277 277
         foreach ($parts as $part) {
278 278
             $part = (string) $part;
279 279
             // wrap all but the first part in []
280
-            $generated_string .= $generated_string === '' ? $part : '[' . $part . ']';
280
+            $generated_string .= $generated_string === '' ? $part : '['.$part.']';
281 281
         }
282 282
         return $generated_string;
283 283
     }
Please login to merge, or discard this patch.
core/services/request/sanitizers/ServerSanitizer.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -11,59 +11,59 @@
 block discarded – undo
11 11
  */
12 12
 class ServerSanitizer
13 13
 {
14
-    /**
15
-     * @param string $value
16
-     * @return mixed|string
17
-     */
18
-    public function clean($key, $value)
19
-    {
20
-        switch ($key) {
21
-            case 'AUTH_TYPE':
22
-                $valid_types = [
23
-                    'Basic',
24
-                    'Bearer',
25
-                    'Digest',
26
-                    'HOBA',
27
-                    'Mutual',
28
-                    'Negotiate',
29
-                    'OAuth',
30
-                    'SCRAM-SHA-1',
31
-                    'SCRAM-SHA-256',
32
-                    'vapid',
33
-                ];
34
-                return in_array($value, $valid_types, true) ? $value : 'Basic';
35
-            case 'argc':
36
-            case 'HTTP_DNT':
37
-            case 'HTTP_UPGRADE_INSECURE_REQUESTS':
38
-            case 'SERVER_PORT':
39
-            case 'REMOTE_PORT':
40
-            case 'REQUEST_TIME':
41
-                return (int) filter_var($value, FILTER_SANITIZE_NUMBER_INT);
42
-            case 'REQUEST_TIME_FLOAT':
43
-                return (float) filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
44
-            case 'REQUEST_METHOD':
45
-                $valid_types = [
46
-                    'CONNECT',
47
-                    'DELETE',
48
-                    'GET',
49
-                    'HEAD',
50
-                    'OPTIONS',
51
-                    'PATCH',
52
-                    'POST',
53
-                    'PUT',
54
-                    'TRACE',
55
-                ];
56
-                return in_array($value, $valid_types, true) ? $value : 'GET';
57
-            case 'HTTP_HOST':
58
-            case 'QUERY_STRING':
59
-            case 'REQUEST_URI':
60
-            case 'SCRIPT_NAME':
61
-            case 'SERVER_NAME':
62
-                return filter_var($value, FILTER_SANITIZE_URL);
63
-            case 'SERVER_ADMIN':
64
-                return filter_var($value, FILTER_SANITIZE_EMAIL);
65
-            default:
66
-                return filter_var($value, FILTER_SANITIZE_STRING);
67
-        }
68
-    }
14
+	/**
15
+	 * @param string $value
16
+	 * @return mixed|string
17
+	 */
18
+	public function clean($key, $value)
19
+	{
20
+		switch ($key) {
21
+			case 'AUTH_TYPE':
22
+				$valid_types = [
23
+					'Basic',
24
+					'Bearer',
25
+					'Digest',
26
+					'HOBA',
27
+					'Mutual',
28
+					'Negotiate',
29
+					'OAuth',
30
+					'SCRAM-SHA-1',
31
+					'SCRAM-SHA-256',
32
+					'vapid',
33
+				];
34
+				return in_array($value, $valid_types, true) ? $value : 'Basic';
35
+			case 'argc':
36
+			case 'HTTP_DNT':
37
+			case 'HTTP_UPGRADE_INSECURE_REQUESTS':
38
+			case 'SERVER_PORT':
39
+			case 'REMOTE_PORT':
40
+			case 'REQUEST_TIME':
41
+				return (int) filter_var($value, FILTER_SANITIZE_NUMBER_INT);
42
+			case 'REQUEST_TIME_FLOAT':
43
+				return (float) filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
44
+			case 'REQUEST_METHOD':
45
+				$valid_types = [
46
+					'CONNECT',
47
+					'DELETE',
48
+					'GET',
49
+					'HEAD',
50
+					'OPTIONS',
51
+					'PATCH',
52
+					'POST',
53
+					'PUT',
54
+					'TRACE',
55
+				];
56
+				return in_array($value, $valid_types, true) ? $value : 'GET';
57
+			case 'HTTP_HOST':
58
+			case 'QUERY_STRING':
59
+			case 'REQUEST_URI':
60
+			case 'SCRIPT_NAME':
61
+			case 'SERVER_NAME':
62
+				return filter_var($value, FILTER_SANITIZE_URL);
63
+			case 'SERVER_ADMIN':
64
+				return filter_var($value, FILTER_SANITIZE_EMAIL);
65
+			default:
66
+				return filter_var($value, FILTER_SANITIZE_STRING);
67
+		}
68
+	}
69 69
 }
Please login to merge, or discard this patch.