Completed
Branch fix/escaping-2 (5dcb9a)
by
unknown
13:02 queued 10:26
created
core/domain/services/admin/events/data/ConfirmDeletion.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -30,86 +30,86 @@
 block discarded – undo
30 30
  */
31 31
 class ConfirmDeletion
32 32
 {
33
-    /**
34
-     * @var NodeGroupDao
35
-     */
36
-    private $dao;
33
+	/**
34
+	 * @var NodeGroupDao
35
+	 */
36
+	private $dao;
37 37
 
38
-    /**
39
-     * ConfirmDeletion constructor.
40
-     * @param NodeGroupDao $dao
41
-     */
42
-    public function __construct(
43
-        NodeGroupDao $dao
44
-    ) {
38
+	/**
39
+	 * ConfirmDeletion constructor.
40
+	 * @param NodeGroupDao $dao
41
+	 */
42
+	public function __construct(
43
+		NodeGroupDao $dao
44
+	) {
45 45
 
46
-        $this->dao = $dao;
47
-    }
46
+		$this->dao = $dao;
47
+	}
48 48
 
49
-    /**
50
-     * Redirects to the batch job for deleting events if the form submission is valid, otherwise back to the deletion
51
-     * preview page.
52
-     * @since 4.10.12.p
53
-     * @param $request_data
54
-     * @param $admin_base_url
55
-     * @throws EE_Error
56
-     * @throws InvalidArgumentException
57
-     * @throws InvalidDataTypeException
58
-     * @throws InvalidInterfaceException
59
-     * @throws ReflectionException
60
-     * @throws UnexpectedEntityException
61
-     */
62
-    public function handle($request_data, $admin_base_url)
63
-    {
64
-        $deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : '';
65
-        $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
66
-        $form = new ConfirmEventDeletionForm($models_and_ids_to_delete['Event']);
67
-        // Initialize the form from the request, and check if its valid.
68
-        $form->receive_form_submission($request_data);
69
-        if ($form->is_valid()) {
70
-            // Redirect the user to the deletion batch job.
71
-            EEH_URL::safeRedirectAndExit(
72
-                EE_Admin_Page::add_query_args_and_nonce(
73
-                    array(
74
-                        'page' => 'espresso_batch',
75
-                        'batch' => EED_Batch::batch_job,
76
-                        'deletion_job_code' => $deletion_job_code,
77
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion'),
78
-                        'return_url' => urlencode(
79
-                            add_query_arg(
80
-                                [
81
-                                    'status' => 'trash'
82
-                                ],
83
-                                EVENTS_ADMIN_URL
84
-                            )
85
-                        )
86
-                    ),
87
-                    admin_url()
88
-                )
89
-            );
90
-        }
91
-        // Dont' use $form->submission_error_message() because it adds the form input's label in front
92
-        // of each validation error which ends up looking quite confusing.
93
-        $validation_errors = $form->get_validation_errors_accumulated();
94
-        foreach ($validation_errors as $validation_error) {
95
-            EE_Error::add_error(
96
-                $validation_error->getMessage(),
97
-                __FILE__,
98
-                __FUNCTION__,
99
-                __LINE__
100
-            );
101
-        }
49
+	/**
50
+	 * Redirects to the batch job for deleting events if the form submission is valid, otherwise back to the deletion
51
+	 * preview page.
52
+	 * @since 4.10.12.p
53
+	 * @param $request_data
54
+	 * @param $admin_base_url
55
+	 * @throws EE_Error
56
+	 * @throws InvalidArgumentException
57
+	 * @throws InvalidDataTypeException
58
+	 * @throws InvalidInterfaceException
59
+	 * @throws ReflectionException
60
+	 * @throws UnexpectedEntityException
61
+	 */
62
+	public function handle($request_data, $admin_base_url)
63
+	{
64
+		$deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : '';
65
+		$models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
66
+		$form = new ConfirmEventDeletionForm($models_and_ids_to_delete['Event']);
67
+		// Initialize the form from the request, and check if its valid.
68
+		$form->receive_form_submission($request_data);
69
+		if ($form->is_valid()) {
70
+			// Redirect the user to the deletion batch job.
71
+			EEH_URL::safeRedirectAndExit(
72
+				EE_Admin_Page::add_query_args_and_nonce(
73
+					array(
74
+						'page' => 'espresso_batch',
75
+						'batch' => EED_Batch::batch_job,
76
+						'deletion_job_code' => $deletion_job_code,
77
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion'),
78
+						'return_url' => urlencode(
79
+							add_query_arg(
80
+								[
81
+									'status' => 'trash'
82
+								],
83
+								EVENTS_ADMIN_URL
84
+							)
85
+						)
86
+					),
87
+					admin_url()
88
+				)
89
+			);
90
+		}
91
+		// Dont' use $form->submission_error_message() because it adds the form input's label in front
92
+		// of each validation error which ends up looking quite confusing.
93
+		$validation_errors = $form->get_validation_errors_accumulated();
94
+		foreach ($validation_errors as $validation_error) {
95
+			EE_Error::add_error(
96
+				$validation_error->getMessage(),
97
+				__FILE__,
98
+				__FUNCTION__,
99
+				__LINE__
100
+			);
101
+		}
102 102
 
103
-        EEH_URL::safeRedirectAndExit(
104
-            EE_Admin_Page::add_query_args_and_nonce(
105
-                [
106
-                    'action' => 'preview_deletion',
107
-                    'deletion_job_code' => $deletion_job_code
108
-                ],
109
-                $admin_base_url
110
-            )
111
-        );
112
-    }
103
+		EEH_URL::safeRedirectAndExit(
104
+			EE_Admin_Page::add_query_args_and_nonce(
105
+				[
106
+					'action' => 'preview_deletion',
107
+					'deletion_job_code' => $deletion_job_code
108
+				],
109
+				$admin_base_url
110
+			)
111
+		);
112
+	}
113 113
 }
114 114
 // End of file ConfirmDeletion.php
115 115
 // Location: EventEspresso\core\domain\services\admin\events\data/ConfirmDeletion.php
Please login to merge, or discard this patch.
core/db_models/helpers/EE_Table_Base.php 2 patches
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -7,151 +7,151 @@
 block discarded – undo
7 7
 abstract class EE_Table_Base
8 8
 {
9 9
 
10
-    /**
11
-     * This holds the table_name without the table prefix.
12
-     *
13
-     * @var string
14
-     */
15
-    public $_table_name;
16
-
17
-
18
-    /**
19
-     * This holds what is used as the alias for the table in queries.
20
-     *
21
-     * @var string
22
-     */
23
-    public $_table_alias;
24
-
25
-
26
-    /**
27
-     * Table's private key column
28
-     *
29
-     * @var string
30
-     */
31
-    protected $_pk_column;
32
-
33
-
34
-    /**
35
-     * Whether this table is a global table (in multisite) or specific to site.
36
-     *
37
-     * @var bool
38
-     */
39
-    protected $_global;
40
-
41
-
42
-    /**
43
-     * @param string  $table_name with or without wpdb prefix
44
-     * @param string  $pk_column
45
-     * @param boolean $global     whether the table is "global" as in there is only 1 table on an entire multisite
46
-     *                            install, or whether each site on a multisite install has a copy of this table
47
-     * @global wpdb   $wpdb
48
-     */
49
-    public function __construct($table_name, $pk_column, $global = false)
50
-    {
51
-        $this->_global = $global;
52
-        $prefix        = $this->get_table_prefix();
53
-        // if they added the prefix, let's remove it because we delay adding the prefix until right when its needed.
54
-        if (strpos($table_name, $prefix) === 0) {
55
-            $table_name = substr_replace($table_name, '', 0, strlen($prefix));
56
-        }
57
-        $this->_table_name = $table_name;
58
-        $this->_pk_column  = $pk_column;
59
-    }
60
-
61
-
62
-    /**
63
-     * This returns the table prefix for the current model state.
64
-     *
65
-     * @return string
66
-     * @global wpdb $wpdb
67
-     */
68
-    public function get_table_prefix()
69
-    {
70
-        global $wpdb;
71
-        if ($this->_global) {
72
-            return $wpdb->base_prefix;
73
-        }
74
-        return $wpdb->get_blog_prefix(EEM_Base::get_model_query_blog_id());
75
-    }
76
-
77
-
78
-    /**
79
-     * Used to set the table_alias property
80
-     *
81
-     * @param string $table_alias
82
-     */
83
-    public function _construct_finalize_with_alias($table_alias)
84
-    {
85
-        $this->_table_alias = $table_alias;
86
-    }
87
-
88
-
89
-    /**
90
-     * Returns the fully qualified table name for the database (includes the table prefix current for the blog).
91
-     *
92
-     * @return string
93
-     */
94
-    public function get_table_name()
95
-    {
96
-        return $this->get_table_prefix() . $this->_table_name;
97
-    }
98
-
99
-
100
-    /**
101
-     * Provides what is currently set as the alias for the table to be used in queries.
102
-     *
103
-     * @return string
104
-     * @throws EE_Error
105
-     */
106
-    public function get_table_alias()
107
-    {
108
-        if (! $this->_table_alias) {
109
-            throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?");
110
-        }
111
-        return $this->_table_alias;
112
-    }
113
-
114
-
115
-    /**
116
-     * @return string name of column of PK
117
-     */
118
-    public function get_pk_column()
119
-    {
120
-        return $this->_pk_column;
121
-    }
122
-
123
-
124
-    /**
125
-     * returns a string with the table alias, a period, and the private key's column.
126
-     *
127
-     * @return string
128
-     */
129
-    public function get_fully_qualified_pk_column()
130
-    {
131
-        return $this->get_table_alias() . "." . $this->get_pk_column();
132
-    }
133
-
134
-
135
-    /**
136
-     * returns the special sql for a inner select with a limit.
137
-     *
138
-     * @return string    SQL select
139
-     */
140
-    public function get_select_join_limit($limit)
141
-    {
142
-        $limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int) $limit;
143
-        return SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias;
144
-    }
145
-
146
-
147
-    /**
148
-     * Returns whether or not htis is a global table (ie, on multisite there's
149
-     * only one of these tables, on the main blog)
150
-     *
151
-     * @return boolean
152
-     */
153
-    public function is_global()
154
-    {
155
-        return $this->_global;
156
-    }
10
+	/**
11
+	 * This holds the table_name without the table prefix.
12
+	 *
13
+	 * @var string
14
+	 */
15
+	public $_table_name;
16
+
17
+
18
+	/**
19
+	 * This holds what is used as the alias for the table in queries.
20
+	 *
21
+	 * @var string
22
+	 */
23
+	public $_table_alias;
24
+
25
+
26
+	/**
27
+	 * Table's private key column
28
+	 *
29
+	 * @var string
30
+	 */
31
+	protected $_pk_column;
32
+
33
+
34
+	/**
35
+	 * Whether this table is a global table (in multisite) or specific to site.
36
+	 *
37
+	 * @var bool
38
+	 */
39
+	protected $_global;
40
+
41
+
42
+	/**
43
+	 * @param string  $table_name with or without wpdb prefix
44
+	 * @param string  $pk_column
45
+	 * @param boolean $global     whether the table is "global" as in there is only 1 table on an entire multisite
46
+	 *                            install, or whether each site on a multisite install has a copy of this table
47
+	 * @global wpdb   $wpdb
48
+	 */
49
+	public function __construct($table_name, $pk_column, $global = false)
50
+	{
51
+		$this->_global = $global;
52
+		$prefix        = $this->get_table_prefix();
53
+		// if they added the prefix, let's remove it because we delay adding the prefix until right when its needed.
54
+		if (strpos($table_name, $prefix) === 0) {
55
+			$table_name = substr_replace($table_name, '', 0, strlen($prefix));
56
+		}
57
+		$this->_table_name = $table_name;
58
+		$this->_pk_column  = $pk_column;
59
+	}
60
+
61
+
62
+	/**
63
+	 * This returns the table prefix for the current model state.
64
+	 *
65
+	 * @return string
66
+	 * @global wpdb $wpdb
67
+	 */
68
+	public function get_table_prefix()
69
+	{
70
+		global $wpdb;
71
+		if ($this->_global) {
72
+			return $wpdb->base_prefix;
73
+		}
74
+		return $wpdb->get_blog_prefix(EEM_Base::get_model_query_blog_id());
75
+	}
76
+
77
+
78
+	/**
79
+	 * Used to set the table_alias property
80
+	 *
81
+	 * @param string $table_alias
82
+	 */
83
+	public function _construct_finalize_with_alias($table_alias)
84
+	{
85
+		$this->_table_alias = $table_alias;
86
+	}
87
+
88
+
89
+	/**
90
+	 * Returns the fully qualified table name for the database (includes the table prefix current for the blog).
91
+	 *
92
+	 * @return string
93
+	 */
94
+	public function get_table_name()
95
+	{
96
+		return $this->get_table_prefix() . $this->_table_name;
97
+	}
98
+
99
+
100
+	/**
101
+	 * Provides what is currently set as the alias for the table to be used in queries.
102
+	 *
103
+	 * @return string
104
+	 * @throws EE_Error
105
+	 */
106
+	public function get_table_alias()
107
+	{
108
+		if (! $this->_table_alias) {
109
+			throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?");
110
+		}
111
+		return $this->_table_alias;
112
+	}
113
+
114
+
115
+	/**
116
+	 * @return string name of column of PK
117
+	 */
118
+	public function get_pk_column()
119
+	{
120
+		return $this->_pk_column;
121
+	}
122
+
123
+
124
+	/**
125
+	 * returns a string with the table alias, a period, and the private key's column.
126
+	 *
127
+	 * @return string
128
+	 */
129
+	public function get_fully_qualified_pk_column()
130
+	{
131
+		return $this->get_table_alias() . "." . $this->get_pk_column();
132
+	}
133
+
134
+
135
+	/**
136
+	 * returns the special sql for a inner select with a limit.
137
+	 *
138
+	 * @return string    SQL select
139
+	 */
140
+	public function get_select_join_limit($limit)
141
+	{
142
+		$limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int) $limit;
143
+		return SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias;
144
+	}
145
+
146
+
147
+	/**
148
+	 * Returns whether or not htis is a global table (ie, on multisite there's
149
+	 * only one of these tables, on the main blog)
150
+	 *
151
+	 * @return boolean
152
+	 */
153
+	public function is_global()
154
+	{
155
+		return $this->_global;
156
+	}
157 157
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function get_table_name()
95 95
     {
96
-        return $this->get_table_prefix() . $this->_table_name;
96
+        return $this->get_table_prefix().$this->_table_name;
97 97
     }
