Completed
Branch dependabot/composer/tijsverkoy... (491ea6)
by
unknown
32:00 queued 25:42
created
core/domain/services/graphql/mutators/FormSectionDelete.php 2 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -17,73 +17,73 @@
 block discarded – undo
17 17
 class FormSectionDelete extends EntityMutator
18 18
 {
19 19
 
20
-    /**
21
-     * Defines the mutation data modification closure.
22
-     *
23
-     * @param EEM_Form_Section $model
24
-     * @return callable
25
-     */
26
-    public static function mutateAndGetPayload(EEM_Form_Section $model)
27
-    {
28
-        /**
29
-         * Deletes an entity.
30
-         *
31
-         * @param array       $input   The input for the mutation
32
-         * @param AppContext  $context The AppContext passed down to all resolvers
33
-         * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
34
-         * @return array
35
-         */
36
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array {
37
-            try {
38
-                /** @var EE_Form_Section $entity */
39
-                $entity = EntityMutator::getEntityFromInputData($model, $input);
20
+	/**
21
+	 * Defines the mutation data modification closure.
22
+	 *
23
+	 * @param EEM_Form_Section $model
24
+	 * @return callable
25
+	 */
26
+	public static function mutateAndGetPayload(EEM_Form_Section $model)
27
+	{
28
+		/**
29
+		 * Deletes an entity.
30
+		 *
31
+		 * @param array       $input   The input for the mutation
32
+		 * @param AppContext  $context The AppContext passed down to all resolvers
33
+		 * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
34
+		 * @return array
35
+		 */
36
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array {
37
+			try {
38
+				/** @var EE_Form_Section $entity */
39
+				$entity = EntityMutator::getEntityFromInputData($model, $input);
40 40
 
41
-                $result = FormSectionDelete::deleteSectionAndRelations($entity);
41
+				$result = FormSectionDelete::deleteSectionAndRelations($entity);
42 42
 
43
-                EntityMutator::validateResults($result);
43
+				EntityMutator::validateResults($result);
44 44
 
45
-                do_action(
46
-                    'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_section_delete',
47
-                    $entity,
48
-                    $input
49
-                );
50
-            } catch (Exception $exception) {
51
-                EntityMutator::handleExceptions(
52
-                    $exception,
53
-                    esc_html__(
54
-                        'The form section could not be deleted because of the following error(s)',
55
-                        'event_espresso'
56
-                    )
57
-                );
58
-            }
45
+				do_action(
46
+					'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_section_delete',
47
+					$entity,
48
+					$input
49
+				);
50
+			} catch (Exception $exception) {
51
+				EntityMutator::handleExceptions(
52
+					$exception,
53
+					esc_html__(
54
+						'The form section could not be deleted because of the following error(s)',
55
+						'event_espresso'
56
+					)
57
+				);
58
+			}
59 59
 
60
-            return [
61
-                'deleted' => $entity,
62
-            ];
63
-        };
64
-    }
60
+			return [
61
+				'deleted' => $entity,
62
+			];
63
+		};
64
+	}
65 65
 
66
-    /**
67
-     * Deletes a form section along with its related form elements.
68
-     *
69
-     * @param EE_Form_Section $entity
70
-     * @return bool | int
71
-     * @throws ReflectionException
72
-     * @throws InvalidArgumentException
73
-     * @throws InvalidInterfaceException
74
-     * @throws InvalidDataTypeException
75
-     * @throws EE_Error
76
-     */
77
-    public static function deleteSectionAndRelations(EE_Form_Section $entity)
78
-    {
79
-        // Remove related non-default form elements
80
-        $entity->delete_related('Form_Element', [
81
-            [
82
-                'FIN_status' => ['NOT IN', [ FormStatus::SHARED, FormStatus::DEFAULT] ]
83
-            ]
84
-        ]);
66
+	/**
67
+	 * Deletes a form section along with its related form elements.
68
+	 *
69
+	 * @param EE_Form_Section $entity
70
+	 * @return bool | int
71
+	 * @throws ReflectionException
72
+	 * @throws InvalidArgumentException
73
+	 * @throws InvalidInterfaceException
74
+	 * @throws InvalidDataTypeException
75
+	 * @throws EE_Error
76
+	 */
77
+	public static function deleteSectionAndRelations(EE_Form_Section $entity)
78
+	{
79
+		// Remove related non-default form elements
80
+		$entity->delete_related('Form_Element', [
81
+			[
82
+				'FIN_status' => ['NOT IN', [ FormStatus::SHARED, FormStatus::DEFAULT] ]
83
+			]
84
+		]);
85 85
 
86
-        // Now delete the form section
87
-        return $entity->delete();
88
-    }
86
+		// Now delete the form section
87
+		return $entity->delete();
88
+	}
89 89
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
          * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
34 34
          * @return array
35 35
          */
36
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array {
36
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model): array {
37 37
             try {
38 38
                 /** @var EE_Form_Section $entity */
39 39
                 $entity = EntityMutator::getEntityFromInputData($model, $input);
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         // Remove related non-default form elements
80 80
         $entity->delete_related('Form_Element', [
81 81
             [
82
-                'FIN_status' => ['NOT IN', [ FormStatus::SHARED, FormStatus::DEFAULT] ]
82
+                'FIN_status' => ['NOT IN', [FormStatus::SHARED, FormStatus::DEFAULT]]
83 83
             ]
84 84
         ]);
85 85
 
Please login to merge, or discard this patch.
core/services/form/meta/inputs/Block.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -4,36 +4,36 @@
 block discarded – undo
4 4
 
5 5
 class Block
6 6
 {
7
-    /**
8
-     * indicates that the element is a general HTML block
9
-     */
10
-    public const TYPE_HTML = 'html';
7
+	/**
8
+	 * indicates that the element is a general HTML block
9
+	 */
10
+	public const TYPE_HTML = 'html';
11 11
 
12
-    /**
13
-     * @var array
14
-     */
15
-    private $valid_type_options;
12
+	/**
13
+	 * @var array
14
+	 */
15
+	private $valid_type_options;
16 16
 
17 17
 
18
-    public function __construct()
19
-    {
20
-        $this->valid_type_options = apply_filters(
21
-            'FHEE__EventEspresso_core_services_form_meta_inputs_Block__valid_type_options',
22
-            [
23
-                Block::TYPE_HTML => esc_html__('HTML Block', 'event_espresso'),
24
-            ]
25
-        );
26
-    }
18
+	public function __construct()
19
+	{
20
+		$this->valid_type_options = apply_filters(
21
+			'FHEE__EventEspresso_core_services_form_meta_inputs_Block__valid_type_options',
22
+			[
23
+				Block::TYPE_HTML => esc_html__('HTML Block', 'event_espresso'),
24
+			]
25
+		);
26
+	}
27 27
 
28 28
 
29
-    /**
30
-     * @param bool $constants_only
31
-     * @return array
32
-     */
33
-    public function validTypeOptions(bool $constants_only = false): array
34
-    {
35
-        return $constants_only
36
-            ? array_keys($this->valid_type_options)
37
-            : $this->valid_type_options;
38
-    }
29
+	/**
30
+	 * @param bool $constants_only
31
+	 * @return array
32
+	 */
33
+	public function validTypeOptions(bool $constants_only = false): array
34
+	{
35
+		return $constants_only
36
+			? array_keys($this->valid_type_options)
37
+			: $this->valid_type_options;
38
+	}
39 39
 }
Please login to merge, or discard this patch.
core/db_models/helpers/EE_Table_Base.php 2 patches
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.
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -6,151 +6,151 @@
 block discarded – undo
6 6
  */
7 7
 abstract class EE_Table_Base
8 8
 {
9
-    /**
10
-     * This holds the table_name without the table prefix.
11
-     *
12
-     * @var string
13
-     */
14
-    public string $_table_name;
15
-
16
-
17
-    /**
18
-     * This holds what is used as the alias for the table in queries.
19
-     *
20
-     * @var string
21
-     */
22
-    public string $_table_alias;
23
-
24
-
25
-    /**
26
-     * Table's private key column
27
-     *
28
-     * @var string|null
29
-     */
30
-    protected ?string $_pk_column = null;
31
-
32
-
33
-    /**
34
-     * Whether this table is a global table (in multisite) or specific to site.
35
-     *
36
-     * @var bool|null
37
-     */
38
-    protected ?bool $_global;
39
-
40
-
41
-    /**
42
-     * @param string      $table_name with or without wpdb prefix
43
-     * @param string|null $pk_column
44
-     * @param boolean     $global     whether the table is "global" as in there is only 1 table on an entire multisite
45
-     *                                install, or whether each site on a multisite installation has a copy of this table
46
-     * @global wpdb       $wpdb
47
-     */
48
-    public function __construct(string $table_name, ?string $pk_column, bool $global = false)
49
-    {
50
-        $this->_global = $global;
51
-        $prefix        = $this->get_table_prefix();
52
-        // if they added the prefix, let's remove it because we delay adding the prefix until right when it's needed.
53
-        if (strpos($table_name, $prefix) === 0) {
54
-            $table_name = substr_replace($table_name, '', 0, strlen($prefix));
55
-        }
56
-        $this->_table_name = $table_name;
57
-        $this->_pk_column  = $pk_column;
58
-    }
59
-
60
-
61
-    /**
62
-     * This returns the table prefix for the current model state.
63
-     *
64
-     * @return string
65
-     * @global wpdb $wpdb
66
-     */
67
-    public function get_table_prefix()
68
-    {
69
-        global $wpdb;
70
-        if ($this->_global) {
71
-            return $wpdb->base_prefix;
72
-        }
73
-        return $wpdb->get_blog_prefix(EEM_Base::get_model_query_blog_id());
74
-    }
75
-
76
-
77
-    /**
78
-     * Used to set the table_alias property
79
-     *
80
-     * @param string $table_alias
81
-     */
82
-    public function _construct_finalize_with_alias(string $table_alias)
83
-    {
84
-        $this->_table_alias = $table_alias;
85
-    }
86
-
87
-
88
-    /**
89
-     * Returns the fully qualified table name for the database (includes the table prefix current for the blog).
90
-     *
91
-     * @return string
92
-     */
93
-    public function get_table_name()
94
-    {
95
-        return $this->get_table_prefix() . $this->_table_name;
96
-    }
97
-
98
-
99
-    /**
100
-     * Provides what is currently set as the alias for the table to be used in queries.
101
-     *
102
-     * @return string
103
-     * @throws EE_Error
104
-     */
105
-    public function get_table_alias()
106
-    {
107
-        if (! $this->_table_alias) {
108
-            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?");
109
-        }
110
-        return $this->_table_alias;
111
-    }
112
-
113
-
114
-    /**
115
-     * @return string name of column of PK
116
-     */
117
-    public function get_pk_column()
118
-    {
119
-        return $this->_pk_column;
120
-    }
121
-
122
-
123
-    /**
124
-     * returns a string with the table alias, a period, and the private key's column.
125
-     *
126
-     * @return string
127
-     */
128
-    public function get_fully_qualified_pk_column()
129
-    {
130
-        return $this->get_table_alias() . "." . $this->get_pk_column();
131
-    }
132
-
133
-
134
-    /**
135
-     * returns the special sql for a inner select with a limit.
136
-     *
137
-     * @return string    SQL select
138
-     */
139
-    public function get_select_join_limit($limit)
140
-    {
141
-        $limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int) $limit;
142
-        return SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias;
143
-    }
144
-
145
-
146
-    /**
147
-     * Returns whether or not htis is a global table (ie, on multisite there's
148
-     * only one of these tables, on the main blog)
149
-     *
150
-     * @return boolean
151
-     */
152
-    public function is_global()
153
-    {
154
-        return $this->_global;
155
-    }
9
+	/**
10
+	 * This holds the table_name without the table prefix.
11
+	 *
12
+	 * @var string
13
+	 */
14
+	public string $_table_name;
15
+
16
+
17
+	/**
18
+	 * This holds what is used as the alias for the table in queries.
19
+	 *
20
+	 * @var string
21
+	 */
22
+	public string $_table_alias;
23
+
24
+
25
+	/**
26
+	 * Table's private key column
27
+	 *
28
+	 * @var string|null
29
+	 */
30
+	protected ?string $_pk_column = null;
31
+
32
+
33
+	/**
34
+	 * Whether this table is a global table (in multisite) or specific to site.
35
+	 *
36
+	 * @var bool|null
37
+	 */
38
+	protected ?bool $_global;
39
+
40
+
41
+	/**
42
+	 * @param string      $table_name with or without wpdb prefix
43
+	 * @param string|null $pk_column
44
+	 * @param boolean     $global     whether the table is "global" as in there is only 1 table on an entire multisite
45
+	 *                                install, or whether each site on a multisite installation has a copy of this table
46
+	 * @global wpdb       $wpdb
47
+	 */
48
+	public function __construct(string $table_name, ?string $pk_column, bool $global = false)
49
+	{
50
+		$this->_global = $global;
51
+		$prefix        = $this->get_table_prefix();
52
+		// if they added the prefix, let's remove it because we delay adding the prefix until right when it's needed.
53
+		if (strpos($table_name, $prefix) === 0) {
54
+			$table_name = substr_replace($table_name, '', 0, strlen($prefix));
55
+		}
56
+		$this->_table_name = $table_name;
57
+		$this->_pk_column  = $pk_column;
58
+	}
59
+
60
+
61
+	/**
62
+	 * This returns the table prefix for the current model state.
63
+	 *
64
+	 * @return string
65
+	 * @global wpdb $wpdb
66
+	 */
67
+	public function get_table_prefix()
68
+	{
69
+		global $wpdb;
70
+		if ($this->_global) {
71
+			return $wpdb->base_prefix;
72
+		}
73
+		return $wpdb->get_blog_prefix(EEM_Base::get_model_query_blog_id());
74
+	}
75
+
76
+
77
+	/**
78
+	 * Used to set the table_alias property
79
+	 *
80
+	 * @param string $table_alias
81
+	 */
82
+	public function _construct_finalize_with_alias(string $table_alias)
83
+	{
84
+		$this->_table_alias = $table_alias;
85
+	}
86
+
87
+
88
+	/**
89
+	 * Returns the fully qualified table name for the database (includes the table prefix current for the blog).
90
+	 *
91
+	 * @return string
92
+	 */
93
+	public function get_table_name()
94
+	{
95
+		return $this->get_table_prefix() . $this->_table_name;
96
+	}
97
+
98
+
99
+	/**
100
+	 * Provides what is currently set as the alias for the table to be used in queries.
101
+	 *
102
+	 * @return string
103
+	 * @throws EE_Error
104
+	 */
105
+	public function get_table_alias()
106
+	{
107
+		if (! $this->_table_alias) {
108
+			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?");
109
+		}
110
+		return $this->_table_alias;
111
+	}
112
+
113
+
114
+	/**
115
+	 * @return string name of column of PK
116
+	 */
117
+	public function get_pk_column()
118
+	{
119
+		return $this->_pk_column;
120
+	}
121
+
122
+
123
+	/**
124
+	 * returns a string with the table alias, a period, and the private key's column.
125
+	 *
126
+	 * @return string
127
+	 */
128
+	public function get_fully_qualified_pk_column()
129
+	{
130
+		return $this->get_table_alias() . "." . $this->get_pk_column();
131
+	}
132
+
133
+
134
+	/**
135
+	 * returns the special sql for a inner select with a limit.
136
+	 *
137
+	 * @return string    SQL select
138
+	 */
139
+	public function get_select_join_limit($limit)
140
+	{
141
+		$limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int) $limit;
142
+		return SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias;
143
+	}
144
+
145
+
146
+	/**
147
+	 * Returns whether or not htis is a global table (ie, on multisite there's
148
+	 * only one of these tables, on the main blog)
149
+	 *
150
+	 * @return boolean
151
+	 */
152
+	public function is_global()
153
+	{
154
+		return $this->_global;
155
+	}
156 156
 }
Please login to merge, or discard this patch.
core/services/form/meta/InputOptions.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             $value = sanitize_key($option['value']);
94 94
 
95 95
             // use `value` as key
96
-            $this->options[ $value ] = compact('label', 'value');
96
+            $this->options[$value] = compact('label', 'value');
97 97
         }
98 98
     }
99 99
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     public function removeOption(string $option_value): void
105 105
     {
106 106
         $option_value = sanitize_key($option_value);
107
-        unset($this->options[ $option_value ]);
107
+        unset($this->options[$option_value]);
108 108
     }
109 109
 
110 110
 
Please login to merge, or discard this patch.
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -14,106 +14,106 @@
 block discarded – undo
14 14
  */
15 15
 class InputOptions implements JsonableInterface
16 16
 {
17
-    /**
18
-     * @var JsonDataHandler
19
-     */
20
-    private $json_data_handler;
21
-
22
-    /**
23
-     * Options for ENUM type inputs like checkboxes, radio buttons, select inputs, etc
24
-     *
25
-     * @var array
26
-     */
27
-    private $options = [];
28
-
29
-
30
-    /**
31
-     * HelpText constructor.
32
-     *
33
-     * @param JsonDataHandler $json_data_handler
34
-     * @param array           $options
35
-     */
36
-    public function __construct(JsonDataHandler $json_data_handler, array $options)
37
-    {
38
-        $this->json_data_handler = $json_data_handler;
39
-        $this->setOptions($options);
40
-    }
41
-
42
-
43
-    /**
44
-     * @param string $json
45
-     * @return InputOptions
46
-     */
47
-    public static function fromJson(string $json): InputOptions
48
-    {
49
-        $json_data_handler = new JsonDataHandler();
50
-        $json_data_handler->configure(JsonDataHandler::DATA_TYPE_ARRAY);
51
-        $data = $json_data_handler->decodeJson($json);
52
-        return new InputOptions($json_data_handler, (array) $data ?? []);
53
-    }
54
-
55
-
56
-    /**
57
-     * @return array
58
-     */
59
-    public function toArray(): array
60
-    {
61
-        return array_values($this->options);
62
-    }
63
-
64
-
65
-    /**
66
-     * @return string
67
-     */
68
-    public function toJson(): string
69
-    {
70
-        return $this->json_data_handler->encodeData($this->toArray());
71
-    }
72
-
73
-
74
-    /**
75
-     * an array where keys are option values and values are option labels
76
-     *
77
-     * @return array
78
-     */
79
-    public function options(): array
80
-    {
81
-        return $this->options;
82
-    }
83
-
84
-
85
-    /**
86
-     * @param array $option
87
-     */
88
-    public function addOption(array $option): void
89
-    {
90
-        if (isset($option['label'], $option['value'])) {
91
-            $label = sanitize_text_field($option['label']);
92
-            $value = sanitize_key($option['value']);
93
-
94
-            // use `value` as key
95
-            $this->options[ $value ] = compact('label', 'value');
96
-        }
97
-    }
98
-
99
-
100
-    /**
101
-     * @param int|float|string $option_value
102
-     */
103
-    public function removeOption(string $option_value): void
104
-    {
105
-        $option_value = sanitize_key($option_value);
106
-        unset($this->options[ $option_value ]);
107
-    }
108
-
109
-
110
-    /**
111
-     * @param array $options an array where keys are option values and values are option labels
112
-     */
113
-    public function setOptions(array $options): void
114
-    {
115
-        foreach ($options as $option) {
116
-            $this->addOption((array) $option);
117
-        }
118
-    }
17
+	/**
18
+	 * @var JsonDataHandler
19
+	 */
20
+	private $json_data_handler;
21
+
22
+	/**
23
+	 * Options for ENUM type inputs like checkboxes, radio buttons, select inputs, etc
24
+	 *
25
+	 * @var array
26
+	 */
27
+	private $options = [];
28
+
29
+
30
+	/**
31
+	 * HelpText constructor.
32
+	 *
33
+	 * @param JsonDataHandler $json_data_handler
34
+	 * @param array           $options
35
+	 */
36
+	public function __construct(JsonDataHandler $json_data_handler, array $options)
37
+	{
38
+		$this->json_data_handler = $json_data_handler;
39
+		$this->setOptions($options);
40
+	}
41
+
42
+
43
+	/**
44
+	 * @param string $json
45
+	 * @return InputOptions
46
+	 */
47
+	public static function fromJson(string $json): InputOptions
48
+	{
49
+		$json_data_handler = new JsonDataHandler();
50
+		$json_data_handler->configure(JsonDataHandler::DATA_TYPE_ARRAY);
51
+		$data = $json_data_handler->decodeJson($json);
52
+		return new InputOptions($json_data_handler, (array) $data ?? []);
53
+	}
54
+
55
+
56
+	/**
57
+	 * @return array
58
+	 */
59
+	public function toArray(): array
60
+	{
61
+		return array_values($this->options);
62
+	}
63
+
64
+
65
+	/**
66
+	 * @return string
67
+	 */
68
+	public function toJson(): string
69
+	{
70
+		return $this->json_data_handler->encodeData($this->toArray());
71
+	}
72
+
73
+
74
+	/**
75
+	 * an array where keys are option values and values are option labels
76
+	 *
77
+	 * @return array
78
+	 */
79
+	public function options(): array
80
+	{
81
+		return $this->options;
82
+	}
83
+
84
+
85
+	/**
86
+	 * @param array $option
87
+	 */
88
+	public function addOption(array $option): void
89
+	{
90
+		if (isset($option['label'], $option['value'])) {
91
+			$label = sanitize_text_field($option['label']);
92
+			$value = sanitize_key($option['value']);
93
+
94
+			// use `value` as key
95
+			$this->options[ $value ] = compact('label', 'value');
96
+		}
97
+	}
98
+
99
+
100
+	/**
101
+	 * @param int|float|string $option_value
102
+	 */
103
+	public function removeOption(string $option_value): void
104
+	{
105
+		$option_value = sanitize_key($option_value);
106
+		unset($this->options[ $option_value ]);
107
+	}
108
+
109
+
110
+	/**
111
+	 * @param array $options an array where keys are option values and values are option labels
112
+	 */
113
+	public function setOptions(array $options): void
114
+	{
115
+		foreach ($options as $option) {
116
+			$this->addOption((array) $option);
117
+		}
118
+	}
119 119
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Form_Element.class.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      */
138 138
     public function attributes(): ?Attributes
139 139
     {
140
-        if (! $this->attributes instanceof Attributes) {
140
+        if ( ! $this->attributes instanceof Attributes) {
141 141
             $this->attributes = Attributes::fromJson($this->get('FIN_attributes'));
142 142
         }
143 143
         return $this->attributes;
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
      */
192 192
     public function helpText(): ?HelpText
193 193
     {
194
-        if (! $this->helpText instanceof HelpText) {
194
+        if ( ! $this->helpText instanceof HelpText) {
195 195
             $this->helpText = HelpText::fromJson($this->get('FIN_helpText'));
196 196
         }
197 197
         return $this->helpText;
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      */
222 222
     public function label(): ?FormLabel
223 223
     {
224
-        if (! $this->label instanceof FormLabel) {
224
+        if ( ! $this->label instanceof FormLabel) {
225 225
             $this->label = FormLabel::fromJson($this->get('FIN_label'));
226 226
         }
227 227
         return $this->label;
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
     public function setMapsTo(string $model, string $field)
265 265
     {
266 266
         $model_name = strpos($model, 'EEM_') !== 0 ? "EEM_$model" : $model;
267
-        if (! class_exists($model_name)) {
267
+        if ( ! class_exists($model_name)) {
268 268
             throw new DomainException(
269 269
                 sprintf(
270 270
                     esc_html__(
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
      */
289 289
     public function options(): ?InputOptions
290 290
     {
291
-        if (! $this->options instanceof InputOptions) {
291
+        if ( ! $this->options instanceof InputOptions) {
292 292
             $this->options = InputOptions::fromJson($this->get('FIN_options'));
293 293
         }
294 294
         return $this->options;
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
      */
368 368
     public function required(): ?Required
369 369
     {
370
-        if (! $this->required instanceof Required) {
370
+        if ( ! $this->required instanceof Required) {
371 371
             $this->required = Required::fromJson($this->get('FIN_required'));
372 372
         }
373 373
         return $this->required;
Please login to merge, or discard this patch.
Indentation   +467 added lines, -467 removed lines patch added patch discarded remove patch
@@ -28,471 +28,471 @@
 block discarded – undo
28 28
  */
29 29
 class EE_Form_Element extends EE_Base_Class
30 30
 {
31
-    /**
32
-     * @var Attributes
33
-     */
34
-    private $attributes;
35
-
36
-    /**
37
-     * @var FormLabel
38
-     */
39
-    private $label;
40
-
41
-    /**
42
-     * @var HelpText
43
-     */
44
-    private $helpText;
45
-
46
-    /**
47
-     * @var InputOptions
48
-     */
49
-    private $options;
50
-
51
-    /**
52
-     * @var Required
53
-     */
54
-    private $required;
55
-
56
-
57
-    /**
58
-     * @param array $props_n_values
59
-     * @return EE_Form_Element
60
-     * @throws EE_Error
61
-     * @throws ReflectionException
62
-     */
63
-    public static function new_instance(array $props_n_values = []): EE_Form_Element
64
-    {
65
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
66
-        return $has_object ?: new self($props_n_values);
67
-    }
68
-
69
-
70
-    /**
71
-     * @param array $props_n_values
72
-     * @return EE_Form_Element
73
-     * @throws EE_Error
74
-     * @throws ReflectionException
75
-     */
76
-    public static function new_instance_from_db(array $props_n_values = []): EE_Form_Element
77
-    {
78
-        return new self($props_n_values);
79
-    }
80
-
81
-
82
-    /**
83
-     * Form Element UUID (universally unique identifier)
84
-     *
85
-     * @return string
86
-     * @throws EE_Error
87
-     * @throws ReflectionException
88
-     */
89
-    public function UUID(): string
90
-    {
91
-        return $this->get('FIN_UUID');
92
-    }
93
-
94
-
95
-    /**
96
-     * @param string $UUID
97
-     * @throws EE_Error
98
-     * @throws ReflectionException
99
-     */
100
-    public function setUUID(string $UUID)
101
-    {
102
-        $this->set('FIN_UUID', $UUID);
103
-    }
104
-
105
-
106
-    /**
107
-     * Whether or not input is only displayed in the admin. If false, input will appear in public forms
108
-     *
109
-     * @return bool
110
-     * @throws EE_Error
111
-     * @throws ReflectionException
112
-     */
113
-    public function adminOnly(): ?bool
114
-    {
115
-        return $this->get('FIN_adminOnly');
116
-    }
117
-
118
-
119
-    /**
120
-     * @param bool $admin_only
121
-     * @throws EE_Error
122
-     * @throws ReflectionException
123
-     */
124
-    public function setAdminOnly(bool $admin_only)
125
-    {
126
-        $this->set('FIN_adminOnly', $admin_only);
127
-    }
128
-
129
-
130
-    /**
131
-     * JSON string of HTML attributes such as class, max, min, placeholder, type, etc.
132
-     *
133
-     * @return Attributes
134
-     * @throws EE_Error
135
-     * @throws ReflectionException
136
-     */
137
-    public function attributes(): ?Attributes
138
-    {
139
-        if (! $this->attributes instanceof Attributes) {
140
-            $this->attributes = Attributes::fromJson($this->get('FIN_attributes'));
141
-        }
142
-        return $this->attributes;
143
-    }
144
-
145
-
146
-    /**
147
-     * @param Attributes $attributes
148
-     * @throws EE_Error
149
-     * @throws ReflectionException
150
-     */
151
-    public function setAttributes(Attributes $attributes)
152
-    {
153
-        // set local object
154
-        $this->attributes = $attributes;
155
-        // then pass to model as an array which will get converted to JSON by the model field
156
-        $this->set('FIN_attributes', $attributes->toArray());
157
-    }
158
-
159
-
160
-    /**
161
-     * UUID of parent form section this form input belongs to.
162
-     *
163
-     * @return string
164
-     * @throws EE_Error
165
-     * @throws ReflectionException
166
-     */
167
-    public function belongsTo(): string
168
-    {
169
-        return $this->get('FSC_UUID');
170
-    }
171
-
172
-
173
-    /**
174
-     * @param string $relation_UUID
175
-     * @throws EE_Error
176
-     * @throws ReflectionException
177
-     */
178
-    public function setBelongsTo(string $relation_UUID)
179
-    {
180
-        $this->set('FSC_UUID', $relation_UUID);
181
-    }
182
-
183
-
184
-    /**
185
-     * returns a HelpText object for managing input help text
186
-     *
187
-     * @return HelpText
188
-     * @throws EE_Error
189
-     * @throws ReflectionException
190
-     */
191
-    public function helpText(): ?HelpText
192
-    {
193
-        if (! $this->helpText instanceof HelpText) {
194
-            $this->helpText = HelpText::fromJson($this->get('FIN_helpText'));
195
-        }
196
-        return $this->helpText;
197
-    }
198
-
199
-
200
-    /**
201
-     * @param HelpText $helpText
202
-     * @throws EE_Error
203
-     * @throws ReflectionException
204
-     */
205
-    public function setHelpText(HelpText $helpText)
206
-    {
207
-        // set local object
208
-        $this->helpText = $helpText;
209
-        // then pass to model as an array which will get converted to JSON by the model field
210
-        $this->set('FIN_helpText', $helpText->toArray());
211
-    }
212
-
213
-
214
-    /**
215
-     * returns a FormLabel object for managing input labels
216
-     *
217
-     * @return FormLabel
218
-     * @throws EE_Error
219
-     * @throws ReflectionException
220
-     */
221
-    public function label(): ?FormLabel
222
-    {
223
-        if (! $this->label instanceof FormLabel) {
224
-            $this->label = FormLabel::fromJson($this->get('FIN_label'));
225
-        }
226
-        return $this->label;
227
-    }
228
-
229
-
230
-    /**
231
-     * @param FormLabel $label
232
-     * @throws EE_Error
233
-     * @throws ReflectionException
234
-     */
235
-    public function setLabel(FormLabel $label)
236
-    {
237
-        // set local object
238
-        $this->label = $label;
239
-        // then pass to model as an array which will get converted to JSON by the model field
240
-        $this->set('FIN_label', $label->toArray());
241
-    }
242
-
243
-
244
-    /**
245
-     * Model and Fields name that this input maps to; ex: Attendee.email
246
-     *
247
-     * @return string
248
-     * @throws EE_Error
249
-     * @throws ReflectionException
250
-     */
251
-    public function mapsTo(): ?string
252
-    {
253
-        return $this->get('FIN_mapsTo');
254
-    }
255
-
256
-
257
-    /**
258
-     * @param string $model ex: Attendee
259
-     * @param string $field ex: email
260
-     * @throws EE_Error
261
-     * @throws ReflectionException
262
-     */
263
-    public function setMapsTo(string $model, string $field)
264
-    {
265
-        $model_name = strpos($model, 'EEM_') !== 0 ? "EEM_$model" : $model;
266
-        if (! class_exists($model_name)) {
267
-            throw new DomainException(
268
-                sprintf(
269
-                    esc_html__(
270
-                        'The %1$s model does not exist or can not be located. Please verify the spelling and whether it is loaded.',
271
-                        'event_espresso'
272
-                    ),
273
-                    $model_name
274
-                )
275
-            );
276
-        }
277
-        $this->set('FIN_mapsTo', "{$model}.{$field}");
278
-    }
279
-
280
-
281
-    /**
282
-     * Options for ENUM type inputs like checkboxes, radio buttons, select inputs, etc
283
-     *
284
-     * @return InputOptions
285
-     * @throws EE_Error
286
-     * @throws ReflectionException
287
-     */
288
-    public function options(): ?InputOptions
289
-    {
290
-        if (! $this->options instanceof InputOptions) {
291
-            $this->options = InputOptions::fromJson($this->get('FIN_options'));
292
-        }
293
-        return $this->options;
294
-    }
295
-
296
-
297
-    /**
298
-     * @param InputOptions $options
299
-     * @throws EE_Error
300
-     * @throws ReflectionException
301
-     */
302
-    public function setOptions(InputOptions $options)
303
-    {
304
-        // set local object
305
-        $this->options = $options;
306
-        // then pass to model as an array which will get converted to JSON by the model field
307
-        $this->set('FIN_options', $options->toArray());
308
-    }
309
-
310
-
311
-
312
-    /**
313
-     * Order in which form input appears in a form.
314
-     *
315
-     * @return int
316
-     * @throws EE_Error
317
-     * @throws ReflectionException
318
-     */
319
-    public function order(): int
320
-    {
321
-        return $this->get('FIN_order');
322
-    }
323
-
324
-
325
-    /**
326
-     * @param int $order
327
-     * @throws EE_Error
328
-     * @throws ReflectionException
329
-     */
330
-    public function setOrder(int $order)
331
-    {
332
-        $this->set('FIN_order', $order);
333
-    }
334
-
335
-
336
-    /**
337
-     * Example text displayed within an input to assist users with completing the form.
338
-     *
339
-     * @return string
340
-     * @throws EE_Error
341
-     * @throws ReflectionException
342
-     */
343
-    public function placeholder(): ?string
344
-    {
345
-        return $this->get('FIN_placeholder');
346
-    }
347
-
348
-
349
-    /**
350
-     * @param string $placeholder
351
-     * @throws EE_Error
352
-     * @throws ReflectionException
353
-     */
354
-    public function setPlaceholder(string $placeholder)
355
-    {
356
-        $this->set('FIN_placeholder', $placeholder);
357
-    }
358
-
359
-
360
-    /**
361
-     * Whether or not the input must be supplied with a value in order to complete the form.
362
-     *
363
-     * @return Required
364
-     * @throws EE_Error
365
-     * @throws ReflectionException
366
-     */
367
-    public function required(): ?Required
368
-    {
369
-        if (! $this->required instanceof Required) {
370
-            $this->required = Required::fromJson($this->get('FIN_required'));
371
-        }
372
-        return $this->required;
373
-    }
374
-
375
-
376
-    /**
377
-     * @param Required $required
378
-     * @throws EE_Error
379
-     * @throws ReflectionException
380
-     */
381
-    public function setRequired(Required $required)
382
-    {
383
-        // set local object
384
-        $this->required = $required;
385
-        // then pass to model as an array which will get converted to JSON by the model field
386
-        $this->set('FIN_required', $required->toArray());
387
-    }
388
-
389
-
390
-    /**
391
-     * version of public label for use in identifiers
392
-     *
393
-     * @return string
394
-     * @throws EE_Error
395
-     * @throws ReflectionException
396
-     */
397
-    public function slug(): ?string
398
-    {
399
-        return sanitize_title($this->label()->publicLabel());
400
-    }
401
-
402
-
403
-    /**
404
-     * Whether form input is active, archived, trashed, or used as a default on new forms.
405
-     * Values correspond to the EEM_Form_Element::STATUS_* constants.
406
-     *
407
-     * @return string
408
-     * @throws EE_Error
409
-     * @throws ReflectionException
410
-     */
411
-    public function status(): string
412
-    {
413
-        return $this->get('FIN_status');
414
-    }
415
-
416
-
417
-    /**
418
-     * Whether form input is active, archived, trashed, or used as a default on new forms.
419
-     * Values correspond to the EEM_Form_Element::STATUS_* constants.
420
-     *
421
-     * @param string $status
422
-     * @throws EE_Error
423
-     * @throws ReflectionException
424
-     */
425
-    public function setStatus(string $status)
426
-    {
427
-        $this->set('FIN_status', $status);
428
-    }
429
-
430
-
431
-    /**
432
-     * Form input type.
433
-     * Values correspond to the EventEspresso\core\domain\entities\form\Input::TYPE_* constants.
434
-     *
435
-     * @return string
436
-     * @throws EE_Error
437
-     * @throws ReflectionException
438
-     */
439
-    public function type(): ?string
440
-    {
441
-        return $this->get('FIN_type');
442
-    }
443
-
444
-
445
-    /**
446
-     * @param string $type
447
-     * @throws EE_Error
448
-     * @throws ReflectionException
449
-     */
450
-    public function setType(string $type)
451
-    {
452
-        $this->set('FIN_type', $type);
453
-    }
454
-
455
-
456
-    /**
457
-     * ID of the WP User that created this form input.
458
-     *
459
-     * @return int
460
-     * @throws EE_Error
461
-     * @throws ReflectionException
462
-     */
463
-    public function wp_user(): int
464
-    {
465
-        return $this->get('FIN_wpUser');
466
-    }
467
-
468
-
469
-    /**
470
-     * returns the id the wordpress user who created this question
471
-     *
472
-     * @param int $wp_user
473
-     * @throws EE_Error
474
-     * @throws ReflectionException
475
-     */
476
-    public function setWpUser(int $wp_user)
477
-    {
478
-        $this->set('FIN_wpUser', $wp_user);
479
-    }
480
-
481
-
482
-    /**
483
-     * @param array $set_cols_n_values
484
-     * @return bool|int|string
485
-     * @throws EE_Error
486
-     * @throws ReflectionException
487
-     */
488
-    public function save($set_cols_n_values = [])
489
-    {
490
-        // make sure internal versions for all composite objects are updated
491
-        $this->set('FIN_attributes', $this->attributes()->toArray());
492
-        $this->set('FIN_helpText', $this->helpText()->toArray());
493
-        $this->set('FIN_label', $this->label()->toArray());
494
-        $this->set('FIN_options', $this->options()->toArray());
495
-        $this->set('FIN_required', $this->required()->toArray());
496
-        return parent::save($set_cols_n_values);
497
-    }
31
+	/**
32
+	 * @var Attributes
33
+	 */
34
+	private $attributes;
35
+
36
+	/**
37
+	 * @var FormLabel
38
+	 */
39
+	private $label;
40
+
41
+	/**
42
+	 * @var HelpText
43
+	 */
44
+	private $helpText;
45
+
46
+	/**
47
+	 * @var InputOptions
48
+	 */
49
+	private $options;
50
+
51
+	/**
52
+	 * @var Required
53
+	 */
54
+	private $required;
55
+
56
+
57
+	/**
58
+	 * @param array $props_n_values
59
+	 * @return EE_Form_Element
60
+	 * @throws EE_Error
61
+	 * @throws ReflectionException
62
+	 */
63
+	public static function new_instance(array $props_n_values = []): EE_Form_Element
64
+	{
65
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
66
+		return $has_object ?: new self($props_n_values);
67
+	}
68
+
69
+
70
+	/**
71
+	 * @param array $props_n_values
72
+	 * @return EE_Form_Element
73
+	 * @throws EE_Error
74
+	 * @throws ReflectionException
75
+	 */
76
+	public static function new_instance_from_db(array $props_n_values = []): EE_Form_Element
77
+	{
78
+		return new self($props_n_values);
79
+	}
80
+
81
+
82
+	/**
83
+	 * Form Element UUID (universally unique identifier)
84
+	 *
85
+	 * @return string
86
+	 * @throws EE_Error
87
+	 * @throws ReflectionException
88
+	 */
89
+	public function UUID(): string
90
+	{
91
+		return $this->get('FIN_UUID');
92
+	}
93
+
94
+
95
+	/**
96
+	 * @param string $UUID
97
+	 * @throws EE_Error
98
+	 * @throws ReflectionException
99
+	 */
100
+	public function setUUID(string $UUID)
101
+	{
102
+		$this->set('FIN_UUID', $UUID);
103
+	}
104
+
105
+
106
+	/**
107
+	 * Whether or not input is only displayed in the admin. If false, input will appear in public forms
108
+	 *
109
+	 * @return bool
110
+	 * @throws EE_Error
111
+	 * @throws ReflectionException
112
+	 */
113
+	public function adminOnly(): ?bool
114
+	{
115
+		return $this->get('FIN_adminOnly');
116
+	}
117
+
118
+
119
+	/**
120
+	 * @param bool $admin_only
121
+	 * @throws EE_Error
122
+	 * @throws ReflectionException
123
+	 */
124
+	public function setAdminOnly(bool $admin_only)
125
+	{
126
+		$this->set('FIN_adminOnly', $admin_only);
127
+	}
128
+
129
+
130
+	/**
131
+	 * JSON string of HTML attributes such as class, max, min, placeholder, type, etc.
132
+	 *
133
+	 * @return Attributes
134
+	 * @throws EE_Error
135
+	 * @throws ReflectionException
136
+	 */
137
+	public function attributes(): ?Attributes
138
+	{
139
+		if (! $this->attributes instanceof Attributes) {
140
+			$this->attributes = Attributes::fromJson($this->get('FIN_attributes'));
141
+		}
142
+		return $this->attributes;
143
+	}
144
+
145
+
146
+	/**
147
+	 * @param Attributes $attributes
148
+	 * @throws EE_Error
149
+	 * @throws ReflectionException
150
+	 */
151
+	public function setAttributes(Attributes $attributes)
152
+	{
153
+		// set local object
154
+		$this->attributes = $attributes;
155
+		// then pass to model as an array which will get converted to JSON by the model field
156
+		$this->set('FIN_attributes', $attributes->toArray());
157
+	}
158
+
159
+
160
+	/**
161
+	 * UUID of parent form section this form input belongs to.
162
+	 *
163
+	 * @return string
164
+	 * @throws EE_Error
165
+	 * @throws ReflectionException
166
+	 */
167
+	public function belongsTo(): string
168
+	{
169
+		return $this->get('FSC_UUID');
170
+	}
171
+
172
+
173
+	/**
174
+	 * @param string $relation_UUID
175
+	 * @throws EE_Error
176
+	 * @throws ReflectionException
177
+	 */
178
+	public function setBelongsTo(string $relation_UUID)
179
+	{
180
+		$this->set('FSC_UUID', $relation_UUID);
181
+	}
182
+
183
+
184
+	/**
185
+	 * returns a HelpText object for managing input help text
186
+	 *
187
+	 * @return HelpText
188
+	 * @throws EE_Error
189
+	 * @throws ReflectionException
190
+	 */
191
+	public function helpText(): ?HelpText
192
+	{
193
+		if (! $this->helpText instanceof HelpText) {
194
+			$this->helpText = HelpText::fromJson($this->get('FIN_helpText'));
195
+		}
196
+		return $this->helpText;
197
+	}
198
+
199
+
200
+	/**
201
+	 * @param HelpText $helpText
202
+	 * @throws EE_Error
203
+	 * @throws ReflectionException
204
+	 */
205
+	public function setHelpText(HelpText $helpText)
206
+	{
207
+		// set local object
208
+		$this->helpText = $helpText;
209
+		// then pass to model as an array which will get converted to JSON by the model field
210
+		$this->set('FIN_helpText', $helpText->toArray());
211
+	}
212
+
213
+
214
+	/**
215
+	 * returns a FormLabel object for managing input labels
216
+	 *
217
+	 * @return FormLabel
218
+	 * @throws EE_Error
219
+	 * @throws ReflectionException
220
+	 */
221
+	public function label(): ?FormLabel
222
+	{
223
+		if (! $this->label instanceof FormLabel) {
224
+			$this->label = FormLabel::fromJson($this->get('FIN_label'));
225
+		}
226
+		return $this->label;
227
+	}
228
+
229
+
230
+	/**
231
+	 * @param FormLabel $label
232
+	 * @throws EE_Error
233
+	 * @throws ReflectionException
234
+	 */
235
+	public function setLabel(FormLabel $label)
236
+	{
237
+		// set local object
238
+		$this->label = $label;
239
+		// then pass to model as an array which will get converted to JSON by the model field
240
+		$this->set('FIN_label', $label->toArray());
241
+	}
242
+
243
+
244
+	/**
245
+	 * Model and Fields name that this input maps to; ex: Attendee.email
246
+	 *
247
+	 * @return string
248
+	 * @throws EE_Error
249
+	 * @throws ReflectionException
250
+	 */
251
+	public function mapsTo(): ?string
252
+	{
253
+		return $this->get('FIN_mapsTo');
254
+	}
255
+
256
+
257
+	/**
258
+	 * @param string $model ex: Attendee
259
+	 * @param string $field ex: email
260
+	 * @throws EE_Error
261
+	 * @throws ReflectionException
262
+	 */
263
+	public function setMapsTo(string $model, string $field)
264
+	{
265
+		$model_name = strpos($model, 'EEM_') !== 0 ? "EEM_$model" : $model;
266
+		if (! class_exists($model_name)) {
267
+			throw new DomainException(
268
+				sprintf(
269
+					esc_html__(
270
+						'The %1$s model does not exist or can not be located. Please verify the spelling and whether it is loaded.',
271
+						'event_espresso'
272
+					),
273
+					$model_name
274
+				)
275
+			);
276
+		}
277
+		$this->set('FIN_mapsTo', "{$model}.{$field}");
278
+	}
279
+
280
+
281
+	/**
282
+	 * Options for ENUM type inputs like checkboxes, radio buttons, select inputs, etc
283
+	 *
284
+	 * @return InputOptions
285
+	 * @throws EE_Error
286
+	 * @throws ReflectionException
287
+	 */
288
+	public function options(): ?InputOptions
289
+	{
290
+		if (! $this->options instanceof InputOptions) {
291
+			$this->options = InputOptions::fromJson($this->get('FIN_options'));
292
+		}
293
+		return $this->options;
294
+	}
295
+
296
+
297
+	/**
298
+	 * @param InputOptions $options
299
+	 * @throws EE_Error
300
+	 * @throws ReflectionException
301
+	 */
302
+	public function setOptions(InputOptions $options)
303
+	{
304
+		// set local object
305
+		$this->options = $options;
306
+		// then pass to model as an array which will get converted to JSON by the model field
307
+		$this->set('FIN_options', $options->toArray());
308
+	}
309
+
310
+
311
+
312
+	/**
313
+	 * Order in which form input appears in a form.
314
+	 *
315
+	 * @return int
316
+	 * @throws EE_Error
317
+	 * @throws ReflectionException
318
+	 */
319
+	public function order(): int
320
+	{
321
+		return $this->get('FIN_order');
322
+	}
323
+
324
+
325
+	/**
326
+	 * @param int $order
327
+	 * @throws EE_Error
328
+	 * @throws ReflectionException
329
+	 */
330
+	public function setOrder(int $order)
331
+	{
332
+		$this->set('FIN_order', $order);
333
+	}
334
+
335
+
336
+	/**
337
+	 * Example text displayed within an input to assist users with completing the form.
338
+	 *
339
+	 * @return string
340
+	 * @throws EE_Error
341
+	 * @throws ReflectionException
342
+	 */
343
+	public function placeholder(): ?string
344
+	{
345
+		return $this->get('FIN_placeholder');
346
+	}
347
+
348
+
349
+	/**
350
+	 * @param string $placeholder
351
+	 * @throws EE_Error
352
+	 * @throws ReflectionException
353
+	 */
354
+	public function setPlaceholder(string $placeholder)
355
+	{
356
+		$this->set('FIN_placeholder', $placeholder);
357
+	}
358
+
359
+
360
+	/**
361
+	 * Whether or not the input must be supplied with a value in order to complete the form.
362
+	 *
363
+	 * @return Required
364
+	 * @throws EE_Error
365
+	 * @throws ReflectionException
366
+	 */
367
+	public function required(): ?Required
368
+	{
369
+		if (! $this->required instanceof Required) {
370
+			$this->required = Required::fromJson($this->get('FIN_required'));
371
+		}
372
+		return $this->required;
373
+	}
374
+
375
+
376
+	/**
377
+	 * @param Required $required
378
+	 * @throws EE_Error
379
+	 * @throws ReflectionException
380
+	 */
381
+	public function setRequired(Required $required)
382
+	{
383
+		// set local object
384
+		$this->required = $required;
385
+		// then pass to model as an array which will get converted to JSON by the model field
386
+		$this->set('FIN_required', $required->toArray());
387
+	}
388
+
389
+
390
+	/**
391
+	 * version of public label for use in identifiers
392
+	 *
393
+	 * @return string
394
+	 * @throws EE_Error
395
+	 * @throws ReflectionException
396
+	 */
397
+	public function slug(): ?string
398
+	{
399
+		return sanitize_title($this->label()->publicLabel());
400
+	}
401
+
402
+
403
+	/**
404
+	 * Whether form input is active, archived, trashed, or used as a default on new forms.
405
+	 * Values correspond to the EEM_Form_Element::STATUS_* constants.
406
+	 *
407
+	 * @return string
408
+	 * @throws EE_Error
409
+	 * @throws ReflectionException
410
+	 */
411
+	public function status(): string
412
+	{
413
+		return $this->get('FIN_status');
414
+	}
415
+
416
+
417
+	/**
418
+	 * Whether form input is active, archived, trashed, or used as a default on new forms.
419
+	 * Values correspond to the EEM_Form_Element::STATUS_* constants.
420
+	 *
421
+	 * @param string $status
422
+	 * @throws EE_Error
423
+	 * @throws ReflectionException
424
+	 */
425
+	public function setStatus(string $status)
426
+	{
427
+		$this->set('FIN_status', $status);
428
+	}
429
+
430
+
431
+	/**
432
+	 * Form input type.
433
+	 * Values correspond to the EventEspresso\core\domain\entities\form\Input::TYPE_* constants.
434
+	 *
435
+	 * @return string
436
+	 * @throws EE_Error
437
+	 * @throws ReflectionException
438
+	 */
439
+	public function type(): ?string
440
+	{
441
+		return $this->get('FIN_type');
442
+	}
443
+
444
+
445
+	/**
446
+	 * @param string $type
447
+	 * @throws EE_Error
448
+	 * @throws ReflectionException
449
+	 */
450
+	public function setType(string $type)
451
+	{
452
+		$this->set('FIN_type', $type);
453
+	}
454
+
455
+
456
+	/**
457
+	 * ID of the WP User that created this form input.
458
+	 *
459
+	 * @return int
460
+	 * @throws EE_Error
461
+	 * @throws ReflectionException
462
+	 */
463
+	public function wp_user(): int
464
+	{
465
+		return $this->get('FIN_wpUser');
466
+	}
467
+
468
+
469
+	/**
470
+	 * returns the id the wordpress user who created this question
471
+	 *
472
+	 * @param int $wp_user
473
+	 * @throws EE_Error
474
+	 * @throws ReflectionException
475
+	 */
476
+	public function setWpUser(int $wp_user)
477
+	{
478
+		$this->set('FIN_wpUser', $wp_user);
479
+	}
480
+
481
+
482
+	/**
483
+	 * @param array $set_cols_n_values
484
+	 * @return bool|int|string
485
+	 * @throws EE_Error
486
+	 * @throws ReflectionException
487
+	 */
488
+	public function save($set_cols_n_values = [])
489
+	{
490
+		// make sure internal versions for all composite objects are updated
491
+		$this->set('FIN_attributes', $this->attributes()->toArray());
492
+		$this->set('FIN_helpText', $this->helpText()->toArray());
493
+		$this->set('FIN_label', $this->label()->toArray());
494
+		$this->set('FIN_options', $this->options()->toArray());
495
+		$this->set('FIN_required', $this->required()->toArray());
496
+		return parent::save($set_cols_n_values);
497
+	}
498 498
 }
Please login to merge, or discard this patch.
core/services/orm/tree_traversal/NodeGroupDao.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function getModelObjNodesInGroup($code)
52 52
     {
53
-        if (! $code) {
53
+        if ( ! $code) {
54 54
             throw new Exception(
55 55
                 esc_html__(
56 56
                     'We aren’t sure which job you are performing. Please press back in your browser and try again.',
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
                 )
59 59
             );
60 60
         }
61
-        $deletion_data = get_option($this->getOptionPrefix() . $code, []);
61
+        $deletion_data = get_option($this->getOptionPrefix().$code, []);
62 62
         foreach ($deletion_data as $root) {
63
-            if (! $root instanceof ModelObjNode) {
63
+            if ( ! $root instanceof ModelObjNode) {
64 64
                 throw new UnexpectedEntityException($root, 'ModelObjNode');
65 65
             }
66 66
         }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     public function persistModelObjNodesGroup(array $model_obj_nodes, $code)
122 122
     {
123 123
         return add_option(
124
-            $this->getOptionPrefix() . $code,
124
+            $this->getOptionPrefix().$code,
125 125
             $model_obj_nodes,
126 126
             null,
127 127
             'no'
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      */
138 138
     public function deleteModelObjNodesInGroup($code)
139 139
     {
140
-        return delete_option($this->getOptionPrefix() . $code);
140
+        return delete_option($this->getOptionPrefix().$code);
141 141
     }
142 142
 }
143 143
 // End of file NodeGroupDao.php
Please login to merge, or discard this patch.
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -22,125 +22,125 @@
 block discarded – undo
22 22
  */
23 23
 class NodeGroupDao
24 24
 {
25
-    /**
26
-     * @return mixed|void
27
-     */
28
-    public function generateGroupCode()
29
-    {
30
-        return wp_generate_password(6, false);
31
-    }
25
+	/**
26
+	 * @return mixed|void
27
+	 */
28
+	public function generateGroupCode()
29
+	{
30
+		return wp_generate_password(6, false);
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * Gets the string we put in front of the WP Option name used to store the jobs.
36
-     *
37
-     * @return string
38
-     */
39
-    private function getOptionPrefix()
40
-    {
41
-        return 'ee_deletion_';
42
-    }
34
+	/**
35
+	 * Gets the string we put in front of the WP Option name used to store the jobs.
36
+	 *
37
+	 * @return string
38
+	 */
39
+	private function getOptionPrefix()
40
+	{
41
+		return 'ee_deletion_';
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * @param $code
47
-     * @return ModelObjNode[]
48
-     * @throws Exception
49
-     * @throws UnexpectedEntityException
50
-     * @throws Exception
51
-     */
52
-    public function getModelObjNodesInGroup($code)
53
-    {
54
-        if (! $code) {
55
-            throw new Exception(
56
-                esc_html__(
57
-                    'We aren’t sure which job you are performing. Please press back in your browser and try again.',
58
-                    'event_espresso'
59
-                )
60
-            );
61
-        }
62
-        $deletion_data = get_option($this->getOptionPrefix() . $code, []);
63
-        foreach ($deletion_data as $root) {
64
-            if (! $root instanceof ModelObjNode) {
65
-                throw new UnexpectedEntityException($root, 'ModelObjNode');
66
-            }
67
-        }
68
-        return $deletion_data;
69
-    }
45
+	/**
46
+	 * @param $code
47
+	 * @return ModelObjNode[]
48
+	 * @throws Exception
49
+	 * @throws UnexpectedEntityException
50
+	 * @throws Exception
51
+	 */
52
+	public function getModelObjNodesInGroup($code)
53
+	{
54
+		if (! $code) {
55
+			throw new Exception(
56
+				esc_html__(
57
+					'We aren’t sure which job you are performing. Please press back in your browser and try again.',
58
+					'event_espresso'
59
+				)
60
+			);
61
+		}
62
+		$deletion_data = get_option($this->getOptionPrefix() . $code, []);
63
+		foreach ($deletion_data as $root) {
64
+			if (! $root instanceof ModelObjNode) {
65
+				throw new UnexpectedEntityException($root, 'ModelObjNode');
66
+			}
67
+		}
68
+		return $deletion_data;
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * Gets an array indicating what database rows are contained in the job.
74
-     * Each top-level key is a model name, and its value is an array of IDs.
75
-     *
76
-     * @param ModelObjNode[] $model_obj_nodes
77
-     * @return array
78
-     * @throws EE_Error
79
-     * @throws InvalidDataTypeException
80
-     * @throws InvalidInterfaceException
81
-     * @throws InvalidArgumentException
82
-     * @throws ReflectionException
83
-     */
84
-    public function getModelsAndIdsContainedIn(array $model_obj_nodes)
85
-    {
86
-        $models_and_ids_to_delete = [];
87
-        foreach ($model_obj_nodes as $root) {
88
-            $models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds());
89
-        }
90
-        return $models_and_ids_to_delete;
91
-    }
72
+	/**
73
+	 * Gets an array indicating what database rows are contained in the job.
74
+	 * Each top-level key is a model name, and its value is an array of IDs.
75
+	 *
76
+	 * @param ModelObjNode[] $model_obj_nodes
77
+	 * @return array
78
+	 * @throws EE_Error
79
+	 * @throws InvalidDataTypeException
80
+	 * @throws InvalidInterfaceException
81
+	 * @throws InvalidArgumentException
82
+	 * @throws ReflectionException
83
+	 */
84
+	public function getModelsAndIdsContainedIn(array $model_obj_nodes)
85
+	{
86
+		$models_and_ids_to_delete = [];
87
+		foreach ($model_obj_nodes as $root) {
88
+			$models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds());
89
+		}
90
+		return $models_and_ids_to_delete;
91
+	}
92 92
 
93 93
 
94
-    /**
95
-     * Gets an array indicating what database rows are contained in the job.
96
-     * Each top-level key is a model name, and its value is an array of IDs.
97
-     *
98
-     * @param string $code
99
-     * @return array
100
-     * @throws EE_Error
101
-     * @throws Exception
102
-     * @throws InvalidArgumentException
103
-     * @throws InvalidDataTypeException
104
-     * @throws InvalidInterfaceException
105
-     * @throws ReflectionException
106
-     * @throws UnexpectedEntityException
107
-     * @throws Exception
108
-     */
109
-    public function getModelsAndIdsFromGroup($code)
110
-    {
111
-        $model_obj_nodes = $this->getModelObjNodesInGroup($code);
112
-        return $this->getModelsAndIdsContainedIn($model_obj_nodes);
113
-    }
94
+	/**
95
+	 * Gets an array indicating what database rows are contained in the job.
96
+	 * Each top-level key is a model name, and its value is an array of IDs.
97
+	 *
98
+	 * @param string $code
99
+	 * @return array
100
+	 * @throws EE_Error
101
+	 * @throws Exception
102
+	 * @throws InvalidArgumentException
103
+	 * @throws InvalidDataTypeException
104
+	 * @throws InvalidInterfaceException
105
+	 * @throws ReflectionException
106
+	 * @throws UnexpectedEntityException
107
+	 * @throws Exception
108
+	 */
109
+	public function getModelsAndIdsFromGroup($code)
110
+	{
111
+		$model_obj_nodes = $this->getModelObjNodesInGroup($code);
112
+		return $this->getModelsAndIdsContainedIn($model_obj_nodes);
113
+	}
114 114
 
115 115
 
116
-    /**
117
-     * Persists the ModelObjNodes for future requests, using the code for reference.
118
-     *
119
-     * @param ModelObjNode[] $model_obj_nodes
120
-     * @param string         $code
121
-     * @return bool
122
-     */
123
-    public function persistModelObjNodesGroup(array $model_obj_nodes, $code)
124
-    {
125
-        return add_option(
126
-            $this->getOptionPrefix() . $code,
127
-            $model_obj_nodes,
128
-            null,
129
-            'no'
130
-        );
131
-    }
116
+	/**
117
+	 * Persists the ModelObjNodes for future requests, using the code for reference.
118
+	 *
119
+	 * @param ModelObjNode[] $model_obj_nodes
120
+	 * @param string         $code
121
+	 * @return bool
122
+	 */
123
+	public function persistModelObjNodesGroup(array $model_obj_nodes, $code)
124
+	{
125
+		return add_option(
126
+			$this->getOptionPrefix() . $code,
127
+			$model_obj_nodes,
128
+			null,
129
+			'no'
130
+		);
131
+	}
132 132
 
133 133
 
134
-    /**
135
-     * Forgets about the group of ModelObjNodes. Doesn't delete the rows in the database they reference though.
136
-     *
137
-     * @param $code
138
-     * @return bool
139
-     */
140
-    public function deleteModelObjNodesInGroup($code)
141
-    {
142
-        return delete_option($this->getOptionPrefix() . $code);
143
-    }
134
+	/**
135
+	 * Forgets about the group of ModelObjNodes. Doesn't delete the rows in the database they reference though.
136
+	 *
137
+	 * @param $code
138
+	 * @return bool
139
+	 */
140
+	public function deleteModelObjNodesInGroup($code)
141
+	{
142
+		return delete_option($this->getOptionPrefix() . $code);
143
+	}
144 144
 }
145 145
 // End of file NodeGroupDao.php
146 146
 // Location: EventEspresso\core\services\orm\tree_traversal/NodeGroupDao.php
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Personal_Data_Exporter.lib.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public static function register(string $addon_name = '', array $setup_args = []): bool
31 31
     {
32
-        self::$exporters[ $addon_name ] = $setup_args;
32
+        self::$exporters[$addon_name] = $setup_args;
33 33
         // add to list of modules to be registered
34 34
         add_filter(
35 35
             'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters',
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      */
45 45
     public static function deregister(string $addon_name = '')
46 46
     {
47
-        unset(self::$exporters[ $addon_name ]);
47
+        unset(self::$exporters[$addon_name]);
48 48
     }
49 49
 
50 50
 
Please login to merge, or discard this patch.
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -12,57 +12,57 @@
 block discarded – undo
12 12
  */
13 13
 class EE_Register_Personal_Data_Exporter implements EEI_Plugin_API
14 14
 {
15
-    /**
16
-     * FQCN for all privacy policy generators
17
-     *
18
-     * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs
19
-     */
20
-    protected static $exporters = [];
15
+	/**
16
+	 * FQCN for all privacy policy generators
17
+	 *
18
+	 * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs
19
+	 */
20
+	protected static $exporters = [];
21 21
 
22 22
 
23
-    /**
24
-     * @param string $addon_name
25
-     * @param array  $setup_args can be the fully qualified namespaces each containing only privacy policies,
26
-     *                           OR fully qualified class names of privacy policies
27
-     * @return bool
28
-     */
29
-    public static function register(string $addon_name = '', array $setup_args = []): bool
30
-    {
31
-        self::$exporters[ $addon_name ] = $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
-        return true;
38
-    }
23
+	/**
24
+	 * @param string $addon_name
25
+	 * @param array  $setup_args can be the fully qualified namespaces each containing only privacy policies,
26
+	 *                           OR fully qualified class names of privacy policies
27
+	 * @return bool
28
+	 */
29
+	public static function register(string $addon_name = '', array $setup_args = []): bool
30
+	{
31
+		self::$exporters[ $addon_name ] = $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
+		return true;
38
+	}
39 39
 
40 40
 
41
-    /**
42
-     * @param string $addon_name
43
-     */
44
-    public static function deregister(string $addon_name = '')
45
-    {
46
-        unset(self::$exporters[ $addon_name ]);
47
-    }
41
+	/**
42
+	 * @param string $addon_name
43
+	 */
44
+	public static function deregister(string $addon_name = '')
45
+	{
46
+		unset(self::$exporters[ $addon_name ]);
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * Adds our personal data exporters registered by add-ons
52
-     *
53
-     * @param string[] $exporters
54
-     * @return string[]
55
-     */
56
-    public static function addExporters(array $exporters): array
57
-    {
58
-        return array_merge($exporters, ...self::$exporters);
59
-    }
50
+	/**
51
+	 * Adds our personal data exporters registered by add-ons
52
+	 *
53
+	 * @param string[] $exporters
54
+	 * @return string[]
55
+	 */
56
+	public static function addExporters(array $exporters): array
57
+	{
58
+		return array_merge($exporters, ...self::$exporters);
59
+	}
60 60
 
61 61
 
62
-    public static function reset(): void
63
-    {
64
-        self::$exporters = [];
65
-    }
62
+	public static function reset(): void
63
+	{
64
+		self::$exporters = [];
65
+	}
66 66
 }
67 67
 // End of file EE_Register_Personal_Data_Exporter.lib.php
68 68
 // Location: ${NAMESPACE}/EE_Register_Personal_Data_Exporter.lib.php
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Personal_Data_Eraser.lib.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public static function register(string $addon_name = '', array $setup_args = []): bool
31 31
     {
32
-        self::$erasers[ $addon_name ] = $setup_args;
32
+        self::$erasers[$addon_name] = $setup_args;
33 33
         // add to list of modules to be registered
34 34
         add_filter(
35 35
             'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers',
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      */
45 45
     public static function deregister(string $addon_name = '')
46 46
     {
47
-        unset(self::$erasers[ $addon_name ]);
47
+        unset(self::$erasers[$addon_name]);
48 48
     }
49 49
 
50 50
 
Please login to merge, or discard this patch.
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -12,57 +12,57 @@
 block discarded – undo
12 12
  */
13 13
 class EE_Register_Personal_Data_Eraser implements EEI_Plugin_API
14 14
 {
15
-    /**
16
-     * FQCN for all privacy policy generators
17
-     *
18
-     * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs
19
-     */
20
-    protected static $erasers = [];
15
+	/**
16
+	 * FQCN for all privacy policy generators
17
+	 *
18
+	 * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs
19
+	 */
20
+	protected static $erasers = [];
21 21
 
22 22
 
23
-    /**
24
-     * @param string $addon_name
25
-     * @param array  $setup_args can be the fully qualified namespaces each containing only privacy policies,
26
-     *                           OR fully qualified class names of privacy policies
27
-     * @return bool
28
-     */
29
-    public static function register(string $addon_name = '', array $setup_args = []): bool
30
-    {
31
-        self::$erasers[ $addon_name ] = $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
-        return true;
38
-    }
23
+	/**
24
+	 * @param string $addon_name
25
+	 * @param array  $setup_args can be the fully qualified namespaces each containing only privacy policies,
26
+	 *                           OR fully qualified class names of privacy policies
27
+	 * @return bool
28
+	 */
29
+	public static function register(string $addon_name = '', array $setup_args = []): bool
30
+	{
31
+		self::$erasers[ $addon_name ] = $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
+		return true;
38
+	}
39 39
 
40 40
 
41
-    /**
42
-     * @param string $addon_name
43
-     */
44
-    public static function deregister(string $addon_name = '')
45
-    {
46
-        unset(self::$erasers[ $addon_name ]);
47
-    }
41
+	/**
42
+	 * @param string $addon_name
43
+	 */
44
+	public static function deregister(string $addon_name = '')
45
+	{
46
+		unset(self::$erasers[ $addon_name ]);
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * Adds our personal data erasers registered by add-ons
52
-     *
53
-     * @param string[] $erasers
54
-     * @return string[]
55
-     */
56
-    public static function addErasers(array $erasers): array
57
-    {
58
-        return array_merge($erasers, ...self::$erasers);
59
-    }
50
+	/**
51
+	 * Adds our personal data erasers registered by add-ons
52
+	 *
53
+	 * @param string[] $erasers
54
+	 * @return string[]
55
+	 */
56
+	public static function addErasers(array $erasers): array
57
+	{
58
+		return array_merge($erasers, ...self::$erasers);
59
+	}
60 60
 
61 61
 
62
-    public static function reset(): void
63
-    {
64
-        self::$erasers = [];
65
-    }
62
+	public static function reset(): void
63
+	{
64
+		self::$erasers = [];
65
+	}
66 66
 }
67 67
 // End of file EE_Register_Personal_Data_Eraser.lib.php
68 68
 // Location: ${NAMESPACE}/EE_Register_Personal_Data_Eraser.lib.php
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Messages_Shortcode_Library.lib.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         }
66 66
 
67 67
         // make sure we don't register twice
68
-        if (isset(self::$_ee_messages_shortcode_registry[ $addon_name ])) {
68
+        if (isset(self::$_ee_messages_shortcode_registry[$addon_name])) {
69 69
             return true;
70 70
         }
71 71
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
             );
88 88
         }
89 89
 
90
-        self::$_ee_messages_shortcode_registry[ $addon_name ] = [
90
+        self::$_ee_messages_shortcode_registry[$addon_name] = [
91 91
             'autoloadpaths'        => (array) $setup_args['autoloadpaths'],
92 92
             'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes'])
93 93
                 ? (array) $setup_args['list_type_shortcodes'] : [],
@@ -101,19 +101,19 @@  discard block
 block discarded – undo
101 101
         );
102 102
 
103 103
         // add below filters if the required callback is provided.
104
-        if (! empty($setup_args['msgr_validator_callback'])) {
104
+        if ( ! empty($setup_args['msgr_validator_callback'])) {
105 105
             add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2);
106 106
         }
107 107
 
108
-        if (! empty($setup_args['msgr_template_fields_callback'])) {
108
+        if ( ! empty($setup_args['msgr_template_fields_callback'])) {
109 109
             add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2);
110 110
         }
111 111
 
112
-        if (! empty($setup_args['valid_shortcodes_callback'])) {
112
+        if ( ! empty($setup_args['valid_shortcodes_callback'])) {
113 113
             add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2);
114 114
         }
115 115
 
116
-        if (! empty($setup_args['list_type_shortcodes'])) {
116
+        if ( ! empty($setup_args['list_type_shortcodes'])) {
117 117
             add_filter(
118 118
                 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes',
119 119
                 ['EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'],
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
      */
134 134
     public static function deregister(string $addon_name = '')
135 135
     {
136
-        unset(self::$_ee_messages_shortcode_registry[ $addon_name ]);
136
+        unset(self::$_ee_messages_shortcode_registry[$addon_name]);
137 137
     }
138 138
 
139 139
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     public static function register_msgs_autoload_paths(array $paths): array
149 149
     {
150 150
         $autoload_paths = [];
151
-        if (! empty(self::$_ee_messages_shortcode_registry)) {
151
+        if ( ! empty(self::$_ee_messages_shortcode_registry)) {
152 152
             foreach (self::$_ee_messages_shortcode_registry as $st_reg) {
153 153
                 if (empty($st_reg['autoloadpaths'])) {
154 154
                     continue;
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         }
177 177
         $shortcodes = [];
178 178
         foreach (self::$_ee_messages_shortcode_registry as $sc_reg) {
179
-            if (! empty($sc_reg['list_type_shortcodes'])) {
179
+            if ( ! empty($sc_reg['list_type_shortcodes'])) {
180 180
                 $shortcodes[] = $sc_reg['list_type_shortcodes'];
181 181
             }
182 182
         }
Please login to merge, or discard this patch.
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -10,180 +10,180 @@
 block discarded – undo
10 10
  */
11 11
 class EE_Register_Messages_Shortcode_Library implements EEI_Plugin_API
12 12
 {
13
-    /**
14
-     * holds values for registered messages shortcode libraries
15
-     *
16
-     * @var array
17
-     */
18
-    protected static $_ee_messages_shortcode_registry = [];
19
-
20
-
21
-    /**
22
-     * Helper method for registering a new shortcodes library class for the messages system.
23
-     *
24
-     * Note this is not used for adding shortcodes to existing libraries.  It's for registering anything
25
-     * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class.
26
-     *
27
-     * @param string $addon_name    What is the name of this shortcode library (e.g. 'question_list');
28
-     * @param array  $setup_args    An array of arguments provided for registering the new messages shortcode library.
29
-     *                              {
30
-     *
31
-     * @type array $autoloadpaths                       An array of paths to add to the messages autoloader
32
-     *                                                  for the new shortcode library class file.
33
-     * @type string $msgr_validator_callback            Callback for a method that will register the library with the
34
-     *                                                  messenger _validator_config. Optional.
35
-     * @type string  $msgr_template_fields_callback     Callback for changing adding the _template_fields property for
36
-     *                                                  messenger. For example, the shortcode library may add a new
37
-     *                                                  field to the message templates. Optional.
38
-     * @type string  $valid_shortcodes_callback         Callback for message types _valid_shortcodes array setup.
39
-     *                                                  Optional.
40
-     * @type array $list_type_shortcodes                If there are any specific shortcodes with this message
41
-     *                                                  shortcode library that should be considered "list type"
42
-     *                                                  then include them in an array.
43
-     *                                                  List Type shortcodes are shortcodes that have a corresponding
44
-     *                                                  field that indicates how they are parsed. Optional.
45
-     *                              }
46
-     * @return bool
47
-     * @throws EE_Error
48
-     * @throws EE_Error
49
-     * @since    4.3.0
50
-     *
51
-     */
52
-    public static function register(string $addon_name = '', array $setup_args = []): bool
53
-    {
54
-
55
-        // required fields MUST be present, so let's make sure they are.
56
-        if (empty($addon_name) || ! is_array($setup_args) || empty($setup_args['autoloadpaths'])) {
57
-            throw new EE_Error(
58
-                esc_html__(
59
-                    'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"',
60
-                    'event_espresso'
61
-                )
62
-            );
63
-        }
64
-
65
-        // make sure we don't register twice
66
-        if (isset(self::$_ee_messages_shortcode_registry[ $addon_name ])) {
67
-            return true;
68
-        }
69
-
70
-        // make sure this was called in the right place!
71
-        if (
72
-            ! did_action('EE_Brewing_Regular___messages_caf')
73
-            || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
74
-        ) {
75
-            EE_Error::doing_it_wrong(
76
-                __METHOD__,
77
-                sprintf(
78
-                    esc_html__(
79
-                        'Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).',
80
-                        'event_espresso'
81
-                    ),
82
-                    $addon_name
83
-                ),
84
-                '4.3.0'
85
-            );
86
-        }
87
-
88
-        self::$_ee_messages_shortcode_registry[ $addon_name ] = [
89
-            'autoloadpaths'        => (array) $setup_args['autoloadpaths'],
90
-            'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes'])
91
-                ? (array) $setup_args['list_type_shortcodes'] : [],
92
-        ];
93
-
94
-        // add filters
95
-        add_filter(
96
-            'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
97
-            ['EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'],
98
-            10
99
-        );
100
-
101
-        // add below filters if the required callback is provided.
102
-        if (! empty($setup_args['msgr_validator_callback'])) {
103
-            add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2);
104
-        }
105
-
106
-        if (! empty($setup_args['msgr_template_fields_callback'])) {
107
-            add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2);
108
-        }
109
-
110
-        if (! empty($setup_args['valid_shortcodes_callback'])) {
111
-            add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2);
112
-        }
113
-
114
-        if (! empty($setup_args['list_type_shortcodes'])) {
115
-            add_filter(
116
-                'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes',
117
-                ['EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'],
118
-                10
119
-            );
120
-        }
121
-        return true;
122
-    }
123
-
124
-
125
-    /**
126
-     * This deregisters any messages shortcode library previously registered with the given name.
127
-     *
128
-     * @param string $addon_name name used to register the shortcode library.
129
-     * @return  void
130
-     * @since    4.3.0
131
-     */
132
-    public static function deregister(string $addon_name = '')
133
-    {
134
-        unset(self::$_ee_messages_shortcode_registry[ $addon_name ]);
135
-    }
136
-
137
-
138
-    /**
139
-     * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.
140
-     *
141
-     * @param array $paths array of paths to be checked by EE_messages autoloader.
142
-     * @return array
143
-     * @since    4.3.0
144
-     *
145
-     */
146
-    public static function register_msgs_autoload_paths(array $paths): array
147
-    {
148
-        $autoload_paths = [];
149
-        if (! empty(self::$_ee_messages_shortcode_registry)) {
150
-            foreach (self::$_ee_messages_shortcode_registry as $st_reg) {
151
-                if (empty($st_reg['autoloadpaths'])) {
152
-                    continue;
153
-                }
154
-                $autoload_paths[] = $st_reg['autoloadpaths'];
155
-            }
156
-        }
157
-        return array_merge($paths, ...$autoload_paths);
158
-    }
159
-
160
-
161
-    /**
162
-     * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes
163
-     * filter which is used to add additional list type shortcodes.
164
-     *
165
-     * @param array $original_shortcodes
166
-     * @return  array                                   Modifications to original shortcodes.
167
-     * @since 4.3.0
168
-     *
169
-     */
170
-    public static function register_list_type_shortcodes(array $original_shortcodes): array
171
-    {
172
-        if (empty(self::$_ee_messages_shortcode_registry)) {
173
-            return $original_shortcodes;
174
-        }
175
-        $shortcodes = [];
176
-        foreach (self::$_ee_messages_shortcode_registry as $sc_reg) {
177
-            if (! empty($sc_reg['list_type_shortcodes'])) {
178
-                $shortcodes[] = $sc_reg['list_type_shortcodes'];
179
-            }
180
-        }
181
-        return array_merge($original_shortcodes, ...$shortcodes);
182
-    }
183
-
184
-
185
-    public static function reset(): void
186
-    {
187
-        self::$_ee_messages_shortcode_registry = [];
188
-    }
13
+	/**
14
+	 * holds values for registered messages shortcode libraries
15
+	 *
16
+	 * @var array
17
+	 */
18
+	protected static $_ee_messages_shortcode_registry = [];
19
+
20
+
21
+	/**
22
+	 * Helper method for registering a new shortcodes library class for the messages system.
23
+	 *
24
+	 * Note this is not used for adding shortcodes to existing libraries.  It's for registering anything
25
+	 * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class.
26
+	 *
27
+	 * @param string $addon_name    What is the name of this shortcode library (e.g. 'question_list');
28
+	 * @param array  $setup_args    An array of arguments provided for registering the new messages shortcode library.
29
+	 *                              {
30
+	 *
31
+	 * @type array $autoloadpaths                       An array of paths to add to the messages autoloader
32
+	 *                                                  for the new shortcode library class file.
33
+	 * @type string $msgr_validator_callback            Callback for a method that will register the library with the
34
+	 *                                                  messenger _validator_config. Optional.
35
+	 * @type string  $msgr_template_fields_callback     Callback for changing adding the _template_fields property for
36
+	 *                                                  messenger. For example, the shortcode library may add a new
37
+	 *                                                  field to the message templates. Optional.
38
+	 * @type string  $valid_shortcodes_callback         Callback for message types _valid_shortcodes array setup.
39
+	 *                                                  Optional.
40
+	 * @type array $list_type_shortcodes                If there are any specific shortcodes with this message
41
+	 *                                                  shortcode library that should be considered "list type"
42
+	 *                                                  then include them in an array.
43
+	 *                                                  List Type shortcodes are shortcodes that have a corresponding
44
+	 *                                                  field that indicates how they are parsed. Optional.
45
+	 *                              }
46
+	 * @return bool
47
+	 * @throws EE_Error
48
+	 * @throws EE_Error
49
+	 * @since    4.3.0
50
+	 *
51
+	 */
52
+	public static function register(string $addon_name = '', array $setup_args = []): bool
53
+	{
54
+
55
+		// required fields MUST be present, so let's make sure they are.
56
+		if (empty($addon_name) || ! is_array($setup_args) || empty($setup_args['autoloadpaths'])) {
57
+			throw new EE_Error(
58
+				esc_html__(
59
+					'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"',
60
+					'event_espresso'
61
+				)
62
+			);
63
+		}
64
+
65
+		// make sure we don't register twice
66
+		if (isset(self::$_ee_messages_shortcode_registry[ $addon_name ])) {
67
+			return true;
68
+		}
69
+
70
+		// make sure this was called in the right place!
71
+		if (
72
+			! did_action('EE_Brewing_Regular___messages_caf')
73
+			|| did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
74
+		) {
75
+			EE_Error::doing_it_wrong(
76
+				__METHOD__,
77
+				sprintf(
78
+					esc_html__(
79
+						'Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).',
80
+						'event_espresso'
81
+					),
82
+					$addon_name
83
+				),
84
+				'4.3.0'
85
+			);
86
+		}
87
+
88
+		self::$_ee_messages_shortcode_registry[ $addon_name ] = [
89
+			'autoloadpaths'        => (array) $setup_args['autoloadpaths'],
90
+			'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes'])
91
+				? (array) $setup_args['list_type_shortcodes'] : [],
92
+		];
93
+
94
+		// add filters
95
+		add_filter(
96
+			'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
97
+			['EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'],
98
+			10
99
+		);
100
+
101
+		// add below filters if the required callback is provided.
102
+		if (! empty($setup_args['msgr_validator_callback'])) {
103
+			add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2);
104
+		}
105
+
106
+		if (! empty($setup_args['msgr_template_fields_callback'])) {
107
+			add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2);
108
+		}
109
+
110
+		if (! empty($setup_args['valid_shortcodes_callback'])) {
111
+			add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2);
112
+		}
113
+
114
+		if (! empty($setup_args['list_type_shortcodes'])) {
115
+			add_filter(
116
+				'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes',
117
+				['EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'],
118
+				10
119
+			);
120
+		}
121
+		return true;
122
+	}
123
+
124
+
125
+	/**
126
+	 * This deregisters any messages shortcode library previously registered with the given name.
127
+	 *
128
+	 * @param string $addon_name name used to register the shortcode library.
129
+	 * @return  void
130
+	 * @since    4.3.0
131
+	 */
132
+	public static function deregister(string $addon_name = '')
133
+	{
134
+		unset(self::$_ee_messages_shortcode_registry[ $addon_name ]);
135
+	}
136
+
137
+
138
+	/**
139
+	 * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.
140
+	 *
141
+	 * @param array $paths array of paths to be checked by EE_messages autoloader.
142
+	 * @return array
143
+	 * @since    4.3.0
144
+	 *
145
+	 */
146
+	public static function register_msgs_autoload_paths(array $paths): array
147
+	{
148
+		$autoload_paths = [];
149
+		if (! empty(self::$_ee_messages_shortcode_registry)) {
150
+			foreach (self::$_ee_messages_shortcode_registry as $st_reg) {
151
+				if (empty($st_reg['autoloadpaths'])) {
152
+					continue;
153
+				}
154
+				$autoload_paths[] = $st_reg['autoloadpaths'];
155
+			}
156
+		}
157
+		return array_merge($paths, ...$autoload_paths);
158
+	}
159
+
160
+
161
+	/**
162
+	 * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes
163
+	 * filter which is used to add additional list type shortcodes.
164
+	 *
165
+	 * @param array $original_shortcodes
166
+	 * @return  array                                   Modifications to original shortcodes.
167
+	 * @since 4.3.0
168
+	 *
169
+	 */
170
+	public static function register_list_type_shortcodes(array $original_shortcodes): array
171
+	{
172
+		if (empty(self::$_ee_messages_shortcode_registry)) {
173
+			return $original_shortcodes;
174
+		}
175
+		$shortcodes = [];
176
+		foreach (self::$_ee_messages_shortcode_registry as $sc_reg) {
177
+			if (! empty($sc_reg['list_type_shortcodes'])) {
178
+				$shortcodes[] = $sc_reg['list_type_shortcodes'];
179
+			}
180
+		}
181
+		return array_merge($original_shortcodes, ...$shortcodes);
182
+	}
183
+
184
+
185
+	public static function reset(): void
186
+	{
187
+		self::$_ee_messages_shortcode_registry = [];
188
+	}
189 189
 }
Please login to merge, or discard this patch.