98 98
 
99 99
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public function get_table_alias()
107 107
     {
108
-        if (! $this->_table_alias) {
108
+        if ( ! $this->_table_alias) {
109 109
             throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?");
110 110
         }
111 111
         return $this->_table_alias;
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      */
129 129
     public function get_fully_qualified_pk_column()
130 130
     {
131
-        return $this->get_table_alias() . "." . $this->get_pk_column();
131
+        return $this->get_table_alias().".".$this->get_pk_column();
132 132
     }
133 133
 
134 134
 
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
      */
140 140
     public function get_select_join_limit($limit)
141 141
     {
142
-        $limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int) $limit;
143
-        return SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias;
142
+        $limit = is_array($limit) ? 'LIMIT '.implode(',', array_map('intval', $limit)) : 'LIMIT '.(int) $limit;
143
+        return SP.'(SELECT * FROM '.$this->_table_name.SP.$limit.') AS '.$this->_table_alias;
144 144
     }
145 145
 
146 146
 
Please login to merge, or discard this patch.
core/domain/DomainFactory.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -23,62 +23,62 @@
 block discarded – undo
23 23
 class DomainFactory
24 24
 {
25 25
 
26
-    /**
27
-     * @param FullyQualifiedName $domain_fqcn   [required] Fully Qualified Class Name for the Domain class
28
-     * @param array $arguments                  [required] array of arguments to be passed to the Domain class
29
-     *                                          constructor. Must at least include the following two value objects:
30
-     *                                          array(
31
-     *                                              EventEspresso\core\domain\values\FilePath $plugin_file
32
-     *                                              EventEspresso\core\domain\values\Version $version
33
-     *                                          )
34
-     * @return DomainInterface
35
-     * @throws DomainException
36
-     * @throws InvalidArgumentException
37
-     * @throws InvalidDataTypeException
38
-     * @throws InvalidInterfaceException
39
-     */
40
-    public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments)
41
-    {
42
-        if (! isset($arguments[0], $arguments[1])) {
43
-            throw new InvalidArgumentException(
44
-                esc_html__(
45
-                    'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class',
46
-                    'event_espresso'
47
-                )
48
-            );
49
-        }
50
-        /** @var DomainInterface $domain */
51
-        $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments);
52
-        if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) {
53
-            throw new DomainException(
54
-                sprintf(
55
-                    esc_html__(
56
-                        'The requested Domain class "%1$s" could not be loaded.',
57
-                        'event_espresso'
58
-                    ),
59
-                    $domain_fqcn
60
-                )
61
-            );
62
-        }
63
-        return $domain;
64
-    }
26
+	/**
27
+	 * @param FullyQualifiedName $domain_fqcn   [required] Fully Qualified Class Name for the Domain class
28
+	 * @param array $arguments                  [required] array of arguments to be passed to the Domain class
29
+	 *                                          constructor. Must at least include the following two value objects:
30
+	 *                                          array(
31
+	 *                                              EventEspresso\core\domain\values\FilePath $plugin_file
32
+	 *                                              EventEspresso\core\domain\values\Version $version
33
+	 *                                          )
34
+	 * @return DomainInterface
35
+	 * @throws DomainException
36
+	 * @throws InvalidArgumentException
37
+	 * @throws InvalidDataTypeException
38
+	 * @throws InvalidInterfaceException
39
+	 */
40
+	public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments)
41
+	{
42
+		if (! isset($arguments[0], $arguments[1])) {
43
+			throw new InvalidArgumentException(
44
+				esc_html__(
45
+					'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class',
46
+					'event_espresso'
47
+				)
48
+			);
49
+		}
50
+		/** @var DomainInterface $domain */
51
+		$domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments);
52
+		if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) {
53
+			throw new DomainException(
54
+				sprintf(
55
+					esc_html__(
56
+						'The requested Domain class "%1$s" could not be loaded.',
57
+						'event_espresso'
58
+					),
59
+					$domain_fqcn
60
+				)
61
+			);
62
+		}
63
+		return $domain;
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * @return Domain
69
-     * @throws DomainException
70
-     * @throws InvalidArgumentException
71
-     * @throws InvalidDataTypeException
72
-     * @throws InvalidFilePathException
73
-     * @throws InvalidInterfaceException
74
-     */
75
-    public static function getEventEspressoCoreDomain()
76
-    {
77
-        $domain = new Domain(
78
-            new FilePath(EVENT_ESPRESSO_MAIN_FILE),
79
-            Version::fromString(espresso_version())
80
-        );
81
-        LoaderFactory::getLoader()->share('EventEspresso\core\domain\Domain', $domain);
82
-        return $domain;
83
-    }
67
+	/**
68
+	 * @return Domain
69
+	 * @throws DomainException
70
+	 * @throws InvalidArgumentException
71
+	 * @throws InvalidDataTypeException
72
+	 * @throws InvalidFilePathException
73
+	 * @throws InvalidInterfaceException
74
+	 */
75
+	public static function getEventEspressoCoreDomain()
76
+	{
77
+		$domain = new Domain(
78
+			new FilePath(EVENT_ESPRESSO_MAIN_FILE),
79
+			Version::fromString(espresso_version())
80
+		);
81
+		LoaderFactory::getLoader()->share('EventEspresso\core\domain\Domain', $domain);
82
+		return $domain;
83
+	}
84 84
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments)
41 41
     {
42
-        if (! isset($arguments[0], $arguments[1])) {
42
+        if ( ! isset($arguments[0], $arguments[1])) {
43 43
             throw new InvalidArgumentException(
44 44
                 esc_html__(
45 45
                     'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class',
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         }
50 50
         /** @var DomainInterface $domain */
51 51
         $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments);
52
-        if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) {
52
+        if ( ! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) {
53 53
             throw new DomainException(
54 54
                 sprintf(
55 55
                     esc_html__(
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Personal_Data_Exporter.lib.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -13,55 +13,55 @@
 block discarded – undo
13 13
 class EE_Register_Personal_Data_Exporter implements EEI_Plugin_API
14 14
 {
15 15
 
16
-    /**
17
-     * FQCN for all privacy policy generators
18
-     *
19
-     * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs
20
-     */
21
-    protected static $exporters = [];
16
+	/**
17
+	 * FQCN for all privacy policy generators
18
+	 *
19
+	 * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs
20
+	 */
21
+	protected static $exporters = [];
22 22
 
23 23
 
24
-    /**
25
-     * @param string $identifier
26
-     * @param array  $setup_args can be the fully qualified namespaces each containing only privacy policies,
27
-     *                           OR fully qualified class names of privacy policies
28
-     */
29
-    public static function register($identifier = '', array $setup_args = [])
30
-    {
31
-        self::$exporters[ $identifier ] = $setup_args;
32
-        // add to list of modules to be registered
33
-        add_filter(
34
-            'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters',
35
-            ['EE_Register_Personal_Data_Exporter', 'addExporters']
36
-        );
37
-    }
24
+	/**
25
+	 * @param string $identifier
26
+	 * @param array  $setup_args can be the fully qualified namespaces each containing only privacy policies,
27
+	 *                           OR fully qualified class names of privacy policies
28
+	 */
29
+	public static function register($identifier = '', array $setup_args = [])
30
+	{
31
+		self::$exporters[ $identifier ] = $setup_args;
32
+		// add to list of modules to be registered
33
+		add_filter(
34
+			'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters',
35
+			['EE_Register_Personal_Data_Exporter', 'addExporters']
36
+		);
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     * @param string $identifier
42
-     */
43
-    public static function deregister($identifier = '')
44
-    {
45
-        unset(self::$exporters[ $identifier ]);
46
-    }
40
+	/**
41
+	 * @param string $identifier
42
+	 */
43
+	public static function deregister($identifier = '')
44
+	{
45
+		unset(self::$exporters[ $identifier ]);
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * Adds our personal data exporters registered by add-ons
51
-     *
52
-     * @param string[] $exporters
53
-     * @return string[]
54
-     */
55
-    public static function addExporters(array $exporters)
56
-    {
57
-        foreach (self::$exporters as $exporters_per_addon) {
58
-            $exporters = array_merge(
59
-                $exporters,
60
-                $exporters_per_addon
61
-            );
62
-        }
63
-        return $exporters;
64
-    }
49
+	/**
50
+	 * Adds our personal data exporters registered by add-ons
51
+	 *
52
+	 * @param string[] $exporters
53
+	 * @return string[]
54
+	 */
55
+	public static function addExporters(array $exporters)
56
+	{
57
+		foreach (self::$exporters as $exporters_per_addon) {
58
+			$exporters = array_merge(
59
+				$exporters,
60
+				$exporters_per_addon
61
+			);
62
+		}
63
+		return $exporters;
64
+	}
65 65
 }
66 66
 // End of file EE_Register_Personal_Data_Exporter.lib.php
67 67
 // Location: ${NAMESPACE}/EE_Register_Personal_Data_Exporter.lib.php
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public static function register($identifier = '', array $setup_args = [])
30 30
     {
31
-        self::$exporters[ $identifier ] = $setup_args;
31
+        self::$exporters[$identifier] = $setup_args;
32 32
         // add to list of modules to be registered
33 33
         add_filter(
34 34
             'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters',
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public static function deregister($identifier = '')
44 44
     {
45
-        unset(self::$exporters[ $identifier ]);
45
+        unset(self::$exporters[$identifier]);
46 46
     }
47 47
 
48 48
 
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Personal_Data_Eraser.lib.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -13,55 +13,55 @@
 block discarded – undo
13 13
 class EE_Register_Personal_Data_Eraser implements EEI_Plugin_API
14 14
 {
15 15
 
16
-    /**
17
-     * FQCN for all privacy policy generators
18
-     *
19
-     * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs
20
-     */
21
-    protected static $erasers = [];
16
+	/**
17
+	 * FQCN for all privacy policy generators
18
+	 *
19
+	 * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs
20
+	 */
21
+	protected static $erasers = [];
22 22
 
23 23
 
24
-    /**
25
-     * @param string $identifier
26
-     * @param array  $setup_args can be the fully qualified namespaces each containing only privacy policies,
27
-     *                           OR fully qualified class names of privacy policies
28
-     */
29
-    public static function register($identifier = '', array $setup_args = [])
30
-    {
31
-        self::$erasers[ $identifier ] = $setup_args;
32
-        // add to list of modules to be registered
33
-        add_filter(
34
-            'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers',
35
-            ['EE_Register_Personal_Data_Eraser', 'addErasers']
36
-        );
37
-    }
24
+	/**
25
+	 * @param string $identifier
26
+	 * @param array  $setup_args can be the fully qualified namespaces each containing only privacy policies,
27
+	 *                           OR fully qualified class names of privacy policies
28
+	 */
29
+	public static function register($identifier = '', array $setup_args = [])
30
+	{
31
+		self::$erasers[ $identifier ] = $setup_args;
32
+		// add to list of modules to be registered
33
+		add_filter(
34
+			'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers',
35
+			['EE_Register_Personal_Data_Eraser', 'addErasers']
36
+		);
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     * @param string $identifier
42
-     */
43
-    public static function deregister($identifier = '')
44
-    {
45
-        unset(self::$erasers[ $identifier ]);
46
-    }
40
+	/**
41
+	 * @param string $identifier
42
+	 */
43
+	public static function deregister($identifier = '')
44
+	{
45
+		unset(self::$erasers[ $identifier ]);
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * Adds our personal data erasers registered by add-ons
51
-     *
52
-     * @param string[] $erasers
53
-     * @return string[]
54
-     */
55
-    public static function addErasers(array $erasers)
56
-    {
57
-        foreach (self::$erasers as $erasers_per_addon) {
58
-            $erasers = array_merge(
59
-                $erasers,
60
-                $erasers_per_addon
61
-            );
62
-        }
63
-        return $erasers;
64
-    }
49
+	/**
50
+	 * Adds our personal data erasers registered by add-ons
51
+	 *
52
+	 * @param string[] $erasers
53
+	 * @return string[]
54
+	 */
55
+	public static function addErasers(array $erasers)
56
+	{
57
+		foreach (self::$erasers as $erasers_per_addon) {
58
+			$erasers = array_merge(
59
+				$erasers,
60
+				$erasers_per_addon
61
+			);
62
+		}
63
+		return $erasers;
64
+	}
65 65
 }
66 66
 // End of file EE_Register_Personal_Data_Eraser.lib.php
67 67
 // Location: ${NAMESPACE}/EE_Register_Personal_Data_Eraser.lib.php
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public static function register($identifier = '', array $setup_args = [])
30 30
     {
31
-        self::$erasers[ $identifier ] = $setup_args;
31
+        self::$erasers[$identifier] = $setup_args;
32 32
         // add to list of modules to be registered
33 33
         add_filter(
34 34
             'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers',
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public static function deregister($identifier = '')
44 44
     {
45
-        unset(self::$erasers[ $identifier ]);
45
+        unset(self::$erasers[$identifier]);
46 46
     }
47 47
 
48 48
 
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Privacy_Policy.lib.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -13,55 +13,55 @@
 block discarded – undo
13 13
 class EE_Register_Privacy_Policy implements EEI_Plugin_API
14 14
 {
15 15
 
16
-    /**
17
-     * FQCN for all privacy policy generators
18
-     *
19
-     * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs
20
-     */
21
-    protected static $privacy_policies = array();
16
+	/**
17
+	 * FQCN for all privacy policy generators
18
+	 *
19
+	 * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs
20
+	 */
21
+	protected static $privacy_policies = array();
22 22
 
23 23
 
24
-    /**
25
-     * @param string $identifier
26
-     * @param array $setup_args can be the fully qualified namespaces each containing only privacy policies,
27
-     *              OR fully qualified class names of privacy policies
28
-     */
29
-    public static function register($identifier = '', array $setup_args = [])
30
-    {
31
-        self::$privacy_policies[ $identifier ] = $setup_args;
32
-        // add to list of modules to be registered
33
-        add_filter(
34
-            'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies',
35
-            array('EE_Register_Privacy_Policy', 'addPrivacyPolicies')
36
-        );
37
-    }
24
+	/**
25
+	 * @param string $identifier
26
+	 * @param array $setup_args can be the fully qualified namespaces each containing only privacy policies,
27
+	 *              OR fully qualified class names of privacy policies
28
+	 */
29
+	public static function register($identifier = '', array $setup_args = [])
30
+	{
31
+		self::$privacy_policies[ $identifier ] = $setup_args;
32
+		// add to list of modules to be registered
33
+		add_filter(
34
+			'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies',
35
+			array('EE_Register_Privacy_Policy', 'addPrivacyPolicies')
36
+		);
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     * @param string $identifier
42
-     */
43
-    public static function deregister($identifier = '')
44
-    {
45
-        unset(self::$privacy_policies[ $identifier ]);
46
-    }
40
+	/**
41
+	 * @param string $identifier
42
+	 */
43
+	public static function deregister($identifier = '')
44
+	{
45
+		unset(self::$privacy_policies[ $identifier ]);
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * Adds our privacy policy generators registered by add-ons
51
-     *
52
-     * @param string[] $privacy_policies
53
-     * @return string[]
54
-     */
55
-    public static function addPrivacyPolicies(array $privacy_policies)
56
-    {
57
-        foreach (self::$privacy_policies as $privacy_policies_per_addon) {
58
-            $privacy_policies = array_merge(
59
-                $privacy_policies,
60
-                $privacy_policies_per_addon
61
-            );
62
-        }
63
-        return $privacy_policies;
64
-    }
49
+	/**
50
+	 * Adds our privacy policy generators registered by add-ons
51
+	 *
52
+	 * @param string[] $privacy_policies
53
+	 * @return string[]
54
+	 */
55
+	public static function addPrivacyPolicies(array $privacy_policies)
56
+	{
57
+		foreach (self::$privacy_policies as $privacy_policies_per_addon) {
58
+			$privacy_policies = array_merge(
59
+				$privacy_policies,
60
+				$privacy_policies_per_addon
61
+			);
62
+		}
63
+		return $privacy_policies;
64
+	}
65 65
 }
66 66
 // End of file EE_Register_Privacy_Policy.lib.php
67 67
 // Location: ${NAMESPACE}/EE_Register_Privacy_Policy.lib.php
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public static function register($identifier = '', array $setup_args = [])
30 30
     {
31
-        self::$privacy_policies[ $identifier ] = $setup_args;
31
+        self::$privacy_policies[$identifier] = $setup_args;
32 32
         // add to list of modules to be registered
33 33
         add_filter(
34 34
             'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies',
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public static function deregister($identifier = '')
44 44
     {
45
-        unset(self::$privacy_policies[ $identifier ]);
45
+        unset(self::$privacy_policies[$identifier]);
46 46
     }
47 47
 
48 48
 
Please login to merge, or discard this patch.
core/libraries/plugin_api/EEI_Plugin_API.lib.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -18,23 +18,23 @@
 block discarded – undo
18 18
 interface EEI_Plugin_API
19 19
 {
20 20
 
21
-    /**
22
-     * Used to register a component with EE.
23
-     *
24
-     * @param string $identifier a unique name for the component being registered
25
-     * @param array  $setup_args an array of key value pairs of info for registering the component
26
-     * @return void
27
-     * @since 4.3.0
28
-     */
29
-    public static function register($identifier = '', array $setup_args = []);
21
+	/**
22
+	 * Used to register a component with EE.
23
+	 *
24
+	 * @param string $identifier a unique name for the component being registered
25
+	 * @param array  $setup_args an array of key value pairs of info for registering the component
26
+	 * @return void
27
+	 * @since 4.3.0
28
+	 */
29
+	public static function register($identifier = '', array $setup_args = []);
30 30
 
31 31
 
32
-    /**
33
-     * Used to deregister a component with EE.
34
-     *
35
-     * @param string $identifier a unique name for the component being registered
36
-     * @return void
37
-     * @since 4.3.0
38
-     */
39
-    public static function deregister($identifier = '');
32
+	/**
33
+	 * Used to deregister a component with EE.
34
+	 *
35
+	 * @param string $identifier a unique name for the component being registered
36
+	 * @return void
37
+	 * @since 4.3.0
38
+	 */
39
+	public static function deregister($identifier = '');
40 40
 }
Please login to merge, or discard this patch.
core/services/progress_steps/ProgressStepManager.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
         $this->setDisplayStrategy($display_strategy_name);
76 76
         $this->setDefaultStep($default_step);
77 77
         $this->setFormStepUrlKey($form_step_url_key);
78
-        if (! $collection instanceof CollectionInterface) {
78
+        if ( ! $collection instanceof CollectionInterface) {
79 79
             $collection = new Collection('\EventEspresso\core\services\progress_steps\ProgressStepInterface');
80 80
         }
81 81
         $this->collection = $collection;
82
-        if (! $request instanceof RequestInterface) {
82
+        if ( ! $request instanceof RequestInterface) {
83 83
             /** @var RequestInterface $request */
84 84
             $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
85 85
         }
@@ -94,23 +94,23 @@  discard block
 block discarded – undo
94 94
      */
95 95
     protected function setDisplayStrategy($display_strategy_name = 'number_bubbles')
96 96
     {
97
-        if (! is_string($display_strategy_name)) {
97
+        if ( ! is_string($display_strategy_name)) {
98 98
             throw new InvalidDataTypeException('$display_strategy_name', $display_strategy_name, 'string');
99 99
         }
100 100
         // build up FQCN from incoming display strategy folder name
101 101
         $display_strategy_class = 'EventEspresso\core\services\progress_steps\display_strategies\\';
102
-        $display_strategy_class .= $display_strategy_name . '\\';
102
+        $display_strategy_class .= $display_strategy_name.'\\';
103 103
         $display_strategy_class .= str_replace(' ', '', ucwords(str_replace('_', ' ', $display_strategy_name)));
104 104
         $display_strategy_class .= 'ProgressStepsDisplay';
105 105
         $display_strategy_class = apply_filters(
106 106
             'FHEE__ProgressStepManager__setDisplayStrategy__display_strategy_class',
107 107
             $display_strategy_class
108 108
         );
109
-        if (! class_exists($display_strategy_class)) {
109
+        if ( ! class_exists($display_strategy_class)) {
110 110
             throw new InvalidClassException($display_strategy_class);
111 111
         }
112 112
         $display_strategy = new $display_strategy_class();
113
-        if (! $display_strategy instanceof ProgressStepsDisplayInterface) {
113
+        if ( ! $display_strategy instanceof ProgressStepsDisplayInterface) {
114 114
             throw new InvalidClassException(
115 115
                 $display_strategy_class,
116 116
                 sprintf(
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function setDefaultStep($default_step)
132 132
     {
133
-        if (! is_string($default_step)) {
133
+        if ( ! is_string($default_step)) {
134 134
             throw new InvalidDataTypeException('$default_step', $default_step, 'string');
135 135
         }
136 136
         $this->default_step = $default_step;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
      */
144 144
     public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
145 145
     {
146
-        if (! is_string($form_step_url_key)) {
146
+        if ( ! is_string($form_step_url_key)) {
147 147
             throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
148 148
         }
149 149
         $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         // grab the step previously known as current, in case we need to revert
164 164
         $current_current_step = $this->collection->current();
165 165
         // verify that requested step exists
166
-        if (! $this->collection->has($step)) {
166
+        if ( ! $this->collection->has($step)) {
167 167
             throw new InvalidIdentifierException($step, $this->default_step);
168 168
         }
169 169
         if ($this->collection->setCurrent($step)) {
Please login to merge, or discard this patch.
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -27,225 +27,225 @@
 block discarded – undo
27 27
 class ProgressStepManager
28 28
 {
29 29
 
30
-    /**
31
-     * @var ProgressStepInterface[]
32
-     */
33
-    private $collection;
34
-
35
-    /**
36
-     * @var string
37
-     */
38
-    private $default_step;
39
-
40
-    /**
41
-     * the key used for the URL param that denotes the current form step
42
-     * defaults to 'ee-form-step'
43
-     *
44
-     * @var string
45
-     */
46
-    private $form_step_url_key = '';
47
-
48
-    /**
49
-     * @var ProgressStepsDisplayInterface
50
-     */
51
-    private $display_strategy;
52
-
53
-    /**
54
-     * @var RequestInterface
55
-     */
56
-    private $request;
57
-
58
-
59
-    /**
60
-     * ProgressStepManager constructor
61
-     *
62
-     * @param string              $display_strategy_name
63
-     * @param string              $default_step
64
-     * @param string              $form_step_url_key
65
-     * @param CollectionInterface $collection
66
-     * @param RequestInterface    $request
67
-     */
68
-    public function __construct(
69
-        $display_strategy_name = 'number_bubbles',
70
-        $default_step = '',
71
-        $form_step_url_key = '',
72
-        CollectionInterface $collection = null,
73
-        RequestInterface $request = null
74
-    ) {
75
-        $this->setDisplayStrategy($display_strategy_name);
76
-        $this->setDefaultStep($default_step);
77
-        $this->setFormStepUrlKey($form_step_url_key);
78
-        if (! $collection instanceof CollectionInterface) {
79
-            $collection = new Collection('\EventEspresso\core\services\progress_steps\ProgressStepInterface');
80
-        }
81
-        $this->collection = $collection;
82
-        if (! $request instanceof RequestInterface) {
83
-            /** @var RequestInterface $request */
84
-            $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
85
-        }
86
-        $this->request = $request;
87
-    }
88
-
89
-
90
-    /**
91
-     * @param string $display_strategy_name
92
-     * @throws InvalidDataTypeException
93
-     * @throws InvalidClassException
94
-     */
95
-    protected function setDisplayStrategy($display_strategy_name = 'number_bubbles')
96
-    {
97
-        if (! is_string($display_strategy_name)) {
98
-            throw new InvalidDataTypeException('$display_strategy_name', $display_strategy_name, 'string');
99
-        }
100
-        // build up FQCN from incoming display strategy folder name
101
-        $display_strategy_class = 'EventEspresso\core\services\progress_steps\display_strategies\\';
102
-        $display_strategy_class .= $display_strategy_name . '\\';
103
-        $display_strategy_class .= str_replace(' ', '', ucwords(str_replace('_', ' ', $display_strategy_name)));
104
-        $display_strategy_class .= 'ProgressStepsDisplay';
105
-        $display_strategy_class = apply_filters(
106
-            'FHEE__ProgressStepManager__setDisplayStrategy__display_strategy_class',
107
-            $display_strategy_class
108
-        );
109
-        if (! class_exists($display_strategy_class)) {
110
-            throw new InvalidClassException($display_strategy_class);
111
-        }
112
-        $display_strategy = new $display_strategy_class();
113
-        if (! $display_strategy instanceof ProgressStepsDisplayInterface) {
114
-            throw new InvalidClassException(
115
-                $display_strategy_class,
116
-                sprintf(
117
-                    esc_html__('The "%1$s" Class needs to be an implementation of the "%1$s" Interface.', 'event_espresso'),
118
-                    $display_strategy_class,
119
-                    '\EventEspresso\core\services\progress_steps\display_strategies\ProgressStepsDisplayInterface'
120
-                )
121
-            );
122
-        }
123
-        $this->display_strategy = $display_strategy;
124
-    }
125
-
126
-
127
-    /**
128
-     * @param string $default_step
129
-     * @throws InvalidDataTypeException
130
-     */
131
-    public function setDefaultStep($default_step)
132
-    {
133
-        if (! is_string($default_step)) {
134
-            throw new InvalidDataTypeException('$default_step', $default_step, 'string');
135
-        }
136
-        $this->default_step = $default_step;
137
-    }
138
-
139
-
140
-    /**
141
-     * @param string $form_step_url_key
142
-     * @throws InvalidDataTypeException
143
-     */
144
-    public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
145
-    {
146
-        if (! is_string($form_step_url_key)) {
147
-            throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
148
-        }
149
-        $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
150
-    }
151
-
152
-
153
-    /**
154
-     * @param string $step
155
-     * @throws InvalidIdentifierException
156
-     */
157
-    public function setCurrentStep($step = '')
158
-    {
159
-        // use incoming value if it's set, otherwise use request param if it's set, otherwise use default
160
-        $step = ! empty($step)
161
-            ? $step
162
-            : $this->request->getRequestParam($this->form_step_url_key, $this->default_step);
163
-        // grab the step previously known as current, in case we need to revert
164
-        $current_current_step = $this->collection->current();
165
-        // verify that requested step exists
166
-        if (! $this->collection->has($step)) {
167
-            throw new InvalidIdentifierException($step, $this->default_step);
168
-        }
169
-        if ($this->collection->setCurrent($step)) {
170
-            // if the old boss is the same as the new boss, then nothing changes
171
-            if ($this->collection->current() !== $current_current_step) {
172
-                $current_current_step->setIsCurrent(false);
173
-            }
174
-            $this->collection->current()->setIsCurrent();
175
-        } else {
176
-            $this->collection->setCurrent($current_current_step->id());
177
-            $current_current_step->setIsCurrent(true);
178
-        }
179
-    }
180
-
181
-
182
-    /**
183
-     * setPreviousStepsCompleted
184
-     */
185
-    public function setPreviousStepsCompleted()
186
-    {
187
-        $current_current_step = $this->collection->current();
188
-        $this->collection->rewind();
189
-        while ($this->collection->valid()) {
190
-            if ($this->collection->current() === $current_current_step) {
191
-                break;
192
-            }
193
-            $this->setCurrentStepCompleted();
194
-            $this->collection->next();
195
-        }
196
-        $this->collection->setCurrentUsingObject($current_current_step);
197
-        return false;
198
-    }
199
-
200
-
201
-    /**
202
-     * @return ProgressStepInterface
203
-     */
204
-    public function currentStep()
205
-    {
206
-        return $this->collection->current();
207
-    }
208
-
209
-
210
-    /**
211
-     * @return ProgressStepInterface
212
-     */
213
-    public function nextStep()
214
-    {
215
-        return $this->collection->next();
216
-    }
217
-
218
-
219
-    /**
220
-     * @return void
221
-     */
222
-    public function enqueueStylesAndScripts()
223
-    {
224
-        $this->display_strategy->enqueueStylesAndScripts();
225
-    }
226
-
227
-
228
-    /**
229
-     * echos out HTML
230
-     *
231
-     * @return string
232
-     */
233
-    public function displaySteps()
234
-    {
235
-        return EEH_Template::display_template(
236
-            $this->display_strategy->getTemplate(),
237
-            array('progress_steps' => $this->collection),
238
-            true
239
-        );
240
-    }
241
-
242
-
243
-    /**
244
-     * @param bool $completed
245
-     * @return ProgressStepInterface
246
-     */
247
-    public function setCurrentStepCompleted($completed = true)
248
-    {
249
-        return $this->collection->current()->setIsCompleted($completed);
250
-    }
30
+	/**
31
+	 * @var ProgressStepInterface[]
32
+	 */
33
+	private $collection;
34
+
35
+	/**
36
+	 * @var string
37
+	 */
38
+	private $default_step;
39
+
40
+	/**
41
+	 * the key used for the URL param that denotes the current form step
42
+	 * defaults to 'ee-form-step'
43
+	 *
44
+	 * @var string
45
+	 */
46
+	private $form_step_url_key = '';
47
+
48
+	/**
49
+	 * @var ProgressStepsDisplayInterface
50
+	 */
51
+	private $display_strategy;
52
+
53
+	/**
54
+	 * @var RequestInterface
55
+	 */
56
+	private $request;
57
+
58
+
59
+	/**
60
+	 * ProgressStepManager constructor
61
+	 *
62
+	 * @param string              $display_strategy_name
63
+	 * @param string              $default_step
64
+	 * @param string              $form_step_url_key
65
+	 * @param CollectionInterface $collection
66
+	 * @param RequestInterface    $request
67
+	 */
68
+	public function __construct(
69
+		$display_strategy_name = 'number_bubbles',
70
+		$default_step = '',
71
+		$form_step_url_key = '',
72
+		CollectionInterface $collection = null,
73
+		RequestInterface $request = null
74
+	) {
75
+		$this->setDisplayStrategy($display_strategy_name);
76
+		$this->setDefaultStep($default_step);
77
+		$this->setFormStepUrlKey($form_step_url_key);
78
+		if (! $collection instanceof CollectionInterface) {
79
+			$collection = new Collection('\EventEspresso\core\services\progress_steps\ProgressStepInterface');
80
+		}
81
+		$this->collection = $collection;
82
+		if (! $request instanceof RequestInterface) {
83
+			/** @var RequestInterface $request */
84
+			$request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
85
+		}
86
+		$this->request = $request;
87
+	}
88
+
89
+
90
+	/**
91
+	 * @param string $display_strategy_name
92
+	 * @throws InvalidDataTypeException
93
+	 * @throws InvalidClassException
94
+	 */
95
+	protected function setDisplayStrategy($display_strategy_name = 'number_bubbles')
96
+	{
97
+		if (! is_string($display_strategy_name)) {
98
+			throw new InvalidDataTypeException('$display_strategy_name', $display_strategy_name, 'string');
99
+		}
100
+		// build up FQCN from incoming display strategy folder name
101
+		$display_strategy_class = 'EventEspresso\core\services\progress_steps\display_strategies\\';
102
+		$display_strategy_class .= $display_strategy_name . '\\';
103
+		$display_strategy_class .= str_replace(' ', '', ucwords(str_replace('_', ' ', $display_strategy_name)));
104
+		$display_strategy_class .= 'ProgressStepsDisplay';
105
+		$display_strategy_class = apply_filters(
106
+			'FHEE__ProgressStepManager__setDisplayStrategy__display_strategy_class',
107
+			$display_strategy_class
108
+		);
109
+		if (! class_exists($display_strategy_class)) {
110
+			throw new InvalidClassException($display_strategy_class);
111
+		}
112
+		$display_strategy = new $display_strategy_class();
113
+		if (! $display_strategy instanceof ProgressStepsDisplayInterface) {
114
+			throw new InvalidClassException(
115
+				$display_strategy_class,
116
+				sprintf(
117
+					esc_html__('The "%1$s" Class needs to be an implementation of the "%1$s" Interface.', 'event_espresso'),
118
+					$display_strategy_class,
119
+					'\EventEspresso\core\services\progress_steps\display_strategies\ProgressStepsDisplayInterface'
120
+				)
121
+			);
122
+		}
123
+		$this->display_strategy = $display_strategy;
124
+	}
125
+
126
+
127
+	/**
128
+	 * @param string $default_step
129
+	 * @throws InvalidDataTypeException
130
+	 */
131
+	public function setDefaultStep($default_step)
132
+	{
133
+		if (! is_string($default_step)) {
134
+			throw new InvalidDataTypeException('$default_step', $default_step, 'string');
135
+		}
136
+		$this->default_step = $default_step;
137
+	}
138
+
139
+
140
+	/**
141
+	 * @param string $form_step_url_key
142
+	 * @throws InvalidDataTypeException
143
+	 */
144
+	public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
145
+	{
146
+		if (! is_string($form_step_url_key)) {
147
+			throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
148
+		}
149
+		$this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
150
+	}
151
+
152
+
153
+	/**
154
+	 * @param string $step
155
+	 * @throws InvalidIdentifierException
156
+	 */
157
+	public function setCurrentStep($step = '')
158
+	{
159
+		// use incoming value if it's set, otherwise use request param if it's set, otherwise use default
160
+		$step = ! empty($step)
161
+			? $step
162
+			: $this->request->getRequestParam($this->form_step_url_key, $this->default_step);
163
+		// grab the step previously known as current, in case we need to revert
164
+		$current_current_step = $this->collection->current();
165
+		// verify that requested step exists
166
+		if (! $this->collection->has($step)) {
167
+			throw new InvalidIdentifierException($step, $this->default_step);
168
+		}
169
+		if ($this->collection->setCurrent($step)) {
170
+			// if the old boss is the same as the new boss, then nothing changes
171
+			if ($this->collection->current() !== $current_current_step) {
172
+				$current_current_step->setIsCurrent(false);
173
+			}
174
+			$this->collection->current()->setIsCurrent();
175
+		} else {
176
+			$this->collection->setCurrent($current_current_step->id());
177
+			$current_current_step->setIsCurrent(true);
178
+		}
179
+	}
180
+
181
+
182
+	/**
183
+	 * setPreviousStepsCompleted
184
+	 */
185
+	public function setPreviousStepsCompleted()
186
+	{
187
+		$current_current_step = $this->collection->current();
188
+		$this->collection->rewind();
189
+		while ($this->collection->valid()) {
190
+			if ($this->collection->current() === $current_current_step) {
191
+				break;
192
+			}
193
+			$this->setCurrentStepCompleted();
194
+			$this->collection->next();
195
+		}
196
+		$this->collection->setCurrentUsingObject($current_current_step);
197
+		return false;
198
+	}
199
+
200
+
201
+	/**
202
+	 * @return ProgressStepInterface
203
+	 */
204
+	public function currentStep()
205
+	{
206
+		return $this->collection->current();
207
+	}
208
+
209
+
210
+	/**
211
+	 * @return ProgressStepInterface
212
+	 */
213
+	public function nextStep()
214
+	{
215
+		return $this->collection->next();
216
+	}
217
+
218
+
219
+	/**
220
+	 * @return void
221
+	 */
222
+	public function enqueueStylesAndScripts()
223
+	{
224
+		$this->display_strategy->enqueueStylesAndScripts();
225
+	}
226
+
227
+
228
+	/**
229
+	 * echos out HTML
230
+	 *
231
+	 * @return string
232
+	 */
233
+	public function displaySteps()
234
+	{
235
+		return EEH_Template::display_template(
236
+			$this->display_strategy->getTemplate(),
237
+			array('progress_steps' => $this->collection),
238
+			true
239
+		);
240
+	}
241
+
242
+
243
+	/**
244
+	 * @param bool $completed
245
+	 * @return ProgressStepInterface
246
+	 */
247
+	public function setCurrentStepCompleted($completed = true)
248
+	{
249
+		return $this->collection->current()->setIsCompleted($completed);
250
+	}
251 251
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/form_handlers/SequentialStepFormManager.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      */
141 141
     protected function setBaseUrl($base_url)
142 142
     {
143
-        if (! is_string($base_url)) {
143
+        if ( ! is_string($base_url)) {
144 144
             throw new InvalidDataTypeException('$base_url', $base_url, 'string');
145 145
         }
146 146
         if (empty($base_url)) {
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      */
172 172
     public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
173 173
     {
174
-        if (! is_string($form_step_url_key)) {
174
+        if ( ! is_string($form_step_url_key)) {
175 175
             throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
176 176
         }
177 177
         $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      */
194 194
     protected function setDefaultFormStep($default_form_step)
195 195
     {
196
-        if (! is_string($default_form_step)) {
196
+        if ( ! is_string($default_form_step)) {
197 197
             throw new InvalidDataTypeException('$default_form_step', $default_form_step, 'string');
198 198
         }
199 199
         $this->default_form_step = $default_form_step;
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
     protected function setCurrentStepFromRequest()
209 209
     {
210 210
         $current_step_slug = $this->request()->getRequestParam($this->formStepUrlKey(), $this->defaultFormStep());
211
-        if (! $this->form_steps->setCurrent($current_step_slug)) {
211
+        if ( ! $this->form_steps->setCurrent($current_step_slug)) {
212 212
             throw new InvalidIdentifierException(
213 213
                 $current_step_slug,
214 214
                 $this->defaultFormStep(),
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
      */
228 228
     public function getCurrentStep()
229 229
     {
230
-        if (! $this->form_steps->current() instanceof SequentialStepForm) {
230
+        if ( ! $this->form_steps->current() instanceof SequentialStepForm) {
231 231
             throw new InvalidFormHandlerException($this->form_steps->current());
232 232
         }
233 233
         return $this->form_steps->current();
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
      */
241 241
     public function formAction()
242 242
     {
243
-        if (! is_string($this->form_action) || empty($this->form_action)) {
243
+        if ( ! is_string($this->form_action) || empty($this->form_action)) {
244 244
             $this->form_action = $this->baseUrl();
245 245
         }
246 246
         return $this->form_action;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
      */
254 254
     public function setFormAction($form_action)
255 255
     {
256
-        if (! is_string($form_action)) {
256
+        if ( ! is_string($form_action)) {
257 257
             throw new InvalidDataTypeException('$form_action', $form_action, 'string');
258 258
         }
259 259
         $this->form_action = $form_action;
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
      */
268 268
     public function addFormActionArgs($form_action_args = array())
269 269
     {
270
-        if (! is_array($form_action_args)) {
270
+        if ( ! is_array($form_action_args)) {
271 271
             throw new InvalidDataTypeException('$form_action_args', $form_action_args, 'array');
272 272
         }
273 273
         $form_action_args = ! empty($form_action_args)
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
     protected function getProgressStepsCollection()
333 333
     {
334 334
         static $collection = null;
335
-        if (! $collection instanceof ProgressStepCollection) {
335
+        if ( ! $collection instanceof ProgressStepCollection) {
336 336
             $collection = new ProgressStepCollection();
337 337
         }
338 338
         return $collection;
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
         /** @var SequentialStepForm $form_step */
355 355
         foreach ($this->form_steps as $form_step) {
356 356
             // is this step active ?
357
-            if (! $form_step->initialize()) {
357
+            if ( ! $form_step->initialize()) {
358 358
                 continue;
359 359
             }
360 360
             $progress_steps_collection->add(
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
     {
424 424
         $form_step = $this->buildCurrentStepForm();
425 425
         // no displayable content ? then skip straight to processing
426
-        if (! $form_step->displayable()) {
426
+        if ( ! $form_step->displayable()) {
427 427
             $this->addFormActionArgs();
428 428
             $form_step->setFormAction($this->formAction());
429 429
             wp_safe_redirect($form_step->formAction());
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
     public function displayProgressSteps($return_as_string = true)
500 500
     {
501 501
         $form_step = $this->getCurrentStep();
502
-        if (! $form_step->displayable()) {
502
+        if ( ! $form_step->displayable()) {
503 503
             return '';
504 504
         }
505 505
         $progress_steps = apply_filters(
Please login to merge, or discard this patch.
Indentation   +579 added lines, -579 removed lines patch added patch discarded remove patch
@@ -30,583 +30,583 @@
 block discarded – undo
30 30
 abstract class SequentialStepFormManager
31 31
 {
32 32
 
33
-    /**
34
-     * a simplified URL with no form related parameters
35
-     * that will be used to build the form's redirect URLs
36
-     *
37
-     * @var string $base_url
38
-     */
39
-    private $base_url = '';
40
-
41
-    /**
42
-     * the key used for the URL param that denotes the current form step
43
-     * defaults to 'ee-form-step'
44
-     *
45
-     * @var string $form_step_url_key
46
-     */
47
-    private $form_step_url_key = '';
48
-
49
-    /**
50
-     * @var string $default_form_step
51
-     */
52
-    private $default_form_step = '';
53
-
54
-    /**
55
-     * @var string $form_action
56
-     */
57
-    private $form_action;
58
-
59
-    /**
60
-     * value of one of the string constant above
61
-     *
62
-     * @var string $form_config
63
-     */
64
-    private $form_config;
65
-
66
-    /**
67
-     * @var string $progress_step_style
68
-     */
69
-    private $progress_step_style = '';
70
-
71
-    /**
72
-     * @var RequestInterface $request
73
-     */
74
-    private $request;
75
-
76
-    /**
77
-     * @var Collection $form_steps
78
-     */
79
-    protected $form_steps;
80
-
81
-    /**
82
-     * @var ProgressStepManager $progress_step_manager
83
-     */
84
-    protected $progress_step_manager;
85
-
86
-
87
-    /**
88
-     * @return Collection|null
89
-     */
90
-    abstract protected function getFormStepsCollection();
91
-
92
-    // phpcs:disable PEAR.Functions.ValidDefaultValue.NotAtEnd
93
-    /**
94
-     * StepsManager constructor
95
-     *
96
-     * @param string                           $base_url
97
-     * @param string                           $default_form_step
98
-     * @param string                           $form_action
99
-     * @param string                           $form_config
100
-     * @param EE_Request|RequestInterface|null $request
101
-     * @param string                           $progress_step_style
102
-     * @throws InvalidDataTypeException
103
-     * @throws InvalidArgumentException
104
-     */
105
-    public function __construct(
106
-        $base_url,
107
-        $default_form_step,
108
-        $form_action = '',
109
-        $form_config = FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
110
-        $progress_step_style = 'number_bubbles',
111
-        $request = null
112
-    ) {
113
-        $this->setBaseUrl($base_url);
114
-        $this->setDefaultFormStep($default_form_step);
115
-        $this->setFormAction($form_action);
116
-        $this->setFormConfig($form_config);
117
-        $this->setProgressStepStyle($progress_step_style);
118
-        $this->request = $request instanceof RequestInterface
119
-            ? $request
120
-            : LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
121
-    }
122
-
123
-
124
-    /**
125
-     * @return string
126
-     * @throws InvalidFormHandlerException
127
-     */
128
-    public function baseUrl()
129
-    {
130
-        if (strpos($this->base_url, $this->getCurrentStep()->slug()) === false) {
131
-            add_query_arg(
132
-                array($this->form_step_url_key => $this->getCurrentStep()->slug()),
133
-                $this->base_url
134
-            );
135
-        }
136
-        return $this->base_url;
137
-    }
138
-
139
-
140
-    /**
141
-     * @param string $base_url
142
-     * @throws InvalidDataTypeException
143
-     * @throws InvalidArgumentException
144
-     */
145
-    protected function setBaseUrl($base_url)
146
-    {
147
-        if (! is_string($base_url)) {
148
-            throw new InvalidDataTypeException('$base_url', $base_url, 'string');
149
-        }
150
-        if (empty($base_url)) {
151
-            throw new InvalidArgumentException(
152
-                esc_html__('The base URL can not be an empty string.', 'event_espresso')
153
-            );
154
-        }
155
-        $this->base_url = $base_url;
156
-    }
157
-
158
-
159
-    /**
160
-     * @return string
161
-     * @throws InvalidDataTypeException
162
-     */
163
-    public function formStepUrlKey()
164
-    {
165
-        if (empty($this->form_step_url_key)) {
166
-            $this->setFormStepUrlKey();
167
-        }
168
-        return $this->form_step_url_key;
169
-    }
170
-
171
-
172
-    /**
173
-     * @param string $form_step_url_key
174
-     * @throws InvalidDataTypeException
175
-     */
176
-    public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
177
-    {
178
-        if (! is_string($form_step_url_key)) {
179
-            throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
180
-        }
181
-        $this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
182
-    }
183
-
184
-
185
-    /**
186
-     * @return string
187
-     */
188
-    public function defaultFormStep()
189
-    {
190
-        return $this->default_form_step;
191
-    }
192
-
193
-
194
-    /**
195
-     * @param $default_form_step
196
-     * @throws InvalidDataTypeException
197
-     */
198
-    protected function setDefaultFormStep($default_form_step)
199
-    {
200
-        if (! is_string($default_form_step)) {
201
-            throw new InvalidDataTypeException('$default_form_step', $default_form_step, 'string');
202
-        }
203
-        $this->default_form_step = $default_form_step;
204
-    }
205
-
206
-
207
-    /**
208
-     * @return void
209
-     * @throws InvalidIdentifierException
210
-     * @throws InvalidDataTypeException
211
-     */
212
-    protected function setCurrentStepFromRequest()
213
-    {
214
-        $current_step_slug = $this->request()->getRequestParam($this->formStepUrlKey(), $this->defaultFormStep());
215
-        if (! $this->form_steps->setCurrent($current_step_slug)) {
216
-            throw new InvalidIdentifierException(
217
-                $current_step_slug,
218
-                $this->defaultFormStep(),
219
-                sprintf(
220
-                    esc_html__('The "%1$s" form step could not be set.', 'event_espresso'),
221
-                    $current_step_slug
222
-                )
223
-            );
224
-        }
225
-    }
226
-
227
-
228
-    /**
229
-     * @return SequentialStepFormInterface|object
230
-     * @throws InvalidFormHandlerException
231
-     */
232
-    public function getCurrentStep()
233
-    {
234
-        if (! $this->form_steps->current() instanceof SequentialStepForm) {
235
-            throw new InvalidFormHandlerException($this->form_steps->current());
236
-        }
237
-        return $this->form_steps->current();
238
-    }
239
-
240
-
241
-    /**
242
-     * @return string
243
-     * @throws InvalidFormHandlerException
244
-     */
245
-    public function formAction()
246
-    {
247
-        if (! is_string($this->form_action) || empty($this->form_action)) {
248
-            $this->form_action = $this->baseUrl();
249
-        }
250
-        return $this->form_action;
251
-    }
252
-
253
-
254
-    /**
255
-     * @param string $form_action
256
-     * @throws InvalidDataTypeException
257
-     */
258
-    public function setFormAction($form_action)
259
-    {
260
-        if (! is_string($form_action)) {
261
-            throw new InvalidDataTypeException('$form_action', $form_action, 'string');
262
-        }
263
-        $this->form_action = $form_action;
264
-    }
265
-
266
-
267
-    /**
268
-     * @param array $form_action_args
269
-     * @throws InvalidDataTypeException
270
-     * @throws InvalidFormHandlerException
271
-     */
272
-    public function addFormActionArgs($form_action_args = array())
273
-    {
274
-        if (! is_array($form_action_args)) {
275
-            throw new InvalidDataTypeException('$form_action_args', $form_action_args, 'array');
276
-        }
277
-        $form_action_args = ! empty($form_action_args)
278
-            ? $form_action_args
279
-            : array($this->formStepUrlKey() => $this->form_steps->current()->slug());
280
-        $this->getCurrentStep()->setFormAction(
281
-            add_query_arg($form_action_args, $this->formAction())
282
-        );
283
-        $this->form_action = $this->getCurrentStep()->formAction();
284
-    }
285
-
286
-
287
-    /**
288
-     * @return string
289
-     */
290
-    public function formConfig()
291
-    {
292
-        return $this->form_config;
293
-    }
294
-
295
-
296
-    /**
297
-     * @param string $form_config
298
-     */
299
-    public function setFormConfig($form_config)
300
-    {
301
-        $this->form_config = $form_config;
302
-    }
303
-
304
-
305
-    /**
306
-     * @return string
307
-     */
308
-    public function progressStepStyle()
309
-    {
310
-        return $this->progress_step_style;
311
-    }
312
-
313
-
314
-    /**
315
-     * @param string $progress_step_style
316
-     */
317
-    public function setProgressStepStyle($progress_step_style)
318
-    {
319
-        $this->progress_step_style = $progress_step_style;
320
-    }
321
-
322
-
323
-    /**
324
-     * @return RequestInterface
325
-     */
326
-    public function request()
327
-    {
328
-        return $this->request;
329
-    }
330
-
331
-
332
-    /**
333
-     * @return Collection|null
334
-     * @throws InvalidInterfaceException
335
-     */
336
-    protected function getProgressStepsCollection()
337
-    {
338
-        static $collection = null;
339
-        if (! $collection instanceof ProgressStepCollection) {
340
-            $collection = new ProgressStepCollection();
341
-        }
342
-        return $collection;
343
-    }
344
-
345
-
346
-    /**
347
-     * @param Collection $progress_steps_collection
348
-     * @return ProgressStepManager
349
-     * @throws InvalidInterfaceException
350
-     * @throws InvalidClassException
351
-     * @throws InvalidDataTypeException
352
-     * @throws InvalidEntityException
353
-     * @throws InvalidFormHandlerException
354
-     */
355
-    protected function generateProgressSteps(Collection $progress_steps_collection)
356
-    {
357
-        $current_step = $this->getCurrentStep();
358
-        /** @var SequentialStepForm $form_step */
359
-        foreach ($this->form_steps as $form_step) {
360
-            // is this step active ?
361
-            if (! $form_step->initialize()) {
362
-                continue;
363
-            }
364
-            $progress_steps_collection->add(
365
-                new ProgressStep(
366
-                    $form_step->order(),
367
-                    $form_step->slug(),
368
-                    $form_step->slug(),
369
-                    $form_step->formName()
370
-                ),
371
-                $form_step->slug()
372
-            );
373
-        }
374
-        // set collection pointer back to current step
375
-        $this->form_steps->setCurrentUsingObject($current_step);
376
-        return new ProgressStepManager(
377
-            $this->progressStepStyle(),
378
-            $this->defaultFormStep(),
379
-            $this->formStepUrlKey(),
380
-            $progress_steps_collection
381
-        );
382
-    }
383
-
384
-
385
-    /**
386
-     * @throws InvalidClassException
387
-     * @throws InvalidDataTypeException
388
-     * @throws InvalidEntityException
389
-     * @throws InvalidIdentifierException
390
-     * @throws InvalidInterfaceException
391
-     * @throws InvalidArgumentException
392
-     * @throws InvalidFormHandlerException
393
-     */
394
-    public function buildForm()
395
-    {
396
-        $this->buildCurrentStepFormForDisplay();
397
-    }
398
-
399
-
400
-    /**
401
-     * @param array $form_data
402
-     * @throws InvalidArgumentException
403
-     * @throws InvalidClassException
404
-     * @throws InvalidDataTypeException
405
-     * @throws InvalidEntityException
406
-     * @throws InvalidFormHandlerException
407
-     * @throws InvalidIdentifierException
408
-     * @throws InvalidInterfaceException
409
-     */
410
-    public function processForm($form_data = array())
411
-    {
412
-        $this->buildCurrentStepFormForProcessing();
413
-        $this->processCurrentStepForm($form_data);
414
-    }
415
-
416
-
417
-    /**
418
-     * @throws InvalidClassException
419
-     * @throws InvalidDataTypeException
420
-     * @throws InvalidEntityException
421
-     * @throws InvalidInterfaceException
422
-     * @throws InvalidIdentifierException
423
-     * @throws InvalidArgumentException
424
-     * @throws InvalidFormHandlerException
425
-     */
426
-    public function buildCurrentStepFormForDisplay()
427
-    {
428
-        $form_step = $this->buildCurrentStepForm();
429
-        // no displayable content ? then skip straight to processing
430
-        if (! $form_step->displayable()) {
431
-            $this->addFormActionArgs();
432
-            $form_step->setFormAction($this->formAction());
433
-            wp_safe_redirect($form_step->formAction());
434
-        }
435
-    }
436
-
437
-
438
-    /**
439
-     * @throws InvalidClassException
440
-     * @throws InvalidDataTypeException
441
-     * @throws InvalidEntityException
442
-     * @throws InvalidInterfaceException
443
-     * @throws InvalidIdentifierException
444
-     * @throws InvalidArgumentException
445
-     * @throws InvalidFormHandlerException
446
-     */
447
-    public function buildCurrentStepFormForProcessing()
448
-    {
449
-        $this->buildCurrentStepForm(false);
450
-    }
451
-
452
-
453
-    /**
454
-     * @param bool $for_display
455
-     * @return SequentialStepFormInterface
456
-     * @throws InvalidArgumentException
457
-     * @throws InvalidClassException
458
-     * @throws InvalidDataTypeException
459
-     * @throws InvalidEntityException
460
-     * @throws InvalidFormHandlerException
461
-     * @throws InvalidIdentifierException
462
-     * @throws InvalidInterfaceException
463
-     */
464
-    private function buildCurrentStepForm($for_display = true)
465
-    {
466
-        $this->form_steps = $this->getFormStepsCollection();
467
-        $this->setCurrentStepFromRequest();
468
-        $form_step = $this->getCurrentStep();
469
-        if ($form_step->submitBtnText() === esc_html__('Submit', 'event_espresso')) {
470
-            $form_step->setSubmitBtnText(esc_html__('Next Step', 'event_espresso'));
471
-        }
472
-        if ($for_display && $form_step->displayable()) {
473
-            $this->progress_step_manager = $this->generateProgressSteps(
474
-                $this->getProgressStepsCollection()
475
-            );
476
-            $this->progress_step_manager->setCurrentStep(
477
-                $form_step->slug()
478
-            );
479
-            // mark all previous progress steps as completed
480
-            $this->progress_step_manager->setPreviousStepsCompleted();
481
-            $this->progress_step_manager->enqueueStylesAndScripts();
482
-            $this->addFormActionArgs();
483
-            $form_step->setFormAction($this->formAction());
484
-        } else {
485
-            $form_step->setRedirectUrl($this->baseUrl());
486
-            $form_step->addRedirectArgs(
487
-                array($this->formStepUrlKey() => $this->form_steps->current()->slug())
488
-            );
489
-        }
490
-        $form_step->generate();
491
-        if ($for_display) {
492
-            $form_step->enqueueStylesAndScripts();
493
-        }
494
-        return $form_step;
495
-    }
496
-
497
-
498
-    /**
499
-     * @param bool $return_as_string
500
-     * @return string
501
-     * @throws InvalidFormHandlerException
502
-     */
503
-    public function displayProgressSteps($return_as_string = true)
504
-    {
505
-        $form_step = $this->getCurrentStep();
506
-        if (! $form_step->displayable()) {
507
-            return '';
508
-        }
509
-        $progress_steps = apply_filters(
510
-            'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__before_steps',
511
-            ''
512
-        );
513
-        $progress_steps .= $this->progress_step_manager->displaySteps();
514
-        $progress_steps .= apply_filters(
515
-            'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__after_steps',
516
-            ''
517
-        );
518
-        if ($return_as_string) {
519
-            return $progress_steps;
520
-        }
521
-        echo $progress_steps; // already escaped
522
-        return '';
523
-    }
524
-
525
-
526
-    /**
527
-     * @param bool $return_as_string
528
-     * @return string
529
-     * @throws InvalidFormHandlerException
530
-     */
531
-    public function displayCurrentStepForm($return_as_string = true)
532
-    {
533
-        if ($return_as_string) {
534
-            return $this->getCurrentStep()->display();
535
-        }
536
-        echo $this->getCurrentStep()->display(); // already escaped
537
-        return '';
538
-    }
539
-
540
-
541
-    /**
542
-     * @param array $form_data
543
-     * @return void
544
-     * @throws InvalidArgumentException
545
-     * @throws InvalidDataTypeException
546
-     * @throws InvalidFormHandlerException
547
-     */
548
-    public function processCurrentStepForm($form_data = array())
549
-    {
550
-        // grab instance of current step because after calling next() below,
551
-        // any calls to getCurrentStep() will return the "next" step because we advanced
552
-        $current_step = $this->getCurrentStep();
553
-        try {
554
-            // form processing should either throw exceptions or return true
555
-            $current_step->process($form_data);
556
-        } catch (Exception $e) {
557
-            // something went wrong, convert the Exception to an EE_Error
558
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
559
-            // prevent redirect to next step or other if exception was thrown
560
-            if (
561
-                $current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_NEXT_STEP
562
-                || $current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_OTHER
563
-            ) {
564
-                $current_step->setRedirectTo(SequentialStepForm::REDIRECT_TO_CURRENT_STEP);
565
-            }
566
-        }
567
-        // save notices to a transient so that when we redirect back
568
-        // to the display portion for this step
569
-        // those notices can be displayed
570
-        EE_Error::get_notices(false, true);
571
-        $this->redirectForm($current_step);
572
-    }
573
-
574
-
575
-    /**
576
-     * handles where to go to next
577
-     *
578
-     * @param SequentialStepFormInterface $current_step
579
-     * @throws InvalidArgumentException
580
-     * @throws InvalidDataTypeException
581
-     * @throws InvalidFormHandlerException
582
-     */
583
-    public function redirectForm(SequentialStepFormInterface $current_step)
584
-    {
585
-        $redirect_step = $current_step;
586
-        switch ($current_step->redirectTo()) {
587
-            case SequentialStepForm::REDIRECT_TO_OTHER:
588
-                // going somewhere else, so just check out now
589
-                wp_safe_redirect($redirect_step->redirectUrl());
590
-                exit();
591
-            case SequentialStepForm::REDIRECT_TO_PREV_STEP:
592
-                $redirect_step = $this->form_steps->previous();
593
-                break;
594
-            case SequentialStepForm::REDIRECT_TO_NEXT_STEP:
595
-                $this->form_steps->next();
596
-                if ($this->form_steps->valid()) {
597
-                    $redirect_step = $this->form_steps->current();
598
-                }
599
-                break;
600
-            case SequentialStepForm::REDIRECT_TO_CURRENT_STEP:
601
-            default:
602
-                // $redirect_step is already set
603
-        }
604
-        $current_step->setRedirectUrl($this->baseUrl());
605
-        $current_step->addRedirectArgs(
606
-            // use the slug for whatever step we are redirecting too
607
-            array($this->formStepUrlKey() => $redirect_step->slug())
608
-        );
609
-        wp_safe_redirect($current_step->redirectUrl());
610
-        exit();
611
-    }
33
+	/**
34
+	 * a simplified URL with no form related parameters
35
+	 * that will be used to build the form's redirect URLs
36
+	 *
37
+	 * @var string $base_url
38
+	 */
39
+	private $base_url = '';
40
+
41
+	/**
42
+	 * the key used for the URL param that denotes the current form step
43
+	 * defaults to 'ee-form-step'
44
+	 *
45
+	 * @var string $form_step_url_key
46
+	 */
47
+	private $form_step_url_key = '';
48
+
49
+	/**
50
+	 * @var string $default_form_step
51
+	 */
52
+	private $default_form_step = '';
53
+
54
+	/**
55
+	 * @var string $form_action
56
+	 */
57
+	private $form_action;
58
+
59
+	/**
60
+	 * value of one of the string constant above
61
+	 *
62
+	 * @var string $form_config
63
+	 */
64
+	private $form_config;
65
+
66
+	/**
67
+	 * @var string $progress_step_style
68
+	 */
69
+	private $progress_step_style = '';
70
+
71
+	/**
72
+	 * @var RequestInterface $request
73
+	 */
74
+	private $request;
75
+
76
+	/**
77
+	 * @var Collection $form_steps
78
+	 */
79
+	protected $form_steps;
80
+
81
+	/**
82
+	 * @var ProgressStepManager $progress_step_manager
83
+	 */
84
+	protected $progress_step_manager;
85
+
86
+
87
+	/**
88
+	 * @return Collection|null
89
+	 */
90
+	abstract protected function getFormStepsCollection();
91
+
92
+	// phpcs:disable PEAR.Functions.ValidDefaultValue.NotAtEnd
93
+	/**
94
+	 * StepsManager constructor
95
+	 *
96
+	 * @param string                           $base_url
97
+	 * @param string                           $default_form_step
98
+	 * @param string                           $form_action
99
+	 * @param string                           $form_config
100
+	 * @param EE_Request|RequestInterface|null $request
101
+	 * @param string                           $progress_step_style
102
+	 * @throws InvalidDataTypeException
103
+	 * @throws InvalidArgumentException
104
+	 */
105
+	public function __construct(
106
+		$base_url,
107
+		$default_form_step,
108
+		$form_action = '',
109
+		$form_config = FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
110
+		$progress_step_style = 'number_bubbles',
111
+		$request = null
112
+	) {
113
+		$this->setBaseUrl($base_url);
114
+		$this->setDefaultFormStep($default_form_step);
115
+		$this->setFormAction($form_action);
116
+		$this->setFormConfig($form_config);
117
+		$this->setProgressStepStyle($progress_step_style);
118
+		$this->request = $request instanceof RequestInterface
119
+			? $request
120
+			: LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
121
+	}
122
+
123
+
124
+	/**
125
+	 * @return string
126
+	 * @throws InvalidFormHandlerException
127
+	 */
128
+	public function baseUrl()
129
+	{
130
+		if (strpos($this->base_url, $this->getCurrentStep()->slug()) === false) {
131
+			add_query_arg(
132
+				array($this->form_step_url_key => $this->getCurrentStep()->slug()),
133
+				$this->base_url
134
+			);
135
+		}
136
+		return $this->base_url;
137
+	}
138
+
139
+
140
+	/**
141
+	 * @param string $base_url
142
+	 * @throws InvalidDataTypeException
143
+	 * @throws InvalidArgumentException
144
+	 */
145
+	protected function setBaseUrl($base_url)
146
+	{
147
+		if (! is_string($base_url)) {
148
+			throw new InvalidDataTypeException('$base_url', $base_url, 'string');
149
+		}
150
+		if (empty($base_url)) {
151
+			throw new InvalidArgumentException(
152
+				esc_html__('The base URL can not be an empty string.', 'event_espresso')
153
+			);
154
+		}
155
+		$this->base_url = $base_url;
156
+	}
157
+
158
+
159
+	/**
160
+	 * @return string
161
+	 * @throws InvalidDataTypeException
162
+	 */
163
+	public function formStepUrlKey()
164
+	{
165
+		if (empty($this->form_step_url_key)) {
166
+			$this->setFormStepUrlKey();
167
+		}
168
+		return $this->form_step_url_key;
169
+	}
170
+
171
+
172
+	/**
173
+	 * @param string $form_step_url_key
174
+	 * @throws InvalidDataTypeException
175
+	 */
176
+	public function setFormStepUrlKey($form_step_url_key = 'ee-form-step')
177
+	{
178
+		if (! is_string($form_step_url_key)) {
179
+			throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
180
+		}
181
+		$this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
182
+	}
183
+
184
+
185
+	/**
186
+	 * @return string
187
+	 */
188
+	public function defaultFormStep()
189
+	{
190
+		return $this->default_form_step;
191
+	}
192
+
193
+
194
+	/**
195
+	 * @param $default_form_step
196
+	 * @throws InvalidDataTypeException
197
+	 */
198
+	protected function setDefaultFormStep($default_form_step)
199
+	{
200
+		if (! is_string($default_form_step)) {
201
+			throw new InvalidDataTypeException('$default_form_step', $default_form_step, 'string');
202
+		}
203
+		$this->default_form_step = $default_form_step;
204
+	}
205
+
206
+
207
+	/**
208
+	 * @return void
209
+	 * @throws InvalidIdentifierException
210
+	 * @throws InvalidDataTypeException
211
+	 */
212
+	protected function setCurrentStepFromRequest()
213
+	{
214
+		$current_step_slug = $this->request()->getRequestParam($this->formStepUrlKey(), $this->defaultFormStep());
215
+		if (! $this->form_steps->setCurrent($current_step_slug)) {
216
+			throw new InvalidIdentifierException(
217
+				$current_step_slug,
218
+				$this->defaultFormStep(),
219
+				sprintf(
220
+					esc_html__('The "%1$s" form step could not be set.', 'event_espresso'),
221
+					$current_step_slug
222
+				)
223
+			);
224
+		}
225
+	}
226
+
227
+
228
+	/**
229
+	 * @return SequentialStepFormInterface|object
230
+	 * @throws InvalidFormHandlerException
231
+	 */
232
+	public function getCurrentStep()
233
+	{
234
+		if (! $this->form_steps->current() instanceof SequentialStepForm) {
235
+			throw new InvalidFormHandlerException($this->form_steps->current());
236
+		}
237
+		return $this->form_steps->current();
238
+	}
239
+
240
+
241
+	/**
242
+	 * @return string
243
+	 * @throws InvalidFormHandlerException
244
+	 */
245
+	public function formAction()
246
+	{
247
+		if (! is_string($this->form_action) || empty($this->form_action)) {
248
+			$this->form_action = $this->baseUrl();
249
+		}
250
+		return $this->form_action;
251
+	}
252
+
253
+
254
+	/**
255
+	 * @param string $form_action
256
+	 * @throws InvalidDataTypeException
257
+	 */
258
+	public function setFormAction($form_action)
259
+	{
260
+		if (! is_string($form_action)) {
261
+			throw new InvalidDataTypeException('$form_action', $form_action, 'string');
262
+		}
263
+		$this->form_action = $form_action;
264
+	}
265
+
266
+
267
+	/**
268
+	 * @param array $form_action_args
269
+	 * @throws InvalidDataTypeException
270
+	 * @throws InvalidFormHandlerException
271
+	 */
272
+	public function addFormActionArgs($form_action_args = array())
273
+	{
274
+		if (! is_array($form_action_args)) {
275
+			throw new InvalidDataTypeException('$form_action_args', $form_action_args, 'array');
276
+		}
277
+		$form_action_args = ! empty($form_action_args)
278
+			? $form_action_args
279
+			: array($this->formStepUrlKey() => $this->form_steps->current()->slug());
280
+		$this->getCurrentStep()->setFormAction(
281
+			add_query_arg($form_action_args, $this->formAction())
282
+		);
283
+		$this->form_action = $this->getCurrentStep()->formAction();
284
+	}
285
+
286
+
287
+	/**
288
+	 * @return string
289
+	 */
290
+	public function formConfig()
291
+	{
292
+		return $this->form_config;
293
+	}
294
+
295
+
296
+	/**
297
+	 * @param string $form_config
298
+	 */
299
+	public function setFormConfig($form_config)
300
+	{
301
+		$this->form_config = $form_config;
302
+	}
303
+
304
+
305
+	/**
306
+	 * @return string
307
+	 */
308
+	public function progressStepStyle()
309
+	{
310
+		return $this->progress_step_style;
311
+	}
312
+
313
+
314
+	/**
315
+	 * @param string $progress_step_style
316
+	 */
317
+	public function setProgressStepStyle($progress_step_style)
318
+	{
319
+		$this->progress_step_style = $progress_step_style;
320
+	}
321
+
322
+
323
+	/**
324
+	 * @return RequestInterface
325
+	 */
326
+	public function request()
327
+	{
328
+		return $this->request;
329
+	}
330
+
331
+
332
+	/**
333
+	 * @return Collection|null
334
+	 * @throws InvalidInterfaceException
335
+	 */
336
+	protected function getProgressStepsCollection()
337
+	{
338
+		static $collection = null;
339
+		if (! $collection instanceof ProgressStepCollection) {
340
+			$collection = new ProgressStepCollection();
341
+		}
342
+		return $collection;
343
+	}
344
+
345
+
346
+	/**
347
+	 * @param Collection $progress_steps_collection
348
+	 * @return ProgressStepManager
349
+	 * @throws InvalidInterfaceException
350
+	 * @throws InvalidClassException
351
+	 * @throws InvalidDataTypeException
352
+	 * @throws InvalidEntityException
353
+	 * @throws InvalidFormHandlerException
354
+	 */
355
+	protected function generateProgressSteps(Collection $progress_steps_collection)
356
+	{
357
+		$current_step = $this->getCurrentStep();
358
+		/** @var SequentialStepForm $form_step */
359
+		foreach ($this->form_steps as $form_step) {
360
+			// is this step active ?
361
+			if (! $form_step->initialize()) {
362
+				continue;
363
+			}
364
+			$progress_steps_collection->add(
365
+				new ProgressStep(
366
+					$form_step->order(),
367
+					$form_step->slug(),
368
+					$form_step->slug(),
369
+					$form_step->formName()
370
+				),
371
+				$form_step->slug()
372
+			);
373
+		}
374
+		// set collection pointer back to current step
375
+		$this->form_steps->setCurrentUsingObject($current_step);
376
+		return new ProgressStepManager(
377
+			$this->progressStepStyle(),
378
+			$this->defaultFormStep(),
379
+			$this->formStepUrlKey(),
380
+			$progress_steps_collection
381
+		);
382
+	}
383
+
384
+
385
+	/**
386
+	 * @throws InvalidClassException
387
+	 * @throws InvalidDataTypeException
388
+	 * @throws InvalidEntityException
389
+	 * @throws InvalidIdentifierException
390
+	 * @throws InvalidInterfaceException
391
+	 * @throws InvalidArgumentException
392
+	 * @throws InvalidFormHandlerException
393
+	 */
394
+	public function buildForm()
395
+	{
396
+		$this->buildCurrentStepFormForDisplay();
397
+	}
398
+
399
+
400
+	/**
401
+	 * @param array $form_data
402
+	 * @throws InvalidArgumentException
403
+	 * @throws InvalidClassException
404
+	 * @throws InvalidDataTypeException
405
+	 * @throws InvalidEntityException
406
+	 * @throws InvalidFormHandlerException
407
+	 * @throws InvalidIdentifierException
408
+	 * @throws InvalidInterfaceException
409
+	 */
410
+	public function processForm($form_data = array())
411
+	{
412
+		$this->buildCurrentStepFormForProcessing();
413
+		$this->processCurrentStepForm($form_data);
414
+	}
415
+
416
+
417
+	/**
418
+	 * @throws InvalidClassException
419
+	 * @throws InvalidDataTypeException
420
+	 * @throws InvalidEntityException
421
+	 * @throws InvalidInterfaceException
422
+	 * @throws InvalidIdentifierException
423
+	 * @throws InvalidArgumentException
424
+	 * @throws InvalidFormHandlerException
425
+	 */
426
+	public function buildCurrentStepFormForDisplay()
427
+	{
428
+		$form_step = $this->buildCurrentStepForm();
429
+		// no displayable content ? then skip straight to processing
430
+		if (! $form_step->displayable()) {
431
+			$this->addFormActionArgs();
432
+			$form_step->setFormAction($this->formAction());
433
+			wp_safe_redirect($form_step->formAction());
434
+		}
435
+	}
436
+
437
+
438
+	/**
439
+	 * @throws InvalidClassException
440
+	 * @throws InvalidDataTypeException
441
+	 * @throws InvalidEntityException
442
+	 * @throws InvalidInterfaceException
443
+	 * @throws InvalidIdentifierException
444
+	 * @throws InvalidArgumentException
445
+	 * @throws InvalidFormHandlerException
446
+	 */
447
+	public function buildCurrentStepFormForProcessing()
448
+	{
449
+		$this->buildCurrentStepForm(false);
450
+	}
451
+
452
+
453
+	/**
454
+	 * @param bool $for_display
455
+	 * @return SequentialStepFormInterface
456
+	 * @throws InvalidArgumentException
457
+	 * @throws InvalidClassException
458
+	 * @throws InvalidDataTypeException
459
+	 * @throws InvalidEntityException
460
+	 * @throws InvalidFormHandlerException
461
+	 * @throws InvalidIdentifierException
462
+	 * @throws InvalidInterfaceException
463
+	 */
464
+	private function buildCurrentStepForm($for_display = true)
465
+	{
466
+		$this->form_steps = $this->getFormStepsCollection();
467
+		$this->setCurrentStepFromRequest();
468
+		$form_step = $this->getCurrentStep();
469
+		if ($form_step->submitBtnText() === esc_html__('Submit', 'event_espresso')) {
470
+			$form_step->setSubmitBtnText(esc_html__('Next Step', 'event_espresso'));
471
+		}
472
+		if ($for_display && $form_step->displayable()) {
473
+			$this->progress_step_manager = $this->generateProgressSteps(
474
+				$this->getProgressStepsCollection()
475
+			);
476
+			$this->progress_step_manager->setCurrentStep(
477
+				$form_step->slug()
478
+			);
479
+			// mark all previous progress steps as completed
480
+			$this->progress_step_manager->setPreviousStepsCompleted();
481
+			$this->progress_step_manager->enqueueStylesAndScripts();
482
+			$this->addFormActionArgs();
483
+			$form_step->setFormAction($this->formAction());
484
+		} else {
485
+			$form_step->setRedirectUrl($this->baseUrl());
486
+			$form_step->addRedirectArgs(
487
+				array($this->formStepUrlKey() => $this->form_steps->current()->slug())
488
+			);
489
+		}
490
+		$form_step->generate();
491
+		if ($for_display) {
492
+			$form_step->enqueueStylesAndScripts();
493
+		}
494
+		return $form_step;
495
+	}
496
+
497
+
498
+	/**
499
+	 * @param bool $return_as_string
500
+	 * @return string
501
+	 * @throws InvalidFormHandlerException
502
+	 */
503
+	public function displayProgressSteps($return_as_string = true)
504
+	{
505
+		$form_step = $this->getCurrentStep();
506
+		if (! $form_step->displayable()) {
507
+			return '';
508
+		}
509
+		$progress_steps = apply_filters(
510
+			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__before_steps',
511
+			''
512
+		);
513
+		$progress_steps .= $this->progress_step_manager->displaySteps();
514
+		$progress_steps .= apply_filters(
515
+			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__after_steps',
516
+			''
517
+		);
518
+		if ($return_as_string) {
519
+			return $progress_steps;
520
+		}
521
+		echo $progress_steps; // already escaped
522
+		return '';
523
+	}
524
+
525
+
526
+	/**
527
+	 * @param bool $return_as_string
528
+	 * @return string
529
+	 * @throws InvalidFormHandlerException
530
+	 */
531
+	public function displayCurrentStepForm($return_as_string = true)
532
+	{
533
+		if ($return_as_string) {
534
+			return $this->getCurrentStep()->display();
535
+		}
536
+		echo $this->getCurrentStep()->display(); // already escaped
537
+		return '';
538
+	}
539
+
540
+
541
+	/**
542
+	 * @param array $form_data
543
+	 * @return void
544
+	 * @throws InvalidArgumentException
545
+	 * @throws InvalidDataTypeException
546
+	 * @throws InvalidFormHandlerException
547
+	 */
548
+	public function processCurrentStepForm($form_data = array())
549
+	{
550
+		// grab instance of current step because after calling next() below,
551
+		// any calls to getCurrentStep() will return the "next" step because we advanced
552
+		$current_step = $this->getCurrentStep();
553
+		try {
554
+			// form processing should either throw exceptions or return true
555
+			$current_step->process($form_data);
556
+		} catch (Exception $e) {
557
+			// something went wrong, convert the Exception to an EE_Error
558
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
559
+			// prevent redirect to next step or other if exception was thrown
560
+			if (
561
+				$current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_NEXT_STEP
562
+				|| $current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_OTHER
563
+			) {
564
+				$current_step->setRedirectTo(SequentialStepForm::REDIRECT_TO_CURRENT_STEP);
565
+			}
566
+		}
567
+		// save notices to a transient so that when we redirect back
568
+		// to the display portion for this step
569
+		// those notices can be displayed
570
+		EE_Error::get_notices(false, true);
571
+		$this->redirectForm($current_step);
572
+	}
573
+
574
+
575
+	/**
576
+	 * handles where to go to next
577
+	 *
578
+	 * @param SequentialStepFormInterface $current_step
579
+	 * @throws InvalidArgumentException
580
+	 * @throws InvalidDataTypeException
581
+	 * @throws InvalidFormHandlerException
582
+	 */
583
+	public function redirectForm(SequentialStepFormInterface $current_step)
584
+	{
585
+		$redirect_step = $current_step;
586
+		switch ($current_step->redirectTo()) {
587
+			case SequentialStepForm::REDIRECT_TO_OTHER:
588
+				// going somewhere else, so just check out now
589
+				wp_safe_redirect($redirect_step->redirectUrl());
590
+				exit();
591
+			case SequentialStepForm::REDIRECT_TO_PREV_STEP:
592
+				$redirect_step = $this->form_steps->previous();
593
+				break;
594
+			case SequentialStepForm::REDIRECT_TO_NEXT_STEP:
595
+				$this->form_steps->next();
596
+				if ($this->form_steps->valid()) {
597
+					$redirect_step = $this->form_steps->current();
598
+				}
599
+				break;
600
+			case SequentialStepForm::REDIRECT_TO_CURRENT_STEP:
601
+			default:
602
+				// $redirect_step is already set
603
+		}
604
+		$current_step->setRedirectUrl($this->baseUrl());
605
+		$current_step->addRedirectArgs(
606
+			// use the slug for whatever step we are redirecting too
607
+			array($this->formStepUrlKey() => $redirect_step->slug())
608
+		);
609
+		wp_safe_redirect($current_step->redirectUrl());
610
+		exit();
611
+	}
612 612
 }
Please login to merge, or discard this patch.