Completed
Branch BUG/php-8-issues (c4ea88)
by
unknown
11:33 queued 09:09
created
core/services/container/Mirror.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function getReflectionClass($class_name)
62 62
     {
63
-        if (! is_string($class_name)) {
63
+        if ( ! is_string($class_name)) {
64 64
             throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
65 65
         }
66
-        if (! isset($this->classes[ $class_name ])) {
67
-            $this->classes[ $class_name ] = new ReflectionClass($class_name);
66
+        if ( ! isset($this->classes[$class_name])) {
67
+            $this->classes[$class_name] = new ReflectionClass($class_name);
68 68
         }
69
-        return $this->classes[ $class_name ];
69
+        return $this->classes[$class_name];
70 70
     }
71 71
 
72 72
 
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function getConstructor($class_name)
80 80
     {
81
-        if (! is_string($class_name)) {
81
+        if ( ! is_string($class_name)) {
82 82
             throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
83 83
         }
84
-        if (! isset($this->constructors[ $class_name ])) {
84
+        if ( ! isset($this->constructors[$class_name])) {
85 85
             $reflection_class                  = $this->getReflectionClass($class_name);
86
-            $this->constructors[ $class_name ] = $reflection_class->getConstructor();
86
+            $this->constructors[$class_name] = $reflection_class->getConstructor();
87 87
         }
88
-        return $this->constructors[ $class_name ];
88
+        return $this->constructors[$class_name];
89 89
     }
90 90
 
91 91
 
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function getParameters($class_name)
111 111
     {
112
-        if (! isset($this->parameters[ $class_name ])) {
112
+        if ( ! isset($this->parameters[$class_name])) {
113 113
             $constructor                     = $this->getConstructor($class_name);
114
-            $this->parameters[ $class_name ] = $constructor->getParameters();
114
+            $this->parameters[$class_name] = $constructor->getParameters();
115 115
         }
116
-        return $this->parameters[ $class_name ];
116
+        return $this->parameters[$class_name];
117 117
     }
118 118
 
119 119
 
@@ -149,20 +149,20 @@  discard block
 block discarded – undo
149 149
      */
150 150
     public function getParameterClassName(ReflectionParameter $param, $class_name, $index)
151 151
     {
152
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
153
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
152
+        if (isset($this->parameter_classes[$class_name][$index]['param_class_name'])) {
153
+            return $this->parameter_classes[$class_name][$index]['param_class_name'];
154 154
         }
155
-        if (! isset($this->parameter_classes[ $class_name ])) {
156
-            $this->parameter_classes[ $class_name ] = [];
155
+        if ( ! isset($this->parameter_classes[$class_name])) {
156
+            $this->parameter_classes[$class_name] = [];
157 157
         }
158
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
159
-            $this->parameter_classes[ $class_name ][ $index ] = [];
158
+        if ( ! isset($this->parameter_classes[$class_name][$index])) {
159
+            $this->parameter_classes[$class_name][$index] = [];
160 160
         }
161 161
         // ReflectionParameter::getClass() is deprecated in PHP 8+
162
-        $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = PHP_VERSION_ID < 70100
162
+        $this->parameter_classes[$class_name][$index]['param_class_name'] = PHP_VERSION_ID < 70100
163 163
             ? $this->getParameterClassNameLegacy($param)
164 164
             : $this->getParameterClassNamePhp8($param);
165
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
165
+        return $this->parameter_classes[$class_name][$index]['param_class_name'];
166 166
     }
167 167
 
168 168
 
@@ -215,19 +215,19 @@  discard block
 block discarded – undo
215 215
      */
216 216
     public function getParameterDefaultValue(ReflectionParameter $param, $class_name, $index)
217 217
     {
218
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
219
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
218
+        if (isset($this->parameter_classes[$class_name][$index]['param_class_default'])) {
219
+            return $this->parameter_classes[$class_name][$index]['param_class_default'];
220 220
         }
221
-        if (! isset($this->parameter_classes[ $class_name ])) {
222
-            $this->parameter_classes[ $class_name ] = [];
221
+        if ( ! isset($this->parameter_classes[$class_name])) {
222
+            $this->parameter_classes[$class_name] = [];
223 223
         }
224
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
225
-            $this->parameter_classes[ $class_name ][ $index ] = [];
224
+        if ( ! isset($this->parameter_classes[$class_name][$index])) {
225
+            $this->parameter_classes[$class_name][$index] = [];
226 226
         }
227
-        $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
227
+        $this->parameter_classes[$class_name][$index]['param_class_default'] = $param->isDefaultValueAvailable()
228 228
             ? $param->getDefaultValue()
229 229
             : null;
230
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
230
+        return $this->parameter_classes[$class_name][$index]['param_class_default'];
231 231
     }
232 232
 
233 233
 
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
      */
240 240
     public function getProperties($class_name)
241 241
     {
242
-        if (! isset($this->properties[ $class_name ])) {
242
+        if ( ! isset($this->properties[$class_name])) {
243 243
             $reflection_class                = $this->getReflectionClass($class_name);
244
-            $this->properties[ $class_name ] = $reflection_class->getProperties();
244
+            $this->properties[$class_name] = $reflection_class->getProperties();
245 245
         }
246
-        return $this->properties[ $class_name ];
246
+        return $this->properties[$class_name];
247 247
     }
248 248
 
249 249
 
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
      */
268 268
     public function getMethods($class_name)
269 269
     {
270
-        if (! isset($this->methods[ $class_name ])) {
270
+        if ( ! isset($this->methods[$class_name])) {
271 271
             $reflection_class             = $this->getReflectionClass($class_name);
272
-            $this->methods[ $class_name ] = $reflection_class->getMethods();
272
+            $this->methods[$class_name] = $reflection_class->getMethods();
273 273
         }
274
-        return $this->methods[ $class_name ];
274
+        return $this->methods[$class_name];
275 275
     }
276 276
 
277 277
 
Please login to merge, or discard this patch.
Indentation   +264 added lines, -264 removed lines patch added patch discarded remove patch
@@ -20,268 +20,268 @@
 block discarded – undo
20 20
  */
21 21
 class Mirror
22 22
 {
23
-    /**
24
-     * @var ReflectionClass[] $classes
25
-     */
26
-    private $classes = [];
27
-
28
-    /**
29
-     * @var ReflectionMethod[] $constructors
30
-     */
31
-    private $constructors = [];
32
-
33
-    /**
34
-     * @var ReflectionParameter[][] $parameters
35
-     */
36
-    private $parameters = [];
37
-
38
-    /**
39
-     * @var ReflectionParameter[][] $parameters
40
-     */
41
-    private $parameter_classes = [];
42
-
43
-    /**
44
-     * @var ReflectionProperty[][] $properties
45
-     */
46
-    private $properties = [];
47
-
48
-    /**
49
-     * @var ReflectionMethod[][] $methods
50
-     */
51
-    private $methods = [];
52
-
53
-
54
-    /**
55
-     * @param string $class_name
56
-     * @return ReflectionClass
57
-     * @throws ReflectionException
58
-     * @throws InvalidDataTypeException
59
-     */
60
-    public function getReflectionClass($class_name)
61
-    {
62
-        if (! is_string($class_name)) {
63
-            throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
64
-        }
65
-        if (! isset($this->classes[ $class_name ])) {
66
-            $this->classes[ $class_name ] = new ReflectionClass($class_name);
67
-        }
68
-        return $this->classes[ $class_name ];
69
-    }
70
-
71
-
72
-    /**
73
-     * @param string $class_name
74
-     * @return ReflectionMethod
75
-     * @throws InvalidDataTypeException
76
-     * @throws ReflectionException
77
-     */
78
-    public function getConstructor($class_name)
79
-    {
80
-        if (! is_string($class_name)) {
81
-            throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
82
-        }
83
-        if (! isset($this->constructors[ $class_name ])) {
84
-            $reflection_class                  = $this->getReflectionClass($class_name);
85
-            $this->constructors[ $class_name ] = $reflection_class->getConstructor();
86
-        }
87
-        return $this->constructors[ $class_name ];
88
-    }
89
-
90
-
91
-    /**
92
-     * @param ReflectionClass $reflection_class
93
-     * @return ReflectionMethod
94
-     * @throws InvalidDataTypeException
95
-     * @throws ReflectionException
96
-     */
97
-    public function getConstructorFromReflection(ReflectionClass $reflection_class)
98
-    {
99
-        return $this->getConstructor($reflection_class->getName());
100
-    }
101
-
102
-
103
-    /**
104
-     * @param string $class_name
105
-     * @return ReflectionParameter[]
106
-     * @throws InvalidDataTypeException
107
-     * @throws ReflectionException
108
-     */
109
-    public function getParameters($class_name)
110
-    {
111
-        if (! isset($this->parameters[ $class_name ])) {
112
-            $constructor                     = $this->getConstructor($class_name);
113
-            $this->parameters[ $class_name ] = $constructor->getParameters();
114
-        }
115
-        return $this->parameters[ $class_name ];
116
-    }
117
-
118
-
119
-    /**
120
-     * @param ReflectionClass $reflection_class
121
-     * @return ReflectionParameter[]
122
-     * @throws InvalidDataTypeException
123
-     * @throws ReflectionException
124
-     */
125
-    public function getParametersFromReflection(ReflectionClass $reflection_class)
126
-    {
127
-        return $this->getParameters($reflection_class->getName());
128
-    }
129
-
130
-
131
-    /**
132
-     * @param ReflectionMethod $constructor
133
-     * @return ReflectionParameter[]
134
-     * @throws InvalidDataTypeException
135
-     * @throws ReflectionException
136
-     */
137
-    public function getParametersFromReflectionConstructor(ReflectionMethod $constructor)
138
-    {
139
-        return $this->getParameters($constructor->getDeclaringClass());
140
-    }
141
-
142
-
143
-    /**
144
-     * @param ReflectionParameter $param
145
-     * @param string              $class_name
146
-     * @param string              $index
147
-     * @return string|null
148
-     */
149
-    public function getParameterClassName(ReflectionParameter $param, $class_name, $index)
150
-    {
151
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
152
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
153
-        }
154
-        if (! isset($this->parameter_classes[ $class_name ])) {
155
-            $this->parameter_classes[ $class_name ] = [];
156
-        }
157
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
158
-            $this->parameter_classes[ $class_name ][ $index ] = [];
159
-        }
160
-        // ReflectionParameter::getClass() is deprecated in PHP 8+
161
-        $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = PHP_VERSION_ID < 70100
162
-            ? $this->getParameterClassNameLegacy($param)
163
-            : $this->getParameterClassNamePhp8($param);
164
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
165
-    }
166
-
167
-
168
-    /**
169
-     * @param ReflectionParameter $param
170
-     * @return string|null
171
-     * @since   4.10.13.p
172
-     */
173
-    private function getParameterClassNameLegacy(ReflectionParameter $param)
174
-    {
175
-        $reflection_class = $param->getClass();
176
-        return $reflection_class instanceof ReflectionClass
177
-            ? $reflection_class->getName()
178
-            : null;
179
-    }
180
-
181
-
182
-    /**
183
-     * ReflectionParameter::getClass() is deprecated in PHP 8+,
184
-     * so the class name for a parameter needs to be extracted from the ReflectionType,
185
-     * which can either be a ReflectionNamedType or ReflectionUnionType
186
-     *
187
-     * @param ReflectionParameter $param
188
-     * @return null
189
-     * @since   4.10.13.p
190
-     */
191
-    private function getParameterClassNamePhp8(ReflectionParameter $param)
192
-    {
193
-        $reflection_type = $param->getType();
194
-        if ($reflection_type instanceof \ReflectionNamedType) {
195
-            return $reflection_type->getName();
196
-        }
197
-        if ($reflection_type instanceof \ReflectionUnionType) {
198
-            $reflection_types = $reflection_type->getTypes();
199
-            if (is_array($reflection_types)) {
200
-                $first = reset($reflection_types);
201
-                return $first->getName();
202
-            }
203
-        }
204
-        return null;
205
-    }
206
-
207
-
208
-    /**
209
-     * @param ReflectionParameter $param
210
-     * @param string              $class_name
211
-     * @param string              $index
212
-     * @return string|null
213
-     * @throws ReflectionException
214
-     */
215
-    public function getParameterDefaultValue(ReflectionParameter $param, $class_name, $index)
216
-    {
217
-        if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
218
-            return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
219
-        }
220
-        if (! isset($this->parameter_classes[ $class_name ])) {
221
-            $this->parameter_classes[ $class_name ] = [];
222
-        }
223
-        if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
224
-            $this->parameter_classes[ $class_name ][ $index ] = [];
225
-        }
226
-        $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
227
-            ? $param->getDefaultValue()
228
-            : null;
229
-        return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
230
-    }
231
-
232
-
233
-    /**
234
-     * @param string $class_name
235
-     * @return ReflectionProperty[]
236
-     * @throws InvalidDataTypeException
237
-     * @throws ReflectionException
238
-     */
239
-    public function getProperties($class_name)
240
-    {
241
-        if (! isset($this->properties[ $class_name ])) {
242
-            $reflection_class                = $this->getReflectionClass($class_name);
243
-            $this->properties[ $class_name ] = $reflection_class->getProperties();
244
-        }
245
-        return $this->properties[ $class_name ];
246
-    }
247
-
248
-
249
-    /**
250
-     * @param ReflectionClass $reflection_class
251
-     * @return ReflectionProperty[]
252
-     * @throws InvalidDataTypeException
253
-     * @throws ReflectionException
254
-     */
255
-    public function getPropertiesFromReflection(ReflectionClass $reflection_class)
256
-    {
257
-        return $this->getProperties($reflection_class->getName());
258
-    }
259
-
260
-
261
-    /**
262
-     * @param string $class_name
263
-     * @return ReflectionMethod[]
264
-     * @throws InvalidDataTypeException
265
-     * @throws ReflectionException
266
-     */
267
-    public function getMethods($class_name)
268
-    {
269
-        if (! isset($this->methods[ $class_name ])) {
270
-            $reflection_class             = $this->getReflectionClass($class_name);
271
-            $this->methods[ $class_name ] = $reflection_class->getMethods();
272
-        }
273
-        return $this->methods[ $class_name ];
274
-    }
275
-
276
-
277
-    /**
278
-     * @param ReflectionClass $reflection_class )
279
-     * @return ReflectionMethod[]
280
-     * @throws InvalidDataTypeException
281
-     * @throws ReflectionException
282
-     */
283
-    public function getMethodsFromReflection(ReflectionClass $reflection_class)
284
-    {
285
-        return $this->getMethods($reflection_class->getName());
286
-    }
23
+	/**
24
+	 * @var ReflectionClass[] $classes
25
+	 */
26
+	private $classes = [];
27
+
28
+	/**
29
+	 * @var ReflectionMethod[] $constructors
30
+	 */
31
+	private $constructors = [];
32
+
33
+	/**
34
+	 * @var ReflectionParameter[][] $parameters
35
+	 */
36
+	private $parameters = [];
37
+
38
+	/**
39
+	 * @var ReflectionParameter[][] $parameters
40
+	 */
41
+	private $parameter_classes = [];
42
+
43
+	/**
44
+	 * @var ReflectionProperty[][] $properties
45
+	 */
46
+	private $properties = [];
47
+
48
+	/**
49
+	 * @var ReflectionMethod[][] $methods
50
+	 */
51
+	private $methods = [];
52
+
53
+
54
+	/**
55
+	 * @param string $class_name
56
+	 * @return ReflectionClass
57
+	 * @throws ReflectionException
58
+	 * @throws InvalidDataTypeException
59
+	 */
60
+	public function getReflectionClass($class_name)
61
+	{
62
+		if (! is_string($class_name)) {
63
+			throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
64
+		}
65
+		if (! isset($this->classes[ $class_name ])) {
66
+			$this->classes[ $class_name ] = new ReflectionClass($class_name);
67
+		}
68
+		return $this->classes[ $class_name ];
69
+	}
70
+
71
+
72
+	/**
73
+	 * @param string $class_name
74
+	 * @return ReflectionMethod
75
+	 * @throws InvalidDataTypeException
76
+	 * @throws ReflectionException
77
+	 */
78
+	public function getConstructor($class_name)
79
+	{
80
+		if (! is_string($class_name)) {
81
+			throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)');
82
+		}
83
+		if (! isset($this->constructors[ $class_name ])) {
84
+			$reflection_class                  = $this->getReflectionClass($class_name);
85
+			$this->constructors[ $class_name ] = $reflection_class->getConstructor();
86
+		}
87
+		return $this->constructors[ $class_name ];
88
+	}
89
+
90
+
91
+	/**
92
+	 * @param ReflectionClass $reflection_class
93
+	 * @return ReflectionMethod
94
+	 * @throws InvalidDataTypeException
95
+	 * @throws ReflectionException
96
+	 */
97
+	public function getConstructorFromReflection(ReflectionClass $reflection_class)
98
+	{
99
+		return $this->getConstructor($reflection_class->getName());
100
+	}
101
+
102
+
103
+	/**
104
+	 * @param string $class_name
105
+	 * @return ReflectionParameter[]
106
+	 * @throws InvalidDataTypeException
107
+	 * @throws ReflectionException
108
+	 */
109
+	public function getParameters($class_name)
110
+	{
111
+		if (! isset($this->parameters[ $class_name ])) {
112
+			$constructor                     = $this->getConstructor($class_name);
113
+			$this->parameters[ $class_name ] = $constructor->getParameters();
114
+		}
115
+		return $this->parameters[ $class_name ];
116
+	}
117
+
118
+
119
+	/**
120
+	 * @param ReflectionClass $reflection_class
121
+	 * @return ReflectionParameter[]
122
+	 * @throws InvalidDataTypeException
123
+	 * @throws ReflectionException
124
+	 */
125
+	public function getParametersFromReflection(ReflectionClass $reflection_class)
126
+	{
127
+		return $this->getParameters($reflection_class->getName());
128
+	}
129
+
130
+
131
+	/**
132
+	 * @param ReflectionMethod $constructor
133
+	 * @return ReflectionParameter[]
134
+	 * @throws InvalidDataTypeException
135
+	 * @throws ReflectionException
136
+	 */
137
+	public function getParametersFromReflectionConstructor(ReflectionMethod $constructor)
138
+	{
139
+		return $this->getParameters($constructor->getDeclaringClass());
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param ReflectionParameter $param
145
+	 * @param string              $class_name
146
+	 * @param string              $index
147
+	 * @return string|null
148
+	 */
149
+	public function getParameterClassName(ReflectionParameter $param, $class_name, $index)
150
+	{
151
+		if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) {
152
+			return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
153
+		}
154
+		if (! isset($this->parameter_classes[ $class_name ])) {
155
+			$this->parameter_classes[ $class_name ] = [];
156
+		}
157
+		if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
158
+			$this->parameter_classes[ $class_name ][ $index ] = [];
159
+		}
160
+		// ReflectionParameter::getClass() is deprecated in PHP 8+
161
+		$this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = PHP_VERSION_ID < 70100
162
+			? $this->getParameterClassNameLegacy($param)
163
+			: $this->getParameterClassNamePhp8($param);
164
+		return $this->parameter_classes[ $class_name ][ $index ]['param_class_name'];
165
+	}
166
+
167
+
168
+	/**
169
+	 * @param ReflectionParameter $param
170
+	 * @return string|null
171
+	 * @since   4.10.13.p
172
+	 */
173
+	private function getParameterClassNameLegacy(ReflectionParameter $param)
174
+	{
175
+		$reflection_class = $param->getClass();
176
+		return $reflection_class instanceof ReflectionClass
177
+			? $reflection_class->getName()
178
+			: null;
179
+	}
180
+
181
+
182
+	/**
183
+	 * ReflectionParameter::getClass() is deprecated in PHP 8+,
184
+	 * so the class name for a parameter needs to be extracted from the ReflectionType,
185
+	 * which can either be a ReflectionNamedType or ReflectionUnionType
186
+	 *
187
+	 * @param ReflectionParameter $param
188
+	 * @return null
189
+	 * @since   4.10.13.p
190
+	 */
191
+	private function getParameterClassNamePhp8(ReflectionParameter $param)
192
+	{
193
+		$reflection_type = $param->getType();
194
+		if ($reflection_type instanceof \ReflectionNamedType) {
195
+			return $reflection_type->getName();
196
+		}
197
+		if ($reflection_type instanceof \ReflectionUnionType) {
198
+			$reflection_types = $reflection_type->getTypes();
199
+			if (is_array($reflection_types)) {
200
+				$first = reset($reflection_types);
201
+				return $first->getName();
202
+			}
203
+		}
204
+		return null;
205
+	}
206
+
207
+
208
+	/**
209
+	 * @param ReflectionParameter $param
210
+	 * @param string              $class_name
211
+	 * @param string              $index
212
+	 * @return string|null
213
+	 * @throws ReflectionException
214
+	 */
215
+	public function getParameterDefaultValue(ReflectionParameter $param, $class_name, $index)
216
+	{
217
+		if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) {
218
+			return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
219
+		}
220
+		if (! isset($this->parameter_classes[ $class_name ])) {
221
+			$this->parameter_classes[ $class_name ] = [];
222
+		}
223
+		if (! isset($this->parameter_classes[ $class_name ][ $index ])) {
224
+			$this->parameter_classes[ $class_name ][ $index ] = [];
225
+		}
226
+		$this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable()
227
+			? $param->getDefaultValue()
228
+			: null;
229
+		return $this->parameter_classes[ $class_name ][ $index ]['param_class_default'];
230
+	}
231
+
232
+
233
+	/**
234
+	 * @param string $class_name
235
+	 * @return ReflectionProperty[]
236
+	 * @throws InvalidDataTypeException
237
+	 * @throws ReflectionException
238
+	 */
239
+	public function getProperties($class_name)
240
+	{
241
+		if (! isset($this->properties[ $class_name ])) {
242
+			$reflection_class                = $this->getReflectionClass($class_name);
243
+			$this->properties[ $class_name ] = $reflection_class->getProperties();
244
+		}
245
+		return $this->properties[ $class_name ];
246
+	}
247
+
248
+
249
+	/**
250
+	 * @param ReflectionClass $reflection_class
251
+	 * @return ReflectionProperty[]
252
+	 * @throws InvalidDataTypeException
253
+	 * @throws ReflectionException
254
+	 */
255
+	public function getPropertiesFromReflection(ReflectionClass $reflection_class)
256
+	{
257
+		return $this->getProperties($reflection_class->getName());
258
+	}
259
+
260
+
261
+	/**
262
+	 * @param string $class_name
263
+	 * @return ReflectionMethod[]
264
+	 * @throws InvalidDataTypeException
265
+	 * @throws ReflectionException
266
+	 */
267
+	public function getMethods($class_name)
268
+	{
269
+		if (! isset($this->methods[ $class_name ])) {
270
+			$reflection_class             = $this->getReflectionClass($class_name);
271
+			$this->methods[ $class_name ] = $reflection_class->getMethods();
272
+		}
273
+		return $this->methods[ $class_name ];
274
+	}
275
+
276
+
277
+	/**
278
+	 * @param ReflectionClass $reflection_class )
279
+	 * @return ReflectionMethod[]
280
+	 * @throws InvalidDataTypeException
281
+	 * @throws ReflectionException
282
+	 */
283
+	public function getMethodsFromReflection(ReflectionClass $reflection_class)
284
+	{
285
+		return $this->getMethods($reflection_class->getName());
286
+	}
287 287
 }
Please login to merge, or discard this patch.
core/services/loaders/ClassInterfaceCache.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -49,16 +49,16 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $fqn = $this->getFqn($fqn);
51 51
         // have we already seen this FQCN ?
52
-        if (! array_key_exists($fqn, $this->interfaces)) {
53
-            $this->interfaces[ $fqn ] = array();
52
+        if ( ! array_key_exists($fqn, $this->interfaces)) {
53
+            $this->interfaces[$fqn] = array();
54 54
             if (class_exists($fqn)) {
55
-                $this->interfaces[ $fqn ] = class_implements($fqn, false);
56
-                $this->interfaces[ $fqn ] = $this->interfaces[ $fqn ] !== false
57
-                    ? $this->interfaces[ $fqn ]
55
+                $this->interfaces[$fqn] = class_implements($fqn, false);
56
+                $this->interfaces[$fqn] = $this->interfaces[$fqn] !== false
57
+                    ? $this->interfaces[$fqn]
58 58
                     : array();
59 59
             }
60 60
         }
61
-        return $this->interfaces[ $fqn ];
61
+        return $this->interfaces[$fqn];
62 62
     }
63 63
 
64 64
 
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
         // are we adding an alias for a specific class?
94 94
         if ($for_class !== '') {
95 95
             // make sure it's set up as an array
96
-            if (! isset($this->aliases[ $for_class ])) {
97
-                $this->aliases[ $for_class ] = array();
96
+            if ( ! isset($this->aliases[$for_class])) {
97
+                $this->aliases[$for_class] = array();
98 98
             }
99
-            $this->aliases[ $for_class ][ $alias ] = $fqn;
99
+            $this->aliases[$for_class][$alias] = $fqn;
100 100
             return;
101 101
         }
102
-        $this->aliases[ $alias ] = $fqn;
102
+        $this->aliases[$alias] = $fqn;
103 103
     }
104 104
 
105 105
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      */
132 132
     protected function isDirectAlias($fqn = '')
133 133
     {
134
-        return isset($this->aliases[ (string) $fqn ]) && ! is_array($this->aliases[ (string) $fqn ]);
134
+        return isset($this->aliases[(string) $fqn]) && ! is_array($this->aliases[(string) $fqn]);
135 135
     }
136 136
 
137 137
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     {
147 147
         return (
148 148
             $for_class !== ''
149
-            && isset($this->aliases[ (string) $for_class ][ (string) $fqn ])
149
+            && isset($this->aliases[(string) $for_class][(string) $fqn])
150 150
         );
151 151
     }
152 152
 
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
     {
172 172
         $alias = $this->getFqn($alias);
173 173
         if ($this->isAliasForClass($alias, $for_class)) {
174
-            return $this->getFqnForAlias($this->aliases[ (string) $for_class ][ (string) $alias ], $for_class);
174
+            return $this->getFqnForAlias($this->aliases[(string) $for_class][(string) $alias], $for_class);
175 175
         }
176 176
         if ($this->isDirectAlias($alias)) {
177 177
             // note: changed '' to $for_class
178
-            return $this->getFqnForAlias($this->aliases[ (string) $alias ], $for_class);
178
+            return $this->getFqnForAlias($this->aliases[(string) $alias], $for_class);
179 179
         }
180 180
         return $alias;
181 181
     }
Please login to merge, or discard this patch.
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -16,180 +16,180 @@
 block discarded – undo
16 16
  */
17 17
 class ClassInterfaceCache
18 18
 {
19
-    /**
20
-     * array of interfaces indexed by FQCNs where values are arrays of interface FQNs
21
-     *
22
-     * @var string[][] $interfaces
23
-     */
24
-    private $interfaces = array();
25
-
26
-    /**
27
-     * @type string[][] $aliases
28
-     */
29
-    protected $aliases = array();
30
-
31
-
32
-    /**
33
-     * @param string $fqn
34
-     * @return string
35
-     */
36
-    public function getFqn($fqn)
37
-    {
38
-        $fqn = $fqn instanceof FullyQualifiedName ? $fqn->string() : $fqn;
39
-        return ltrim((string) $fqn, '\\');
40
-    }
41
-
42
-
43
-    /**
44
-     * @param string $fqn
45
-     * @return array
46
-     */
47
-    public function getInterfaces($fqn)
48
-    {
49
-        $fqn = $this->getFqn($fqn);
50
-        // have we already seen this FQCN ?
51
-        if (! array_key_exists($fqn, $this->interfaces)) {
52
-            $this->interfaces[ $fqn ] = array();
53
-            if (class_exists($fqn)) {
54
-                $this->interfaces[ $fqn ] = class_implements($fqn, false);
55
-                $this->interfaces[ $fqn ] = $this->interfaces[ $fqn ] !== false
56
-                    ? $this->interfaces[ $fqn ]
57
-                    : array();
58
-            }
59
-        }
60
-        return $this->interfaces[ $fqn ];
61
-    }
62
-
63
-
64
-    /**
65
-     * @param string $fqn
66
-     * @param string $interface
67
-     * @return bool
68
-     */
69
-    public function hasInterface($fqn, $interface)
70
-    {
71
-        $fqn        = $this->getFqn($fqn);
72
-        $interfaces = $this->getInterfaces($fqn);
73
-        return in_array($interface, $interfaces, true);
74
-    }
75
-
76
-
77
-    /**
78
-     * adds an alias for a classname
79
-     *
80
-     * @param string $fqn       the class name that should be used (concrete class to replace interface)
81
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
82
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
83
-     * @throws InvalidAliasException
84
-     */
85
-    public function addAlias($fqn, $alias, $for_class = '')
86
-    {
87
-        $fqn   = $this->getFqn($fqn);
88
-        $alias = $this->getFqn($alias);
89
-        if (strpos($alias, '\\') !== false && ! is_subclass_of($fqn, $alias)) {
90
-            throw new InvalidAliasException($fqn, $alias);
91
-        }
92
-        // are we adding an alias for a specific class?
93
-        if ($for_class !== '') {
94
-            // make sure it's set up as an array
95
-            if (! isset($this->aliases[ $for_class ])) {
96
-                $this->aliases[ $for_class ] = array();
97
-            }
98
-            $this->aliases[ $for_class ][ $alias ] = $fqn;
99
-            return;
100
-        }
101
-        $this->aliases[ $alias ] = $fqn;
102
-    }
103
-
104
-
105
-    /**
106
-     * returns TRUE if the provided FQN is an alias
107
-     *
108
-     * @param string $fqn
109
-     * @param string $for_class
110
-     * @return bool
111
-     */
112
-    public function isAlias($fqn = '', $for_class = '')
113
-    {
114
-        $fqn = $this->getFqn($fqn);
115
-        if ($this->isAliasForClass($fqn, $for_class)) {
116
-            return true;
117
-        }
118
-        if ($this->isDirectAlias($fqn)) {
119
-            return true;
120
-        }
121
-        return false;
122
-    }
123
-
124
-
125
-    /**
126
-     * returns TRUE if the provided FQN is an alias
127
-     *
128
-     * @param string $fqn
129
-     * @return bool
130
-     */
131
-    protected function isDirectAlias($fqn = '')
132
-    {
133
-        return isset($this->aliases[ (string) $fqn ]) && ! is_array($this->aliases[ (string) $fqn ]);
134
-    }
135
-
136
-
137
-    /**
138
-     * returns TRUE if the provided FQN is an alias for the specified class
139
-     *
140
-     * @param string $fqn
141
-     * @param string $for_class
142
-     * @return bool
143
-     */
144
-    protected function isAliasForClass($fqn = '', $for_class = '')
145
-    {
146
-        return (
147
-            $for_class !== ''
148
-            && isset($this->aliases[ (string) $for_class ][ (string) $fqn ])
149
-        );
150
-    }
151
-
152
-
153
-    /**
154
-     * returns FQN for provided alias if one exists, otherwise returns the original FQN
155
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
156
-     *  for example:
157
-     *      if the following two entries were added to the aliases array:
158
-     *          array(
159
-     *              'interface_alias'           => 'some\namespace\interface'
160
-     *              'some\namespace\interface'  => 'some\namespace\classname'
161
-     *          )
162
-     *      then one could use Loader::getNew( 'interface_alias' )
163
-     *      to load an instance of 'some\namespace\classname'
164
-     *
165
-     * @param string $alias
166
-     * @param string $for_class
167
-     * @return string
168
-     */
169
-    public function getFqnForAlias($alias = '', $for_class = '')
170
-    {
171
-        $alias = $this->getFqn($alias);
172
-        if ($this->isAliasForClass($alias, $for_class)) {
173
-            return $this->getFqnForAlias($this->aliases[ (string) $for_class ][ (string) $alias ], $for_class);
174
-        }
175
-        if ($this->isDirectAlias($alias)) {
176
-            // note: changed '' to $for_class
177
-            return $this->getFqnForAlias($this->aliases[ (string) $alias ], $for_class);
178
-        }
179
-        return $alias;
180
-    }
181
-
182
-
183
-    // public function debug($for_class = '')
184
-    // {
185
-    //     if ($for_class !== '') {
186
-    //         if ( ! isset($this->aliases[ $for_class ])) {
187
-    //             \EEH_Debug_Tools::printr('NOT FOUND', "aliases[ $for_class ]", __FILE__, __LINE__);
188
-    //             return;
189
-    //         }
190
-    //         \EEH_Debug_Tools::printr($this->aliases[ $for_class ], "aliases[ $for_class ]", __FILE__, __LINE__);
191
-    //         return;
192
-    //     }
193
-    //     \EEH_Debug_Tools::printr($this->aliases, '$this->aliases', __FILE__, __LINE__);
194
-    // }
19
+	/**
20
+	 * array of interfaces indexed by FQCNs where values are arrays of interface FQNs
21
+	 *
22
+	 * @var string[][] $interfaces
23
+	 */
24
+	private $interfaces = array();
25
+
26
+	/**
27
+	 * @type string[][] $aliases
28
+	 */
29
+	protected $aliases = array();
30
+
31
+
32
+	/**
33
+	 * @param string $fqn
34
+	 * @return string
35
+	 */
36
+	public function getFqn($fqn)
37
+	{
38
+		$fqn = $fqn instanceof FullyQualifiedName ? $fqn->string() : $fqn;
39
+		return ltrim((string) $fqn, '\\');
40
+	}
41
+
42
+
43
+	/**
44
+	 * @param string $fqn
45
+	 * @return array
46
+	 */
47
+	public function getInterfaces($fqn)
48
+	{
49
+		$fqn = $this->getFqn($fqn);
50
+		// have we already seen this FQCN ?
51
+		if (! array_key_exists($fqn, $this->interfaces)) {
52
+			$this->interfaces[ $fqn ] = array();
53
+			if (class_exists($fqn)) {
54
+				$this->interfaces[ $fqn ] = class_implements($fqn, false);
55
+				$this->interfaces[ $fqn ] = $this->interfaces[ $fqn ] !== false
56
+					? $this->interfaces[ $fqn ]
57
+					: array();
58
+			}
59
+		}
60
+		return $this->interfaces[ $fqn ];
61
+	}
62
+
63
+
64
+	/**
65
+	 * @param string $fqn
66
+	 * @param string $interface
67
+	 * @return bool
68
+	 */
69
+	public function hasInterface($fqn, $interface)
70
+	{
71
+		$fqn        = $this->getFqn($fqn);
72
+		$interfaces = $this->getInterfaces($fqn);
73
+		return in_array($interface, $interfaces, true);
74
+	}
75
+
76
+
77
+	/**
78
+	 * adds an alias for a classname
79
+	 *
80
+	 * @param string $fqn       the class name that should be used (concrete class to replace interface)
81
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
82
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
83
+	 * @throws InvalidAliasException
84
+	 */
85
+	public function addAlias($fqn, $alias, $for_class = '')
86
+	{
87
+		$fqn   = $this->getFqn($fqn);
88
+		$alias = $this->getFqn($alias);
89
+		if (strpos($alias, '\\') !== false && ! is_subclass_of($fqn, $alias)) {
90
+			throw new InvalidAliasException($fqn, $alias);
91
+		}
92
+		// are we adding an alias for a specific class?
93
+		if ($for_class !== '') {
94
+			// make sure it's set up as an array
95
+			if (! isset($this->aliases[ $for_class ])) {
96
+				$this->aliases[ $for_class ] = array();
97
+			}
98
+			$this->aliases[ $for_class ][ $alias ] = $fqn;
99
+			return;
100
+		}
101
+		$this->aliases[ $alias ] = $fqn;
102
+	}
103
+
104
+
105
+	/**
106
+	 * returns TRUE if the provided FQN is an alias
107
+	 *
108
+	 * @param string $fqn
109
+	 * @param string $for_class
110
+	 * @return bool
111
+	 */
112
+	public function isAlias($fqn = '', $for_class = '')
113
+	{
114
+		$fqn = $this->getFqn($fqn);
115
+		if ($this->isAliasForClass($fqn, $for_class)) {
116
+			return true;
117
+		}
118
+		if ($this->isDirectAlias($fqn)) {
119
+			return true;
120
+		}
121
+		return false;
122
+	}
123
+
124
+
125
+	/**
126
+	 * returns TRUE if the provided FQN is an alias
127
+	 *
128
+	 * @param string $fqn
129
+	 * @return bool
130
+	 */
131
+	protected function isDirectAlias($fqn = '')
132
+	{
133
+		return isset($this->aliases[ (string) $fqn ]) && ! is_array($this->aliases[ (string) $fqn ]);
134
+	}
135
+
136
+
137
+	/**
138
+	 * returns TRUE if the provided FQN is an alias for the specified class
139
+	 *
140
+	 * @param string $fqn
141
+	 * @param string $for_class
142
+	 * @return bool
143
+	 */
144
+	protected function isAliasForClass($fqn = '', $for_class = '')
145
+	{
146
+		return (
147
+			$for_class !== ''
148
+			&& isset($this->aliases[ (string) $for_class ][ (string) $fqn ])
149
+		);
150
+	}
151
+
152
+
153
+	/**
154
+	 * returns FQN for provided alias if one exists, otherwise returns the original FQN
155
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
156
+	 *  for example:
157
+	 *      if the following two entries were added to the aliases array:
158
+	 *          array(
159
+	 *              'interface_alias'           => 'some\namespace\interface'
160
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
161
+	 *          )
162
+	 *      then one could use Loader::getNew( 'interface_alias' )
163
+	 *      to load an instance of 'some\namespace\classname'
164
+	 *
165
+	 * @param string $alias
166
+	 * @param string $for_class
167
+	 * @return string
168
+	 */
169
+	public function getFqnForAlias($alias = '', $for_class = '')
170
+	{
171
+		$alias = $this->getFqn($alias);
172
+		if ($this->isAliasForClass($alias, $for_class)) {
173
+			return $this->getFqnForAlias($this->aliases[ (string) $for_class ][ (string) $alias ], $for_class);
174
+		}
175
+		if ($this->isDirectAlias($alias)) {
176
+			// note: changed '' to $for_class
177
+			return $this->getFqnForAlias($this->aliases[ (string) $alias ], $for_class);
178
+		}
179
+		return $alias;
180
+	}
181
+
182
+
183
+	// public function debug($for_class = '')
184
+	// {
185
+	//     if ($for_class !== '') {
186
+	//         if ( ! isset($this->aliases[ $for_class ])) {
187
+	//             \EEH_Debug_Tools::printr('NOT FOUND', "aliases[ $for_class ]", __FILE__, __LINE__);
188
+	//             return;
189
+	//         }
190
+	//         \EEH_Debug_Tools::printr($this->aliases[ $for_class ], "aliases[ $for_class ]", __FILE__, __LINE__);
191
+	//         return;
192
+	//     }
193
+	//     \EEH_Debug_Tools::printr($this->aliases, '$this->aliases', __FILE__, __LINE__);
194
+	// }
195 195
 }
Please login to merge, or discard this patch.
core/services/shortcodes/ShortcodesManager.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function getShortcodes()
83 83
     {
84
-        if (! $this->shortcodes instanceof CollectionInterface) {
84
+        if ( ! $this->shortcodes instanceof CollectionInterface) {
85 85
             $this->shortcodes = $this->loadShortcodesCollection();
86 86
         }
87 87
         return $this->shortcodes;
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
                 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
139 139
                 $this->getShortcodes()
140 140
             );
141
-            if (! $this->shortcodes instanceof CollectionInterface) {
141
+            if ( ! $this->shortcodes instanceof CollectionInterface) {
142 142
                 throw new InvalidEntityException(
143 143
                     $this->shortcodes,
144 144
                     'CollectionInterface',
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
                     add_action('wp_enqueue_scripts', [$shortcode, 'enqueueStylesheets'], 11);
173 173
                 }
174 174
                 // add_shortcode() if it has not already been added
175
-                if (! shortcode_exists($shortcode->getTag())) {
175
+                if ( ! shortcode_exists($shortcode->getTag())) {
176 176
                     add_shortcode($shortcode->getTag(), [$shortcode, 'processShortcodeCallback']);
177 177
                 }
178 178
             }
Please login to merge, or discard this patch.
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -29,210 +29,210 @@
 block discarded – undo
29 29
  */
30 30
 class ShortcodesManager
31 31
 {
32
-    /**
33
-     * @type CurrentPage
34
-     */
35
-    protected $current_page;
36
-
37
-    /**
38
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
39
-     */
40
-    private $legacy_shortcodes_manager;
41
-
42
-    /**
43
-     * @var ShortcodeInterface[] $shortcodes
44
-     */
45
-    private $shortcodes;
46
-
47
-
48
-    /**
49
-     * ShortcodesManager constructor
50
-     *
51
-     * @param LegacyShortcodesManager $legacy_shortcodes_manager
52
-     * @param CurrentPage             $current_page
53
-     */
54
-    public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager, CurrentPage $current_page)
55
-    {
56
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
57
-        $this->current_page              = $current_page;
58
-        // assemble a list of installed and active shortcodes
59
-        add_action(
60
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
61
-            [$this, 'registerShortcodes'],
62
-            999
63
-        );
64
-        //  call add_shortcode() for all installed shortcodes
65
-        add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'addShortcodes']);
66
-        // check content for shortcodes the old way
67
-        add_action('parse_query', [$this->legacy_shortcodes_manager, 'initializeShortcodes'], 5);
68
-        // check content for shortcodes the NEW more efficient way
69
-        add_action('template_redirect', [$this, 'templateRedirect'], 999);
70
-    }
71
-
72
-
73
-    /**
74
-     * @return CollectionInterface|ShortcodeInterface[]
75
-     * @throws InvalidIdentifierException
76
-     * @throws InvalidInterfaceException
77
-     * @throws InvalidFilePathException
78
-     * @throws InvalidEntityException
79
-     * @throws InvalidDataTypeException
80
-     * @throws InvalidClassException
81
-     */
82
-    public function getShortcodes()
83
-    {
84
-        if (! $this->shortcodes instanceof CollectionInterface) {
85
-            $this->shortcodes = $this->loadShortcodesCollection();
86
-        }
87
-        return $this->shortcodes;
88
-    }
89
-
90
-
91
-    /**
92
-     * @return CollectionInterface|ShortcodeInterface[]
93
-     * @throws InvalidIdentifierException
94
-     * @throws InvalidInterfaceException
95
-     * @throws InvalidFilePathException
96
-     * @throws InvalidEntityException
97
-     * @throws InvalidDataTypeException
98
-     * @throws InvalidClassException
99
-     */
100
-    protected function loadShortcodesCollection()
101
-    {
102
-        $loader = new CollectionLoader(
103
-            new CollectionDetails(
104
-            // collection name
105
-                'shortcodes',
106
-                // collection interface
107
-                'EventEspresso\core\services\shortcodes\ShortcodeInterface',
108
-                // FQCNs for classes to add (all classes within that namespace will be loaded)
109
-                ['EventEspresso\core\domain\entities\shortcodes'],
110
-                // filepaths to classes to add
111
-                [],
112
-                // file mask to use if parsing folder for files to add
113
-                '',
114
-                // what to use as identifier for collection entities
115
-                // using CLASS NAME prevents duplicates (works like a singleton)
116
-                CollectionDetails::ID_CLASS_NAME
117
-            )
118
-        );
119
-        return $loader->getCollection();
120
-    }
121
-
122
-
123
-    /**
124
-     * @return void
125
-     * @throws DomainException
126
-     * @throws InvalidInterfaceException
127
-     * @throws InvalidIdentifierException
128
-     * @throws InvalidFilePathException
129
-     * @throws InvalidEntityException
130
-     * @throws InvalidDataTypeException
131
-     * @throws InvalidClassException
132
-     * @throws Exception
133
-     */
134
-    public function registerShortcodes()
135
-    {
136
-        try {
137
-            $this->shortcodes = apply_filters(
138
-                'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
139
-                $this->getShortcodes()
140
-            );
141
-            if (! $this->shortcodes instanceof CollectionInterface) {
142
-                throw new InvalidEntityException(
143
-                    $this->shortcodes,
144
-                    'CollectionInterface',
145
-                    sprintf(
146
-                        esc_html__(
147
-                            'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.',
148
-                            'event_espresso'
149
-                        ),
150
-                        is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes)
151
-                    )
152
-                );
153
-            }
154
-            $this->legacy_shortcodes_manager->registerShortcodes();
155
-        } catch (Exception $exception) {
156
-            new ExceptionStackTraceDisplay($exception);
157
-        }
158
-    }
159
-
160
-
161
-    /**
162
-     * @return void
163
-     * @throws Exception
164
-     */
165
-    public function addShortcodes()
166
-    {
167
-        try {
168
-            // cycle thru shortcode folders
169
-            foreach ($this->shortcodes as $shortcode) {
170
-                if ($shortcode instanceof EnqueueAssetsInterface) {
171
-                    add_action('wp_enqueue_scripts', [$shortcode, 'registerScriptsAndStylesheets'], 10);
172
-                    add_action('wp_enqueue_scripts', [$shortcode, 'enqueueStylesheets'], 11);
173
-                }
174
-                // add_shortcode() if it has not already been added
175
-                if (! shortcode_exists($shortcode->getTag())) {
176
-                    add_shortcode($shortcode->getTag(), [$shortcode, 'processShortcodeCallback']);
177
-                }
178
-            }
179
-            $this->legacy_shortcodes_manager->addShortcodes();
180
-        } catch (Exception $exception) {
181
-            new ExceptionStackTraceDisplay($exception);
182
-        }
183
-    }
184
-
185
-
186
-    /**
187
-     * callback for the "template_redirect" hook point
188
-     * checks posts for EE shortcodes, and initializes them,
189
-     * then toggles filter switch that loads core default assets
190
-     *
191
-     * @return void
192
-     */
193
-    public function templateRedirect()
194
-    {
195
-        global $wp_query;
196
-        if (empty($wp_query->posts)) {
197
-            return;
198
-        }
199
-        $load_assets = false;
200
-        // array of posts displayed in current request
201
-        $posts = is_array($wp_query->posts) ? $wp_query->posts : [$wp_query->posts];
202
-        foreach ($posts as $post) {
203
-            // now check post content and excerpt for EE shortcodes
204
-            $load_assets = $this->parseContentForShortcodes($post->post_content)
205
-                ? true
206
-                : $load_assets;
207
-        }
208
-        if ($load_assets) {
209
-            $this->current_page->setEspressoPage(true);
210
-            add_filter('FHEE_load_css', '__return_true');
211
-            add_filter('FHEE_load_js', '__return_true');
212
-        }
213
-    }
214
-
215
-
216
-    /**
217
-     * checks supplied content against list of shortcodes,
218
-     * then initializes any found shortcodes, and returns true.
219
-     * returns false if no shortcodes found.
220
-     *
221
-     * @param string $content
222
-     * @return bool
223
-     */
224
-    public function parseContentForShortcodes($content)
225
-    {
226
-        if (empty($this->shortcodes)) {
227
-            return false;
228
-        }
229
-        $has_shortcode = false;
230
-        foreach ($this->shortcodes as $shortcode) {
231
-            if (has_shortcode($content, $shortcode->getTag())) {
232
-                $shortcode->initializeShortcode();
233
-                $has_shortcode = true;
234
-            }
235
-        }
236
-        return $has_shortcode;
237
-    }
32
+	/**
33
+	 * @type CurrentPage
34
+	 */
35
+	protected $current_page;
36
+
37
+	/**
38
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
39
+	 */
40
+	private $legacy_shortcodes_manager;
41
+
42
+	/**
43
+	 * @var ShortcodeInterface[] $shortcodes
44
+	 */
45
+	private $shortcodes;
46
+
47
+
48
+	/**
49
+	 * ShortcodesManager constructor
50
+	 *
51
+	 * @param LegacyShortcodesManager $legacy_shortcodes_manager
52
+	 * @param CurrentPage             $current_page
53
+	 */
54
+	public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager, CurrentPage $current_page)
55
+	{
56
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
57
+		$this->current_page              = $current_page;
58
+		// assemble a list of installed and active shortcodes
59
+		add_action(
60
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
61
+			[$this, 'registerShortcodes'],
62
+			999
63
+		);
64
+		//  call add_shortcode() for all installed shortcodes
65
+		add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'addShortcodes']);
66
+		// check content for shortcodes the old way
67
+		add_action('parse_query', [$this->legacy_shortcodes_manager, 'initializeShortcodes'], 5);
68
+		// check content for shortcodes the NEW more efficient way
69
+		add_action('template_redirect', [$this, 'templateRedirect'], 999);
70
+	}
71
+
72
+
73
+	/**
74
+	 * @return CollectionInterface|ShortcodeInterface[]
75
+	 * @throws InvalidIdentifierException
76
+	 * @throws InvalidInterfaceException
77
+	 * @throws InvalidFilePathException
78
+	 * @throws InvalidEntityException
79
+	 * @throws InvalidDataTypeException
80
+	 * @throws InvalidClassException
81
+	 */
82
+	public function getShortcodes()
83
+	{
84
+		if (! $this->shortcodes instanceof CollectionInterface) {
85
+			$this->shortcodes = $this->loadShortcodesCollection();
86
+		}
87
+		return $this->shortcodes;
88
+	}
89
+
90
+
91
+	/**
92
+	 * @return CollectionInterface|ShortcodeInterface[]
93
+	 * @throws InvalidIdentifierException
94
+	 * @throws InvalidInterfaceException
95
+	 * @throws InvalidFilePathException
96
+	 * @throws InvalidEntityException
97
+	 * @throws InvalidDataTypeException
98
+	 * @throws InvalidClassException
99
+	 */
100
+	protected function loadShortcodesCollection()
101
+	{
102
+		$loader = new CollectionLoader(
103
+			new CollectionDetails(
104
+			// collection name
105
+				'shortcodes',
106
+				// collection interface
107
+				'EventEspresso\core\services\shortcodes\ShortcodeInterface',
108
+				// FQCNs for classes to add (all classes within that namespace will be loaded)
109
+				['EventEspresso\core\domain\entities\shortcodes'],
110
+				// filepaths to classes to add
111
+				[],
112
+				// file mask to use if parsing folder for files to add
113
+				'',
114
+				// what to use as identifier for collection entities
115
+				// using CLASS NAME prevents duplicates (works like a singleton)
116
+				CollectionDetails::ID_CLASS_NAME
117
+			)
118
+		);
119
+		return $loader->getCollection();
120
+	}
121
+
122
+
123
+	/**
124
+	 * @return void
125
+	 * @throws DomainException
126
+	 * @throws InvalidInterfaceException
127
+	 * @throws InvalidIdentifierException
128
+	 * @throws InvalidFilePathException
129
+	 * @throws InvalidEntityException
130
+	 * @throws InvalidDataTypeException
131
+	 * @throws InvalidClassException
132
+	 * @throws Exception
133
+	 */
134
+	public function registerShortcodes()
135
+	{
136
+		try {
137
+			$this->shortcodes = apply_filters(
138
+				'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
139
+				$this->getShortcodes()
140
+			);
141
+			if (! $this->shortcodes instanceof CollectionInterface) {
142
+				throw new InvalidEntityException(
143
+					$this->shortcodes,
144
+					'CollectionInterface',
145
+					sprintf(
146
+						esc_html__(
147
+							'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.',
148
+							'event_espresso'
149
+						),
150
+						is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes)
151
+					)
152
+				);
153
+			}
154
+			$this->legacy_shortcodes_manager->registerShortcodes();
155
+		} catch (Exception $exception) {
156
+			new ExceptionStackTraceDisplay($exception);
157
+		}
158
+	}
159
+
160
+
161
+	/**
162
+	 * @return void
163
+	 * @throws Exception
164
+	 */
165
+	public function addShortcodes()
166
+	{
167
+		try {
168
+			// cycle thru shortcode folders
169
+			foreach ($this->shortcodes as $shortcode) {
170
+				if ($shortcode instanceof EnqueueAssetsInterface) {
171
+					add_action('wp_enqueue_scripts', [$shortcode, 'registerScriptsAndStylesheets'], 10);
172
+					add_action('wp_enqueue_scripts', [$shortcode, 'enqueueStylesheets'], 11);
173
+				}
174
+				// add_shortcode() if it has not already been added
175
+				if (! shortcode_exists($shortcode->getTag())) {
176
+					add_shortcode($shortcode->getTag(), [$shortcode, 'processShortcodeCallback']);
177
+				}
178
+			}
179
+			$this->legacy_shortcodes_manager->addShortcodes();
180
+		} catch (Exception $exception) {
181
+			new ExceptionStackTraceDisplay($exception);
182
+		}
183
+	}
184
+
185
+
186
+	/**
187
+	 * callback for the "template_redirect" hook point
188
+	 * checks posts for EE shortcodes, and initializes them,
189
+	 * then toggles filter switch that loads core default assets
190
+	 *
191
+	 * @return void
192
+	 */
193
+	public function templateRedirect()
194
+	{
195
+		global $wp_query;
196
+		if (empty($wp_query->posts)) {
197
+			return;
198
+		}
199
+		$load_assets = false;
200
+		// array of posts displayed in current request
201
+		$posts = is_array($wp_query->posts) ? $wp_query->posts : [$wp_query->posts];
202
+		foreach ($posts as $post) {
203
+			// now check post content and excerpt for EE shortcodes
204
+			$load_assets = $this->parseContentForShortcodes($post->post_content)
205
+				? true
206
+				: $load_assets;
207
+		}
208
+		if ($load_assets) {
209
+			$this->current_page->setEspressoPage(true);
210
+			add_filter('FHEE_load_css', '__return_true');
211
+			add_filter('FHEE_load_js', '__return_true');
212
+		}
213
+	}
214
+
215
+
216
+	/**
217
+	 * checks supplied content against list of shortcodes,
218
+	 * then initializes any found shortcodes, and returns true.
219
+	 * returns false if no shortcodes found.
220
+	 *
221
+	 * @param string $content
222
+	 * @return bool
223
+	 */
224
+	public function parseContentForShortcodes($content)
225
+	{
226
+		if (empty($this->shortcodes)) {
227
+			return false;
228
+		}
229
+		$has_shortcode = false;
230
+		foreach ($this->shortcodes as $shortcode) {
231
+			if (has_shortcode($content, $shortcode->getTag())) {
232
+				$shortcode->initializeShortcode();
233
+				$has_shortcode = true;
234
+			}
235
+		}
236
+		return $has_shortcode;
237
+	}
238 238
 }
Please login to merge, or discard this patch.
core/libraries/iframe_display/Iframe.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     public function __construct($title, $content)
84 84
     {
85 85
         global $wp_version;
86
-        if (! defined('EE_IFRAME_DIR_URL')) {
86
+        if ( ! defined('EE_IFRAME_DIR_URL')) {
87 87
             define('EE_IFRAME_DIR_URL', plugin_dir_url(__FILE__));
88 88
         }
89 89
         $this->setContent($content);
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
                 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css',
94 94
                 array(
95 95
                     'site_theme'       => get_stylesheet_directory_uri()
96
-                                          . '/style.css?ver=' . EVENT_ESPRESSO_VERSION,
97
-                    'dashicons'        => includes_url('css/dashicons.min.css?ver=' . $wp_version),
96
+                                          . '/style.css?ver='.EVENT_ESPRESSO_VERSION,
97
+                    'dashicons'        => includes_url('css/dashicons.min.css?ver='.$wp_version),
98 98
                     'espresso_default' => EE_GLOBAL_ASSETS_URL
99
-                                          . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
99
+                                          . 'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION,
100 100
                 ),
101 101
                 $this
102 102
             )
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
             apply_filters(
106 106
                 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js',
107 107
                 array(
108
-                    'jquery'        => includes_url('js/jquery/jquery.js?ver=' . $wp_version),
108
+                    'jquery'        => includes_url('js/jquery/jquery.js?ver='.$wp_version),
109 109
                     'espresso_core' => EE_GLOBAL_ASSETS_URL
110
-                                       . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
110
+                                       . 'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION,
111 111
                 ),
112 112
                 $this
113 113
             )
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             );
182 182
         }
183 183
         foreach ($stylesheets as $handle => $stylesheet) {
184
-            $this->css[ $handle ] = $stylesheet;
184
+            $this->css[$handle] = $stylesheet;
185 185
         }
186 186
     }
187 187
 
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
         }
204 204
         foreach ($scripts as $handle => $script) {
205 205
             if ($add_to_header) {
206
-                $this->header_js[ $handle ] = $script;
206
+                $this->header_js[$handle] = $script;
207 207
             } else {
208
-                $this->footer_js[ $handle ] = $script;
208
+                $this->footer_js[$handle] = $script;
209 209
             }
210 210
         }
211 211
     }
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
         }
229 229
         foreach ($script_attributes as $handle => $script_attribute) {
230 230
             if ($add_to_header) {
231
-                $this->header_js_attributes[ $handle ] = $script_attribute;
231
+                $this->header_js_attributes[$handle] = $script_attribute;
232 232
             } else {
233
-                $this->footer_js_attributes[ $handle ] = $script_attribute;
233
+                $this->footer_js_attributes[$handle] = $script_attribute;
234 234
             }
235 235
         }
236 236
     }
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
         }
254 254
         foreach ($vars as $handle => $var) {
255 255
             if ($var_name === 'eei18n') {
256
-                EE_Registry::$i18n_js_strings[ $handle ] = $var;
256
+                EE_Registry::$i18n_js_strings[$handle] = $var;
257 257
             } elseif ($var_name === 'eeCAL' && $handle === 'espresso_calendar') {
258
-                $this->localized_vars[ $var_name ] = $var;
258
+                $this->localized_vars[$var_name] = $var;
259 259
             } else {
260
-                if (! isset($this->localized_vars[ $var_name ])) {
261
-                    $this->localized_vars[ $var_name ] = array();
260
+                if ( ! isset($this->localized_vars[$var_name])) {
261
+                    $this->localized_vars[$var_name] = array();
262 262
                 }
263
-                $this->localized_vars[ $var_name ][ $handle ] = $var;
263
+                $this->localized_vars[$var_name][$handle] = $var;
264 264
             }
265 265
         }
266 266
     }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
     public function getTemplate()
291 291
     {
292 292
         return EEH_Template::display_template(
293
-            __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php',
293
+            __DIR__.DIRECTORY_SEPARATOR.'iframe_wrapper.template.php',
294 294
             array(
295 295
                 'title'                => apply_filters(
296 296
                     'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title',
@@ -334,11 +334,11 @@  discard block
 block discarded – undo
334 334
                 ),
335 335
                 'eei18n'               => apply_filters(
336 336
                     'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings',
337
-                    EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(),
337
+                    EE_Registry::localize_i18n_js_strings().$this->localizeJsonVars(),
338 338
                     $this
339 339
                 ),
340 340
                 'notices'              => EEH_Template::display_template(
341
-                    EE_TEMPLATES . 'espresso-ajax-notices.template.php',
341
+                    EE_TEMPLATES.'espresso-ajax-notices.template.php',
342 342
                     array(),
343 343
                     true
344 344
                 ),
@@ -358,9 +358,9 @@  discard block
 block discarded – undo
358 358
     {
359 359
         $JSON = '';
360 360
         foreach ($this->localized_vars as $var_name => $vars) {
361
-            $this->localized_vars[ $var_name ] = $this->encodeJsonVars($vars);
361
+            $this->localized_vars[$var_name] = $this->encodeJsonVars($vars);
362 362
             $JSON .= "/* <![CDATA[ */ var {$var_name} = ";
363
-            $JSON .= wp_json_encode($this->localized_vars[ $var_name ]);
363
+            $JSON .= wp_json_encode($this->localized_vars[$var_name]);
364 364
             $JSON .= '; /* ]]> */';
365 365
         }
366 366
         return $JSON;
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
         if (is_array($var)) {
377 377
             $localized_vars = array();
378 378
             foreach ((array) $var as $key => $value) {
379
-                $localized_vars[ $key ] = $this->encodeJsonVars($value);
379
+                $localized_vars[$key] = $this->encodeJsonVars($value);
380 380
             }
381 381
             return $localized_vars;
382 382
         }
Please login to merge, or discard this patch.
Indentation   +334 added lines, -334 removed lines patch added patch discarded remove patch
@@ -17,373 +17,373 @@
 block discarded – undo
17 17
  */
18 18
 class Iframe
19 19
 {
20
-    /*
20
+	/*
21 21
     * HTML for notices and ajax gif
22 22
     * @var string $title
23 23
     */
24
-    protected $title = '';
24
+	protected $title = '';
25 25
 
26
-    /*
26
+	/*
27 27
     * HTML for the content being displayed
28 28
     * @var string $content
29 29
     */
30
-    protected $content = '';
30
+	protected $content = '';
31 31
 
32
-    /*
32
+	/*
33 33
     * whether or not to call wp_head() and wp_footer()
34 34
     * @var boolean $enqueue_wp_assets
35 35
     */
36
-    protected $enqueue_wp_assets = false;
36
+	protected $enqueue_wp_assets = false;
37 37
 
38
-    /*
38
+	/*
39 39
     * an array of CSS URLs
40 40
     * @var array $css
41 41
     */
42
-    protected $css = array();
42
+	protected $css = array();
43 43
 
44
-    /*
44
+	/*
45 45
     * an array of JS URLs to be set in the HTML header.
46 46
     * @var array $header_js
47 47
     */
48
-    protected $header_js = array();
48
+	protected $header_js = array();
49 49
 
50
-    /*
50
+	/*
51 51
     * an array of additional attributes to be added to <script> tags for header JS
52 52
     * @var array $footer_js
53 53
     */
54
-    protected $header_js_attributes = array();
54
+	protected $header_js_attributes = array();
55 55
 
56
-    /*
56
+	/*
57 57
     * an array of JS URLs to be displayed before the HTML </body> tag
58 58
     * @var array $footer_js
59 59
     */
60
-    protected $footer_js = array();
60
+	protected $footer_js = array();
61 61
 
62
-    /*
62
+	/*
63 63
     * an array of additional attributes to be added to <script> tags for footer JS
64 64
     * @var array $footer_js_attributes
65 65
     */
66
-    protected $footer_js_attributes = array();
66
+	protected $footer_js_attributes = array();
67 67
 
68
-    /*
68
+	/*
69 69
     * an array of JSON vars to be set in the HTML header.
70 70
     * @var array $localized_vars
71 71
     */
72
-    protected $localized_vars = array();
73
-
74
-
75
-    /**
76
-     * Iframe constructor
77
-     *
78
-     * @param string $title
79
-     * @param string $content
80
-     * @throws DomainException
81
-     */
82
-    public function __construct($title, $content)
83
-    {
84
-        global $wp_version;
85
-        if (! defined('EE_IFRAME_DIR_URL')) {
86
-            define('EE_IFRAME_DIR_URL', plugin_dir_url(__FILE__));
87
-        }
88
-        $this->setContent($content);
89
-        $this->setTitle($title);
90
-        $this->addStylesheets(
91
-            apply_filters(
92
-                'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css',
93
-                array(
94
-                    'site_theme'       => get_stylesheet_directory_uri()
95
-                                          . '/style.css?ver=' . EVENT_ESPRESSO_VERSION,
96
-                    'dashicons'        => includes_url('css/dashicons.min.css?ver=' . $wp_version),
97
-                    'espresso_default' => EE_GLOBAL_ASSETS_URL
98
-                                          . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
99
-                ),
100
-                $this
101
-            )
102
-        );
103
-        $this->addScripts(
104
-            apply_filters(
105
-                'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js',
106
-                array(
107
-                    'jquery'        => includes_url('js/jquery/jquery.js?ver=' . $wp_version),
108
-                    'espresso_core' => EE_GLOBAL_ASSETS_URL
109
-                                       . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
110
-                ),
111
-                $this
112
-            )
113
-        );
114
-        if (
115
-            apply_filters(
116
-                'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__load_default_theme_stylesheet',
117
-                false
118
-            )
119
-        ) {
120
-            $this->addStylesheets(
121
-                apply_filters(
122
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_theme_stylesheet',
123
-                    array('default_theme_stylesheet' => get_stylesheet_uri()),
124
-                    $this
125
-                )
126
-            );
127
-        }
128
-    }
129
-
130
-
131
-    /**
132
-     * @param string $title
133
-     * @throws DomainException
134
-     */
135
-    public function setTitle($title)
136
-    {
137
-        if (empty($title)) {
138
-            throw new DomainException(
139
-                esc_html__('You must provide a page title in order to create an iframe.', 'event_espresso')
140
-            );
141
-        }
142
-        $this->title = $title;
143
-    }
144
-
145
-
146
-    /**
147
-     * @param string $content
148
-     * @throws DomainException
149
-     */
150
-    public function setContent($content)
151
-    {
152
-        if (empty($content)) {
153
-            throw new DomainException(
154
-                esc_html__('You must provide content in order to create an iframe.', 'event_espresso')
155
-            );
156
-        }
157
-        $this->content = $content;
158
-    }
159
-
160
-
161
-    /**
162
-     * @param boolean $enqueue_wp_assets
163
-     */
164
-    public function setEnqueueWpAssets($enqueue_wp_assets)
165
-    {
166
-        $this->enqueue_wp_assets = filter_var($enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN);
167
-    }
168
-
169
-
170
-    /**
171
-     * @param array $stylesheets
172
-     * @throws DomainException
173
-     */
174
-    public function addStylesheets(array $stylesheets)
175
-    {
176
-        if (empty($stylesheets)) {
177
-            throw new DomainException(
178
-                esc_html__(
179
-                    'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.',
180
-                    'event_espresso'
181
-                )
182
-            );
183
-        }
184
-        foreach ($stylesheets as $handle => $stylesheet) {
185
-            $this->css[ $handle ] = $stylesheet;
186
-        }
187
-    }
188
-
189
-
190
-    /**
191
-     * @param array $scripts
192
-     * @param bool  $add_to_header
193
-     * @throws DomainException
194
-     */
195
-    public function addScripts(array $scripts, $add_to_header = false)
196
-    {
197
-        if (empty($scripts)) {
198
-            throw new DomainException(
199
-                esc_html__(
200
-                    'A non-empty array of URLs, is required to add Javascript to an iframe.',
201
-                    'event_espresso'
202
-                )
203
-            );
204
-        }
205
-        foreach ($scripts as $handle => $script) {
206
-            if ($add_to_header) {
207
-                $this->header_js[ $handle ] = $script;
208
-            } else {
209
-                $this->footer_js[ $handle ] = $script;
210
-            }
211
-        }
212
-    }
213
-
214
-
215
-    /**
216
-     * @param array $script_attributes
217
-     * @param bool  $add_to_header
218
-     * @throws DomainException
219
-     */
220
-    public function addScriptAttributes(array $script_attributes, $add_to_header = false)
221
-    {
222
-        if (empty($script_attributes)) {
223
-            throw new DomainException(
224
-                esc_html__(
225
-                    'A non-empty array of strings, is required to add attributes to iframe Javascript.',
226
-                    'event_espresso'
227
-                )
228
-            );
229
-        }
230
-        foreach ($script_attributes as $handle => $script_attribute) {
231
-            if ($add_to_header) {
232
-                $this->header_js_attributes[ $handle ] = $script_attribute;
233
-            } else {
234
-                $this->footer_js_attributes[ $handle ] = $script_attribute;
235
-            }
236
-        }
237
-    }
238
-
239
-
240
-    /**
241
-     * @param array  $vars
242
-     * @param string $var_name
243
-     * @throws DomainException
244
-     */
245
-    public function addLocalizedVars(array $vars, $var_name = 'eei18n')
246
-    {
247
-        if (empty($vars)) {
248
-            throw new DomainException(
249
-                esc_html__(
250
-                    'A non-empty array of vars, is required to add localized Javascript vars to an iframe.',
251
-                    'event_espresso'
252
-                )
253
-            );
254
-        }
255
-        foreach ($vars as $handle => $var) {
256
-            if ($var_name === 'eei18n') {
257
-                EE_Registry::$i18n_js_strings[ $handle ] = $var;
258
-            } elseif ($var_name === 'eeCAL' && $handle === 'espresso_calendar') {
259
-                $this->localized_vars[ $var_name ] = $var;
260
-            } else {
261
-                if (! isset($this->localized_vars[ $var_name ])) {
262
-                    $this->localized_vars[ $var_name ] = array();
263
-                }
264
-                $this->localized_vars[ $var_name ][ $handle ] = $var;
265
-            }
266
-        }
267
-    }
268
-
269
-
270
-    /**
271
-     * @param string $utm_content
272
-     * @throws DomainException
273
-     */
274
-    public function display($utm_content = '')
275
-    {
276
-        $this->content .= EEH_Template::powered_by_event_espresso(
277
-            '',
278
-            '',
279
-            ! empty($utm_content) ? array('utm_content' => $utm_content) : array()
280
-        );
281
-        EE_System::do_not_cache();
282
-        echo $this->getTemplate(); // already escaped
283
-        exit;
284
-    }
285
-
286
-
287
-    /**
288
-     * @return string
289
-     * @throws DomainException
290
-     */
291
-    public function getTemplate()
292
-    {
293
-        return EEH_Template::display_template(
294
-            __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php',
295
-            array(
296
-                'title'                => apply_filters(
297
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title',
298
-                    $this->title,
299
-                    $this
300
-                ),
301
-                'content'              => apply_filters(
302
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__content',
303
-                    $this->content,
304
-                    $this
305
-                ),
306
-                'enqueue_wp_assets'    => apply_filters(
307
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__enqueue_wp_assets',
308
-                    $this->enqueue_wp_assets,
309
-                    $this
310
-                ),
311
-                'css'                  => (array) apply_filters(
312
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls',
313
-                    $this->css,
314
-                    $this
315
-                ),
316
-                'header_js'            => (array) apply_filters(
317
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls',
318
-                    $this->header_js,
319
-                    $this
320
-                ),
321
-                'header_js_attributes' => (array) apply_filters(
322
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_attributes',
323
-                    $this->header_js_attributes,
324
-                    $this
325
-                ),
326
-                'footer_js'            => (array) apply_filters(
327
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls',
328
-                    $this->footer_js,
329
-                    $this
330
-                ),
331
-                'footer_js_attributes' => (array) apply_filters(
332
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_attributes',
333
-                    $this->footer_js_attributes,
334
-                    $this
335
-                ),
336
-                'eei18n'               => apply_filters(
337
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings',
338
-                    EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(),
339
-                    $this
340
-                ),
341
-                'notices'              => EEH_Template::display_template(
342
-                    EE_TEMPLATES . 'espresso-ajax-notices.template.php',
343
-                    array(),
344
-                    true
345
-                ),
346
-            ),
347
-            true,
348
-            true
349
-        );
350
-    }
351
-
352
-
353
-    /**
354
-     * localizeJsonVars
355
-     *
356
-     * @return string
357
-     */
358
-    public function localizeJsonVars()
359
-    {
360
-        $JSON = '';
361
-        foreach ($this->localized_vars as $var_name => $vars) {
362
-            $this->localized_vars[ $var_name ] = $this->encodeJsonVars($vars);
363
-            $JSON .= "/* <![CDATA[ */ var {$var_name} = ";
364
-            $JSON .= wp_json_encode($this->localized_vars[ $var_name ]);
365
-            $JSON .= '; /* ]]> */';
366
-        }
367
-        return $JSON;
368
-    }
369
-
370
-
371
-    /**
372
-     * @param bool|int|float|string|array $var
373
-     * @return array|string|null
374
-     */
375
-    public function encodeJsonVars($var)
376
-    {
377
-        if (is_array($var)) {
378
-            $localized_vars = array();
379
-            foreach ((array) $var as $key => $value) {
380
-                $localized_vars[ $key ] = $this->encodeJsonVars($value);
381
-            }
382
-            return $localized_vars;
383
-        }
384
-        if (is_scalar($var)) {
385
-            return html_entity_decode((string) $var, ENT_QUOTES, 'UTF-8');
386
-        }
387
-        return null;
388
-    }
72
+	protected $localized_vars = array();
73
+
74
+
75
+	/**
76
+	 * Iframe constructor
77
+	 *
78
+	 * @param string $title
79
+	 * @param string $content
80
+	 * @throws DomainException
81
+	 */
82
+	public function __construct($title, $content)
83
+	{
84
+		global $wp_version;
85
+		if (! defined('EE_IFRAME_DIR_URL')) {
86
+			define('EE_IFRAME_DIR_URL', plugin_dir_url(__FILE__));
87
+		}
88
+		$this->setContent($content);
89
+		$this->setTitle($title);
90
+		$this->addStylesheets(
91
+			apply_filters(
92
+				'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css',
93
+				array(
94
+					'site_theme'       => get_stylesheet_directory_uri()
95
+										  . '/style.css?ver=' . EVENT_ESPRESSO_VERSION,
96
+					'dashicons'        => includes_url('css/dashicons.min.css?ver=' . $wp_version),
97
+					'espresso_default' => EE_GLOBAL_ASSETS_URL
98
+										  . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
99
+				),
100
+				$this
101
+			)
102
+		);
103
+		$this->addScripts(
104
+			apply_filters(
105
+				'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js',
106
+				array(
107
+					'jquery'        => includes_url('js/jquery/jquery.js?ver=' . $wp_version),
108
+					'espresso_core' => EE_GLOBAL_ASSETS_URL
109
+									   . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
110
+				),
111
+				$this
112
+			)
113
+		);
114
+		if (
115
+			apply_filters(
116
+				'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__load_default_theme_stylesheet',
117
+				false
118
+			)
119
+		) {
120
+			$this->addStylesheets(
121
+				apply_filters(
122
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_theme_stylesheet',
123
+					array('default_theme_stylesheet' => get_stylesheet_uri()),
124
+					$this
125
+				)
126
+			);
127
+		}
128
+	}
129
+
130
+
131
+	/**
132
+	 * @param string $title
133
+	 * @throws DomainException
134
+	 */
135
+	public function setTitle($title)
136
+	{
137
+		if (empty($title)) {
138
+			throw new DomainException(
139
+				esc_html__('You must provide a page title in order to create an iframe.', 'event_espresso')
140
+			);
141
+		}
142
+		$this->title = $title;
143
+	}
144
+
145
+
146
+	/**
147
+	 * @param string $content
148
+	 * @throws DomainException
149
+	 */
150
+	public function setContent($content)
151
+	{
152
+		if (empty($content)) {
153
+			throw new DomainException(
154
+				esc_html__('You must provide content in order to create an iframe.', 'event_espresso')
155
+			);
156
+		}
157
+		$this->content = $content;
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param boolean $enqueue_wp_assets
163
+	 */
164
+	public function setEnqueueWpAssets($enqueue_wp_assets)
165
+	{
166
+		$this->enqueue_wp_assets = filter_var($enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN);
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param array $stylesheets
172
+	 * @throws DomainException
173
+	 */
174
+	public function addStylesheets(array $stylesheets)
175
+	{
176
+		if (empty($stylesheets)) {
177
+			throw new DomainException(
178
+				esc_html__(
179
+					'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.',
180
+					'event_espresso'
181
+				)
182
+			);
183
+		}
184
+		foreach ($stylesheets as $handle => $stylesheet) {
185
+			$this->css[ $handle ] = $stylesheet;
186
+		}
187
+	}
188
+
189
+
190
+	/**
191
+	 * @param array $scripts
192
+	 * @param bool  $add_to_header
193
+	 * @throws DomainException
194
+	 */
195
+	public function addScripts(array $scripts, $add_to_header = false)
196
+	{
197
+		if (empty($scripts)) {
198
+			throw new DomainException(
199
+				esc_html__(
200
+					'A non-empty array of URLs, is required to add Javascript to an iframe.',
201
+					'event_espresso'
202
+				)
203
+			);
204
+		}
205
+		foreach ($scripts as $handle => $script) {
206
+			if ($add_to_header) {
207
+				$this->header_js[ $handle ] = $script;
208
+			} else {
209
+				$this->footer_js[ $handle ] = $script;
210
+			}
211
+		}
212
+	}
213
+
214
+
215
+	/**
216
+	 * @param array $script_attributes
217
+	 * @param bool  $add_to_header
218
+	 * @throws DomainException
219
+	 */
220
+	public function addScriptAttributes(array $script_attributes, $add_to_header = false)
221
+	{
222
+		if (empty($script_attributes)) {
223
+			throw new DomainException(
224
+				esc_html__(
225
+					'A non-empty array of strings, is required to add attributes to iframe Javascript.',
226
+					'event_espresso'
227
+				)
228
+			);
229
+		}
230
+		foreach ($script_attributes as $handle => $script_attribute) {
231
+			if ($add_to_header) {
232
+				$this->header_js_attributes[ $handle ] = $script_attribute;
233
+			} else {
234
+				$this->footer_js_attributes[ $handle ] = $script_attribute;
235
+			}
236
+		}
237
+	}
238
+
239
+
240
+	/**
241
+	 * @param array  $vars
242
+	 * @param string $var_name
243
+	 * @throws DomainException
244
+	 */
245
+	public function addLocalizedVars(array $vars, $var_name = 'eei18n')
246
+	{
247
+		if (empty($vars)) {
248
+			throw new DomainException(
249
+				esc_html__(
250
+					'A non-empty array of vars, is required to add localized Javascript vars to an iframe.',
251
+					'event_espresso'
252
+				)
253
+			);
254
+		}
255
+		foreach ($vars as $handle => $var) {
256
+			if ($var_name === 'eei18n') {
257
+				EE_Registry::$i18n_js_strings[ $handle ] = $var;
258
+			} elseif ($var_name === 'eeCAL' && $handle === 'espresso_calendar') {
259
+				$this->localized_vars[ $var_name ] = $var;
260
+			} else {
261
+				if (! isset($this->localized_vars[ $var_name ])) {
262
+					$this->localized_vars[ $var_name ] = array();
263
+				}
264
+				$this->localized_vars[ $var_name ][ $handle ] = $var;
265
+			}
266
+		}
267
+	}
268
+
269
+
270
+	/**
271
+	 * @param string $utm_content
272
+	 * @throws DomainException
273
+	 */
274
+	public function display($utm_content = '')
275
+	{
276
+		$this->content .= EEH_Template::powered_by_event_espresso(
277
+			'',
278
+			'',
279
+			! empty($utm_content) ? array('utm_content' => $utm_content) : array()
280
+		);
281
+		EE_System::do_not_cache();
282
+		echo $this->getTemplate(); // already escaped
283
+		exit;
284
+	}
285
+
286
+
287
+	/**
288
+	 * @return string
289
+	 * @throws DomainException
290
+	 */
291
+	public function getTemplate()
292
+	{
293
+		return EEH_Template::display_template(
294
+			__DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php',
295
+			array(
296
+				'title'                => apply_filters(
297
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title',
298
+					$this->title,
299
+					$this
300
+				),
301
+				'content'              => apply_filters(
302
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__content',
303
+					$this->content,
304
+					$this
305
+				),
306
+				'enqueue_wp_assets'    => apply_filters(
307
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__enqueue_wp_assets',
308
+					$this->enqueue_wp_assets,
309
+					$this
310
+				),
311
+				'css'                  => (array) apply_filters(
312
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls',
313
+					$this->css,
314
+					$this
315
+				),
316
+				'header_js'            => (array) apply_filters(
317
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls',
318
+					$this->header_js,
319
+					$this
320
+				),
321
+				'header_js_attributes' => (array) apply_filters(
322
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_attributes',
323
+					$this->header_js_attributes,
324
+					$this
325
+				),
326
+				'footer_js'            => (array) apply_filters(
327
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls',
328
+					$this->footer_js,
329
+					$this
330
+				),
331
+				'footer_js_attributes' => (array) apply_filters(
332
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_attributes',
333
+					$this->footer_js_attributes,
334
+					$this
335
+				),
336
+				'eei18n'               => apply_filters(
337
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings',
338
+					EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(),
339
+					$this
340
+				),
341
+				'notices'              => EEH_Template::display_template(
342
+					EE_TEMPLATES . 'espresso-ajax-notices.template.php',
343
+					array(),
344
+					true
345
+				),
346
+			),
347
+			true,
348
+			true
349
+		);
350
+	}
351
+
352
+
353
+	/**
354
+	 * localizeJsonVars
355
+	 *
356
+	 * @return string
357
+	 */
358
+	public function localizeJsonVars()
359
+	{
360
+		$JSON = '';
361
+		foreach ($this->localized_vars as $var_name => $vars) {
362
+			$this->localized_vars[ $var_name ] = $this->encodeJsonVars($vars);
363
+			$JSON .= "/* <![CDATA[ */ var {$var_name} = ";
364
+			$JSON .= wp_json_encode($this->localized_vars[ $var_name ]);
365
+			$JSON .= '; /* ]]> */';
366
+		}
367
+		return $JSON;
368
+	}
369
+
370
+
371
+	/**
372
+	 * @param bool|int|float|string|array $var
373
+	 * @return array|string|null
374
+	 */
375
+	public function encodeJsonVars($var)
376
+	{
377
+		if (is_array($var)) {
378
+			$localized_vars = array();
379
+			foreach ((array) $var as $key => $value) {
380
+				$localized_vars[ $key ] = $this->encodeJsonVars($value);
381
+			}
382
+			return $localized_vars;
383
+		}
384
+		if (is_scalar($var)) {
385
+			return html_entity_decode((string) $var, ENT_QUOTES, 'UTF-8');
386
+		}
387
+		return null;
388
+	}
389 389
 }
Please login to merge, or discard this patch.
modules/events_archive/EventsArchiveIframe.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
             apply_filters(
48 48
                 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
49 49
                 [
50
-                    'espresso_default' => is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
51
-                        ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
52
-                        : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
50
+                    'espresso_default' => is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')
51
+                        ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION
52
+                        : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION,
53 53
                 ],
54 54
                 $this
55 55
             )
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
                             EE_Registry::instance()->CFG->map_settings->google_map_api_key
66 66
                         )
67 67
                     ),
68
-                    'ee_gmap'  => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0',
68
+                    'ee_gmap'  => EE_HELPERS_ASSETS.'ee_gmap.js?ver=1.0',
69 69
                 ],
70 70
                 $this
71 71
             )
Please login to merge, or discard this patch.
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -21,58 +21,58 @@
 block discarded – undo
21 21
  */
22 22
 class EventsArchiveIframe extends Iframe
23 23
 {
24
-    /**
25
-     * EventsArchiveIframe constructor.
26
-     *
27
-     * @param EED_Events_Archive $EED_Events_Archive
28
-     * @throws EE_Error
29
-     * @throws ReflectionException
30
-     */
31
-    public function __construct($EED_Events_Archive)
32
-    {
33
-        /** @var CurrentPage $current_page */
34
-        $current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class);
35
-        $current_page->setEspressoPage(true);
36
-        add_filter('FHEE__EED_Events_Archive__event_list_iframe', '__return_true');
37
-        $EED_Events_Archive->event_list();
38
-        /** @var EspressoEvents $event_list */
39
-        $event_list = EE_Registry::instance()->create('EventEspresso\core\domain\entities\shortcodes\EspressoEvents');
40
-        parent::__construct(
41
-            esc_html__('Event List', 'event_espresso'),
42
-            $event_list->processShortcode()
43
-        );
44
-        $this->addStylesheets(
45
-            apply_filters(
46
-                'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
47
-                [
48
-                    'espresso_default' => is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
49
-                        ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
50
-                        : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
51
-                ],
52
-                $this
53
-            )
54
-        );
55
-        $this->addScripts(
56
-            apply_filters(
57
-                'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
58
-                [
59
-                    'gmap_api' => sprintf(
60
-                        'https://maps.googleapis.com/maps/api/js?key=%s',
61
-                        apply_filters(
62
-                            'FHEE__EEH_Maps__espresso_google_maps_js__api_key',
63
-                            EE_Registry::instance()->CFG->map_settings->google_map_api_key
64
-                        )
65
-                    ),
66
-                    'ee_gmap'  => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0',
67
-                ],
68
-                $this
69
-            )
70
-        );
71
-        $this->addLocalizedVars(
72
-            [
73
-                'ee_gmap' => EEH_Maps::$gmap_vars,
74
-            ],
75
-            'ee_gmap_vars'
76
-        );
77
-    }
24
+	/**
25
+	 * EventsArchiveIframe constructor.
26
+	 *
27
+	 * @param EED_Events_Archive $EED_Events_Archive
28
+	 * @throws EE_Error
29
+	 * @throws ReflectionException
30
+	 */
31
+	public function __construct($EED_Events_Archive)
32
+	{
33
+		/** @var CurrentPage $current_page */
34
+		$current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class);
35
+		$current_page->setEspressoPage(true);
36
+		add_filter('FHEE__EED_Events_Archive__event_list_iframe', '__return_true');
37
+		$EED_Events_Archive->event_list();
38
+		/** @var EspressoEvents $event_list */
39
+		$event_list = EE_Registry::instance()->create('EventEspresso\core\domain\entities\shortcodes\EspressoEvents');
40
+		parent::__construct(
41
+			esc_html__('Event List', 'event_espresso'),
42
+			$event_list->processShortcode()
43
+		);
44
+		$this->addStylesheets(
45
+			apply_filters(
46
+				'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
47
+				[
48
+					'espresso_default' => is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
49
+						? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
50
+						: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
51
+				],
52
+				$this
53
+			)
54
+		);
55
+		$this->addScripts(
56
+			apply_filters(
57
+				'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
58
+				[
59
+					'gmap_api' => sprintf(
60
+						'https://maps.googleapis.com/maps/api/js?key=%s',
61
+						apply_filters(
62
+							'FHEE__EEH_Maps__espresso_google_maps_js__api_key',
63
+							EE_Registry::instance()->CFG->map_settings->google_map_api_key
64
+						)
65
+					),
66
+					'ee_gmap'  => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0',
67
+				],
68
+				$this
69
+			)
70
+		);
71
+		$this->addLocalizedVars(
72
+			[
73
+				'ee_gmap' => EEH_Maps::$gmap_vars,
74
+			],
75
+			'ee_gmap_vars'
76
+		);
77
+	}
78 78
 }
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorSimple.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,6 +72,6 @@
 block discarded – undo
72 72
         }
73 73
         $this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription();
74 74
         $this->template_args['template_path']      =
75
-            TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
75
+            TICKET_SELECTOR_TEMPLATES_PATH.'simple_ticket_selector.template.php';
76 76
     }
77 77
 }
Please login to merge, or discard this patch.
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -19,59 +19,59 @@
 block discarded – undo
19 19
  */
20 20
 class TicketSelectorSimple extends TicketSelector
21 21
 {
22
-    /**
23
-     * @var EE_Ticket $ticket
24
-     */
25
-    protected $ticket;
22
+	/**
23
+	 * @var EE_Ticket $ticket
24
+	 */
25
+	protected $ticket;
26 26
 
27 27
 
28
-    /**
29
-     * TicketSelectorSimple constructor.
30
-     *
31
-     * @param EE_Event  $event
32
-     * @param EE_Ticket $ticket
33
-     * @param int       $max_attendees
34
-     * @param array     $template_args
35
-     * @throws EE_Error
36
-     */
37
-    public function __construct(EE_Event $event, EE_Ticket $ticket, $max_attendees, array $template_args)
38
-    {
39
-        $this->ticket = $ticket;
40
-        parent::__construct(
41
-            $event,
42
-            [$this->ticket],
43
-            $max_attendees,
44
-            $template_args
45
-        );
46
-    }
28
+	/**
29
+	 * TicketSelectorSimple constructor.
30
+	 *
31
+	 * @param EE_Event  $event
32
+	 * @param EE_Ticket $ticket
33
+	 * @param int       $max_attendees
34
+	 * @param array     $template_args
35
+	 * @throws EE_Error
36
+	 */
37
+	public function __construct(EE_Event $event, EE_Ticket $ticket, $max_attendees, array $template_args)
38
+	{
39
+		$this->ticket = $ticket;
40
+		parent::__construct(
41
+			$event,
42
+			[$this->ticket],
43
+			$max_attendees,
44
+			$template_args
45
+		);
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * sets any and all template args that are required for this Ticket Selector
51
-     *
52
-     * @return void
53
-     * @throws UnexpectedEntityException
54
-     * @throws EE_Error
55
-     */
56
-    protected function addTemplateArgs()
57
-    {
58
-        $this->ticket_rows = 1;
59
-        unset($this->template_args['tickets']);
60
-        $this->template_args['ticket'] = $this->ticket;
61
-        $ticket_selector_row           = new TicketSelectorRowSimple(
62
-            $this->ticket,
63
-            $this->max_attendees,
64
-            $this->template_args['date_format'],
65
-            $this->template_args['event_status']
66
-        );
67
-        $this->template_args['TKT_ID'] = $this->ticket->ID();
68
-        $ticket_selector_row->setupTicketStatusDisplay();
69
-        $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay();
70
-        if (empty($this->template_args['ticket_status_display'])) {
71
-            add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
72
-        }
73
-        $this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription();
74
-        $this->template_args['template_path']      =
75
-            TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
76
-    }
49
+	/**
50
+	 * sets any and all template args that are required for this Ticket Selector
51
+	 *
52
+	 * @return void
53
+	 * @throws UnexpectedEntityException
54
+	 * @throws EE_Error
55
+	 */
56
+	protected function addTemplateArgs()
57
+	{
58
+		$this->ticket_rows = 1;
59
+		unset($this->template_args['tickets']);
60
+		$this->template_args['ticket'] = $this->ticket;
61
+		$ticket_selector_row           = new TicketSelectorRowSimple(
62
+			$this->ticket,
63
+			$this->max_attendees,
64
+			$this->template_args['date_format'],
65
+			$this->template_args['event_status']
66
+		);
67
+		$this->template_args['TKT_ID'] = $this->ticket->ID();
68
+		$ticket_selector_row->setupTicketStatusDisplay();
69
+		$this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay();
70
+		if (empty($this->template_args['ticket_status_display'])) {
71
+			add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
72
+		}
73
+		$this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription();
74
+		$this->template_args['template_path']      =
75
+			TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
76
+	}
77 77
 }
Please login to merge, or discard this patch.
modules/feeds/EED_Feeds.module.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         $request = self::getRequest();
84 84
         if ($request->requestParamIsSet('post_type')) {
85 85
             // define path to templates
86
-            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
86
+            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/');
87 87
             // what kinda post_type are we dealing with ?
88 88
             switch ($request->getRequestParam('post_type')) {
89 89
                 case 'espresso_events':
@@ -155,14 +155,14 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public static function the_event_feed($content)
157 157
     {
158
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
158
+        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php')) {
159 159
             global $post;
160 160
             $template_args = array(
161 161
                 'EVT_ID'            => $post->ID,
162 162
                 'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
163 163
             );
164 164
             $content = EEH_Template::display_template(
165
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
165
+                RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php',
166 166
                 $template_args,
167 167
                 true
168 168
             );
@@ -196,14 +196,14 @@  discard block
 block discarded – undo
196 196
      */
197 197
     public static function the_venue_feed($content)
198 198
     {
199
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
199
+        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php')) {
200 200
             global $post;
201 201
             $template_args = array(
202 202
                 'VNU_ID'            => $post->ID,
203 203
                 'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
204 204
             );
205 205
             $content = EEH_Template::display_template(
206
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
206
+                RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php',
207 207
                 $template_args,
208 208
                 true
209 209
             );
Please login to merge, or discard this patch.
Indentation   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -11,218 +11,218 @@
 block discarded – undo
11 11
  */
12 12
 class EED_Feeds extends EED_Module
13 13
 {
14
-    /**
15
-     * @return EED_Feeds
16
-     */
17
-    public static function instance()
18
-    {
19
-        return parent::get_instance(__CLASS__);
20
-    }
21
-
22
-
23
-    /**
24
-     *    set_hooks - for hooking into EE Core, other modules, etc
25
-     *
26
-     * @access    public
27
-     * @return    void
28
-     */
29
-    public static function set_hooks()
30
-    {
31
-        add_action('parse_request', array('EED_Feeds', 'parse_request'), 10);
32
-        add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1);
33
-        add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2);
34
-        add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2);
35
-    }
36
-
37
-    /**
38
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
39
-     *
40
-     * @access    public
41
-     * @return    void
42
-     */
43
-    public static function set_hooks_admin()
44
-    {
45
-    }
46
-
47
-
48
-    /**
49
-     *    run - initial module setup
50
-     *
51
-     * @access    public
52
-     * @return    void
53
-     */
54
-    public function run($WP)
55
-    {
56
-    }
57
-
58
-
59
-    /**
60
-     *    default_feed
61
-     *
62
-     * @access    public
63
-     * @param    type    rss2, atom, rss, rdf, rssjs
64
-     * @return    string
65
-     */
66
-    public static function default_feed($type = 'rss2')
67
-    {
68
-        // rss2, atom, rss, rdf, rssjs
69
-        $type = 'rss2';
70
-        return $type;
71
-    }
72
-
73
-
74
-    /**
75
-     *    parse_request
76
-     *
77
-     * @access    public
78
-     * @return    void
79
-     */
80
-    public static function parse_request()
81
-    {
82
-        $request = self::getRequest();
83
-        if ($request->requestParamIsSet('post_type')) {
84
-            // define path to templates
85
-            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
86
-            // what kinda post_type are we dealing with ?
87
-            switch ($request->getRequestParam('post_type')) {
88
-                case 'espresso_events':
89
-                    // for rss2, atom, rss, rdf
90
-                    add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1);
91
-                    add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1);
92
-                    // for json ( also uses the above filter )
93
-                    add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1);
94
-                    break;
95
-                case 'espresso_venues':
96
-                    // for rss2, atom, rss, rdf
97
-                    add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1);
98
-                    add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1);
99
-                    // for json ( also uses the above filter )
100
-                    add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1);
101
-                    break;
102
-            }
103
-        }
104
-    }
105
-
106
-
107
-    /**
108
-     *    comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
109
-     *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
110
-     *    so this little snippet of SQL taps into the comment feed query and removes comments for the
111
-     *    espresso_attendees post_type
112
-     *
113
-     * @access    public
114
-     * @param    string $SQL the JOIN clause for the comment feed query
115
-     * @return    void
116
-     */
117
-    public static function comment_feed_join($SQL)
118
-    {
119
-        global $wpdb;
120
-        // check for wp_posts table in JOIN clause
121
-        if (strpos($SQL, $wpdb->posts) !== false) {
122
-            add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true');
123
-        }
124
-        return $SQL;
125
-    }
126
-
127
-
128
-    /**
129
-     *    comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
130
-     *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
131
-     *    so this little snippet of SQL taps into the comment feed query and removes comments for the
132
-     *    espresso_attendees post_type
133
-     *
134
-     * @access    public
135
-     * @param    string $SQL the WHERE clause for the comment feed query
136
-     * @return    void
137
-     */
138
-    public static function comment_feed_where($SQL)
139
-    {
140
-        global $wp_query, $wpdb;
141
-        if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) {
142
-            $SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'";
143
-        }
144
-        return $SQL;
145
-    }
146
-
147
-
148
-    /**
149
-     *    the_event_feed
150
-     *
151
-     * @access    public
152
-     * @param    string $content
153
-     * @return    void
154
-     */
155
-    public static function the_event_feed($content)
156
-    {
157
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
158
-            global $post;
159
-            $template_args = array(
160
-                'EVT_ID'            => $post->ID,
161
-                'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
162
-            );
163
-            $content = EEH_Template::display_template(
164
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
165
-                $template_args,
166
-                true
167
-            );
168
-        }
169
-        return $content;
170
-    }
171
-
172
-
173
-    /**
174
-     *    the_event_rssjs_feed
175
-     *
176
-     * @access    public
177
-     * @param    object $item
178
-     * @return    void
179
-     */
180
-    public static function the_event_rssjs_feed($item)
181
-    {
182
-        if (is_feed() && isset($item->description)) {
183
-            $item->description = EED_Feeds::the_event_feed($item->description);
184
-        }
185
-        return $item;
186
-    }
187
-
188
-
189
-    /**
190
-     *    the_venue_feed
191
-     *
192
-     * @access    public
193
-     * @param    string $content
194
-     * @return    void
195
-     */
196
-    public static function the_venue_feed($content)
197
-    {
198
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
199
-            global $post;
200
-            $template_args = array(
201
-                'VNU_ID'            => $post->ID,
202
-                'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
203
-            );
204
-            $content = EEH_Template::display_template(
205
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
206
-                $template_args,
207
-                true
208
-            );
209
-        }
210
-        return $content;
211
-    }
212
-
213
-
214
-    /**
215
-     *    the_venue_rssjs_feed
216
-     *
217
-     * @access    public
218
-     * @param    object $item
219
-     * @return    void
220
-     */
221
-    public static function the_venue_rssjs_feed($item)
222
-    {
223
-        if (is_feed() && isset($item->description)) {
224
-            $item->description = EED_Feeds::the_venue_feed($item->description);
225
-        }
226
-        return $item;
227
-    }
14
+	/**
15
+	 * @return EED_Feeds
16
+	 */
17
+	public static function instance()
18
+	{
19
+		return parent::get_instance(__CLASS__);
20
+	}
21
+
22
+
23
+	/**
24
+	 *    set_hooks - for hooking into EE Core, other modules, etc
25
+	 *
26
+	 * @access    public
27
+	 * @return    void
28
+	 */
29
+	public static function set_hooks()
30
+	{
31
+		add_action('parse_request', array('EED_Feeds', 'parse_request'), 10);
32
+		add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1);
33
+		add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2);
34
+		add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2);
35
+	}
36
+
37
+	/**
38
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
39
+	 *
40
+	 * @access    public
41
+	 * @return    void
42
+	 */
43
+	public static function set_hooks_admin()
44
+	{
45
+	}
46
+
47
+
48
+	/**
49
+	 *    run - initial module setup
50
+	 *
51
+	 * @access    public
52
+	 * @return    void
53
+	 */
54
+	public function run($WP)
55
+	{
56
+	}
57
+
58
+
59
+	/**
60
+	 *    default_feed
61
+	 *
62
+	 * @access    public
63
+	 * @param    type    rss2, atom, rss, rdf, rssjs
64
+	 * @return    string
65
+	 */
66
+	public static function default_feed($type = 'rss2')
67
+	{
68
+		// rss2, atom, rss, rdf, rssjs
69
+		$type = 'rss2';
70
+		return $type;
71
+	}
72
+
73
+
74
+	/**
75
+	 *    parse_request
76
+	 *
77
+	 * @access    public
78
+	 * @return    void
79
+	 */
80
+	public static function parse_request()
81
+	{
82
+		$request = self::getRequest();
83
+		if ($request->requestParamIsSet('post_type')) {
84
+			// define path to templates
85
+			define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
86
+			// what kinda post_type are we dealing with ?
87
+			switch ($request->getRequestParam('post_type')) {
88
+				case 'espresso_events':
89
+					// for rss2, atom, rss, rdf
90
+					add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1);
91
+					add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1);
92
+					// for json ( also uses the above filter )
93
+					add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1);
94
+					break;
95
+				case 'espresso_venues':
96
+					// for rss2, atom, rss, rdf
97
+					add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1);
98
+					add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1);
99
+					// for json ( also uses the above filter )
100
+					add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1);
101
+					break;
102
+			}
103
+		}
104
+	}
105
+
106
+
107
+	/**
108
+	 *    comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
109
+	 *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
110
+	 *    so this little snippet of SQL taps into the comment feed query and removes comments for the
111
+	 *    espresso_attendees post_type
112
+	 *
113
+	 * @access    public
114
+	 * @param    string $SQL the JOIN clause for the comment feed query
115
+	 * @return    void
116
+	 */
117
+	public static function comment_feed_join($SQL)
118
+	{
119
+		global $wpdb;
120
+		// check for wp_posts table in JOIN clause
121
+		if (strpos($SQL, $wpdb->posts) !== false) {
122
+			add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true');
123
+		}
124
+		return $SQL;
125
+	}
126
+
127
+
128
+	/**
129
+	 *    comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
130
+	 *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
131
+	 *    so this little snippet of SQL taps into the comment feed query and removes comments for the
132
+	 *    espresso_attendees post_type
133
+	 *
134
+	 * @access    public
135
+	 * @param    string $SQL the WHERE clause for the comment feed query
136
+	 * @return    void
137
+	 */
138
+	public static function comment_feed_where($SQL)
139
+	{
140
+		global $wp_query, $wpdb;
141
+		if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) {
142
+			$SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'";
143
+		}
144
+		return $SQL;
145
+	}
146
+
147
+
148
+	/**
149
+	 *    the_event_feed
150
+	 *
151
+	 * @access    public
152
+	 * @param    string $content
153
+	 * @return    void
154
+	 */
155
+	public static function the_event_feed($content)
156
+	{
157
+		if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
158
+			global $post;
159
+			$template_args = array(
160
+				'EVT_ID'            => $post->ID,
161
+				'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
162
+			);
163
+			$content = EEH_Template::display_template(
164
+				RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
165
+				$template_args,
166
+				true
167
+			);
168
+		}
169
+		return $content;
170
+	}
171
+
172
+
173
+	/**
174
+	 *    the_event_rssjs_feed
175
+	 *
176
+	 * @access    public
177
+	 * @param    object $item
178
+	 * @return    void
179
+	 */
180
+	public static function the_event_rssjs_feed($item)
181
+	{
182
+		if (is_feed() && isset($item->description)) {
183
+			$item->description = EED_Feeds::the_event_feed($item->description);
184
+		}
185
+		return $item;
186
+	}
187
+
188
+
189
+	/**
190
+	 *    the_venue_feed
191
+	 *
192
+	 * @access    public
193
+	 * @param    string $content
194
+	 * @return    void
195
+	 */
196
+	public static function the_venue_feed($content)
197
+	{
198
+		if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
199
+			global $post;
200
+			$template_args = array(
201
+				'VNU_ID'            => $post->ID,
202
+				'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
203
+			);
204
+			$content = EEH_Template::display_template(
205
+				RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
206
+				$template_args,
207
+				true
208
+			);
209
+		}
210
+		return $content;
211
+	}
212
+
213
+
214
+	/**
215
+	 *    the_venue_rssjs_feed
216
+	 *
217
+	 * @access    public
218
+	 * @param    object $item
219
+	 * @return    void
220
+	 */
221
+	public static function the_venue_rssjs_feed($item)
222
+	{
223
+		if (is_feed() && isset($item->description)) {
224
+			$item->description = EED_Feeds::the_venue_feed($item->description);
225
+		}
226
+		return $item;
227
+	}
228 228
 }
Please login to merge, or discard this patch.
modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
      */
229 229
     public function set_submit_button_text($submit_button_text = '')
230 230
     {
231
-        if (! empty($submit_button_text)) {
231
+        if ( ! empty($submit_button_text)) {
232 232
             $this->_submit_button_text = $submit_button_text;
233 233
         } elseif ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
234 234
             if ($this->checkout->revisit) {
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
     public function reg_form_name()
389 389
     {
390 390
         if (empty($this->_reg_form_name)) {
391
-            $this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form');
391
+            $this->set_reg_form_name('ee-spco-'.$this->slug().'-reg-step-form');
392 392
         }
393 393
         return $this->_reg_form_name;
394 394
     }
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
     public function reg_step_url($action = '')
413 413
     {
414 414
         $query_args = ['step' => $this->slug()];
415
-        if (! empty($action)) {
415
+        if ( ! empty($action)) {
416 416
             $query_args['action'] = $action;
417 417
         }
418 418
         // final step has no display
@@ -442,12 +442,12 @@  discard block
 block discarded – undo
442 442
             return new EE_Form_Section_Proper(
443 443
                 [
444 444
                     'layout_strategy' => new EE_Div_Per_Section_Layout(),
445
-                    'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
445
+                    'html_id'         => 'ee-'.$this->slug().'-hidden-inputs',
446 446
                     'subsections'     => [
447 447
                         'next_step' => new EE_Fixed_Hidden_Input(
448 448
                             [
449 449
                                 'html_name' => 'next_step',
450
-                                'html_id'   => 'spco-' . $this->slug() . '-next-step',
450
+                                'html_id'   => 'spco-'.$this->slug().'-next-step',
451 451
                                 'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
452 452
                                     ? $this->checkout->next_step->slug()
453 453
                                     : '',
@@ -461,12 +461,12 @@  discard block
 block discarded – undo
461 461
         return new EE_Form_Section_Proper(
462 462
             [
463 463
                 'layout_strategy' => new EE_Div_Per_Section_Layout(),
464
-                'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
464
+                'html_id'         => 'ee-'.$this->slug().'-hidden-inputs',
465 465
                 'subsections'     => [
466 466
                     'action'         => new EE_Fixed_Hidden_Input(
467 467
                         [
468 468
                             'html_name' => 'action',
469
-                            'html_id'   => 'spco-' . $this->slug() . '-action',
469
+                            'html_id'   => 'spco-'.$this->slug().'-action',
470 470
                             'default'   => apply_filters(
471 471
                                 'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action',
472 472
                                 empty($this->checkout->reg_url_link)
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
                     'next_step'      => new EE_Fixed_Hidden_Input(
480 480
                         [
481 481
                             'html_name' => 'next_step',
482
-                            'html_id'   => 'spco-' . $this->slug() . '-next-step',
482
+                            'html_id'   => 'spco-'.$this->slug().'-next-step',
483 483
                             'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
484 484
                                 ? $this->checkout->next_step->slug()
485 485
                                 : '',
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
      */
514 514
     public function generate_reg_form_for_actions($actions = [])
515 515
     {
516
-        $actions                           = array_merge(
516
+        $actions = array_merge(
517 517
             [
518 518
                 'generate_reg_form',
519 519
                 'display_spco_reg_step',
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
      */
557 557
     public function reg_step_submit_button()
558 558
     {
559
-        if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
559
+        if ( ! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
560 560
             return '';
561 561
         }
562 562
         ob_start();
@@ -570,18 +570,18 @@  discard block
 block discarded – undo
570 570
         // generate submit button
571 571
         $submit_btn = new EE_Submit_Input(
572 572
             [
573
-                'html_name'             => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
574
-                'html_id'               => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
573
+                'html_name'             => 'spco-go-to-step-'.$this->checkout->next_step->slug(),
574
+                'html_id'               => 'spco-go-to-step-'.$this->checkout->next_step->slug(),
575 575
                 'html_class'            => 'spco-next-step-btn',
576
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
576
+                'other_html_attributes' => ' rel="'.$this->slug().'"',
577 577
                 'default'               => $this->submit_button_text(),
578 578
             ]
579 579
         );
580 580
         $submit_btn->set_button_css_attributes(true, 'large');
581 581
         $submit_btn_html = $submit_btn->get_html_for_input();
582
-        $html            .= EEH_HTML::div(
582
+        $html .= EEH_HTML::div(
583 583
             apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $submit_btn_html, $this),
584
-            'spco-' . $this->slug() . '-whats-next-buttons-dv',
584
+            'spco-'.$this->slug().'-whats-next-buttons-dv',
585 585
             'spco-whats-next-buttons'
586 586
         );
587 587
         return $html;
Please login to merge, or discard this patch.
Indentation   +644 added lines, -644 removed lines patch added patch discarded remove patch
@@ -13,648 +13,648 @@
 block discarded – undo
13 13
  */
14 14
 abstract class EE_SPCO_Reg_Step
15 15
 {
16
-    /**
17
-     *    $_completed - TRUE if this step has fully completed it's duties
18
-     *
19
-     * @access protected
20
-     * @type bool $_completed
21
-     */
22
-    protected $_completed = false;
23
-
24
-    /**
25
-     *    $_is_current_step - TRUE if this is the current step
26
-     *
27
-     * @access protected
28
-     * @type bool $_is_current_step
29
-     */
30
-    protected $_is_current_step = false;
31
-
32
-    /**
33
-     *    $_order - when the reg step should be run relative to other steps
34
-     *
35
-     * @access protected
36
-     * @type int $_template
37
-     */
38
-    protected $_order = 0;
39
-
40
-    /**
41
-     *    $_slug - URL param for this step
42
-     *
43
-     * @access protected
44
-     * @type string $_slug
45
-     */
46
-    protected $_slug;
47
-
48
-    /**
49
-     *    $_name - Step Name - translatable string
50
-     *
51
-     * @access protected
52
-     * @type string $_slug
53
-     */
54
-    protected $_name;
55
-
56
-    /**
57
-     *    $_submit_button_text - translatable string that appears on this step's submit button
58
-     *
59
-     * @access protected
60
-     * @type string $_slug
61
-     */
62
-    protected $_submit_button_text;
63
-
64
-    /**
65
-     *    $_template - template name
66
-     *
67
-     * @access protected
68
-     * @type string $_template
69
-     */
70
-    protected $_template;
71
-
72
-    /**
73
-     *    $_reg_form_name - the form input name and id attribute
74
-     *
75
-     * @access protected
76
-     * @var string $_reg_form_name
77
-     */
78
-    protected $_reg_form_name;
79
-
80
-    /**
81
-     *    $_success_message - text to display upon successful form submission
82
-     *
83
-     * @access private
84
-     * @var string $_success_message
85
-     */
86
-    protected $_success_message;
87
-
88
-    /**
89
-     *    $_instructions - a brief description of how to complete the reg step.
90
-     *    Usually displayed in conjunction with the previous step's success message.
91
-     *
92
-     * @access private
93
-     * @var string $_instructions
94
-     */
95
-    protected $_instructions;
96
-
97
-    /**
98
-     *    $_valid_data - the normalized and validated data for this step
99
-     *
100
-     * @access public
101
-     * @var array $_valid_data
102
-     */
103
-    protected $_valid_data = [];
104
-
105
-    /**
106
-     *    $reg_form - the registration form for this step
107
-     *
108
-     * @access public
109
-     * @var EE_Form_Section_Proper $reg_form
110
-     */
111
-    public $reg_form;
112
-
113
-    /**
114
-     *    $checkout - EE_Checkout object for handling the properties of the current checkout process
115
-     *
116
-     * @access public
117
-     * @var EE_Checkout $checkout
118
-     */
119
-    public $checkout;
120
-
121
-    /**
122
-     * @var RequestInterface $request
123
-     */
124
-    protected $request;
125
-
126
-
127
-    /**
128
-     * @return void
129
-     */
130
-    abstract public function translate_js_strings();
131
-
132
-
133
-    /**
134
-     * @return void
135
-     */
136
-    abstract public function enqueue_styles_and_scripts();
137
-
138
-
139
-    /**
140
-     * @return boolean
141
-     */
142
-    abstract public function initialize_reg_step();
143
-
144
-
145
-    /**
146
-     * @return string
147
-     */
148
-    abstract public function generate_reg_form();
149
-
150
-
151
-    /**
152
-     * @return boolean
153
-     */
154
-    abstract public function process_reg_step();
155
-
156
-
157
-    /**
158
-     * @return boolean
159
-     */
160
-    abstract public function update_reg_step();
161
-
162
-
163
-    /**
164
-     * @return boolean
165
-     */
166
-    public function completed()
167
-    {
168
-        return $this->_completed;
169
-    }
170
-
171
-
172
-    /**
173
-     * set_completed - toggles $_completed to TRUE
174
-     */
175
-    public function set_completed()
176
-    {
177
-        // DEBUG LOG
178
-        // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
179
-        $this->_completed = apply_filters('FHEE__EE_SPCO_Reg_Step__set_completed___completed', true, $this);
180
-    }
181
-
182
-
183
-    /**
184
-     * set_completed - toggles $_completed to FALSE
185
-     */
186
-    public function set_not_completed()
187
-    {
188
-        $this->_completed = false;
189
-    }
190
-
191
-
192
-    /**
193
-     * @return string
194
-     */
195
-    public function name()
196
-    {
197
-        return $this->_name;
198
-    }
199
-
200
-
201
-    /**
202
-     * @return string
203
-     */
204
-    public function slug()
205
-    {
206
-        return $this->_slug;
207
-    }
208
-
209
-
210
-    /**
211
-     * submit_button_text
212
-     * the text that appears on the reg step form submit button
213
-     *
214
-     * @return string
215
-     */
216
-    public function submit_button_text()
217
-    {
218
-        return $this->_submit_button_text;
219
-    }
220
-
221
-
222
-    /**
223
-     * set_submit_button_text
224
-     * sets the text that appears on the reg step form submit button
225
-     *
226
-     * @param string $submit_button_text
227
-     */
228
-    public function set_submit_button_text($submit_button_text = '')
229
-    {
230
-        if (! empty($submit_button_text)) {
231
-            $this->_submit_button_text = $submit_button_text;
232
-        } elseif ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
233
-            if ($this->checkout->revisit) {
234
-                $this->_submit_button_text = sprintf(
235
-                    esc_html__('Update %s', 'event_espresso'),
236
-                    $this->checkout->current_step->name()
237
-                );
238
-            } else {
239
-                $this->_submit_button_text = sprintf(
240
-                    esc_html__('Proceed to %s', 'event_espresso'),
241
-                    $this->checkout->next_step->name()
242
-                );
243
-            }
244
-        }
245
-        // filters the submit button text
246
-        $this->_submit_button_text = apply_filters(
247
-            'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
248
-            $this->_submit_button_text,
249
-            $this->checkout
250
-        );
251
-    }
252
-
253
-
254
-    /**
255
-     * @param boolean $is_current_step
256
-     */
257
-    public function set_is_current_step($is_current_step)
258
-    {
259
-        $this->_is_current_step = $is_current_step;
260
-    }
261
-
262
-
263
-    /**
264
-     * @return boolean
265
-     */
266
-    public function is_current_step()
267
-    {
268
-        return $this->_is_current_step;
269
-    }
270
-
271
-
272
-    /**
273
-     * @return boolean
274
-     */
275
-    public function is_final_step()
276
-    {
277
-        return $this instanceof EE_SPCO_Reg_Step_Finalize_Registration;
278
-    }
279
-
280
-
281
-    /**
282
-     * @param int $order
283
-     */
284
-    public function set_order($order)
285
-    {
286
-        $this->_order = $order;
287
-    }
288
-
289
-
290
-    /**
291
-     * @return int
292
-     */
293
-    public function order()
294
-    {
295
-        return $this->_order;
296
-    }
297
-
298
-
299
-    /**
300
-     * @return string
301
-     */
302
-    public function template()
303
-    {
304
-        return $this->_template;
305
-    }
306
-
307
-
308
-    /**
309
-     * @return string
310
-     */
311
-    public function success_message()
312
-    {
313
-        return $this->_success_message;
314
-    }
315
-
316
-
317
-    /**
318
-     * _set_success_message
319
-     *
320
-     * @param string $success_message
321
-     */
322
-    protected function _set_success_message($success_message)
323
-    {
324
-        $this->_success_message = $success_message;
325
-    }
326
-
327
-
328
-    /**
329
-     * _reset_success_message
330
-     *
331
-     * @return void
332
-     */
333
-    protected function _reset_success_message()
334
-    {
335
-        $this->_success_message = '';
336
-    }
337
-
338
-
339
-    /**
340
-     * @return string
341
-     */
342
-    public function _instructions()
343
-    {
344
-        return $this->_instructions;
345
-    }
346
-
347
-
348
-    /**
349
-     * @param string $instructions
350
-     */
351
-    public function set_instructions($instructions)
352
-    {
353
-        $this->_instructions = apply_filters(
354
-            'FHEE__EE_SPCO_Reg_Step__set_instructions__instructions',
355
-            $instructions,
356
-            $this
357
-        );
358
-    }
359
-
360
-
361
-    /**
362
-     * @param array $valid_data
363
-     */
364
-    public function set_valid_data($valid_data)
365
-    {
366
-        $this->_valid_data = $valid_data;
367
-    }
368
-
369
-
370
-    /**
371
-     * @return array
372
-     * @throws EE_Error
373
-     * @throws EE_Error
374
-     */
375
-    public function valid_data()
376
-    {
377
-        if (empty($this->_valid_data)) {
378
-            $this->_valid_data = $this->reg_form->valid_data();
379
-        }
380
-        return $this->_valid_data;
381
-    }
382
-
383
-
384
-    /**
385
-     * @return string
386
-     */
387
-    public function reg_form_name()
388
-    {
389
-        if (empty($this->_reg_form_name)) {
390
-            $this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form');
391
-        }
392
-        return $this->_reg_form_name;
393
-    }
394
-
395
-
396
-    /**
397
-     * @param string $reg_form_name
398
-     */
399
-    protected function set_reg_form_name($reg_form_name)
400
-    {
401
-        $this->_reg_form_name = $reg_form_name;
402
-    }
403
-
404
-
405
-    /**
406
-     * reg_step_url
407
-     *
408
-     * @param string $action
409
-     * @return string
410
-     */
411
-    public function reg_step_url($action = '')
412
-    {
413
-        $query_args = ['step' => $this->slug()];
414
-        if (! empty($action)) {
415
-            $query_args['action'] = $action;
416
-        }
417
-        // final step has no display
418
-        if ($this instanceof EE_SPCO_Reg_Step_Finalize_Registration && $action === 'display_spco_reg_step') {
419
-            $query_args['action'] = 'process_reg_step';
420
-        }
421
-        if ($this->checkout->revisit) {
422
-            $query_args['revisit'] = true;
423
-        }
424
-        if ($this->checkout->reg_url_link) {
425
-            $query_args['e_reg_url_link'] = $this->checkout->reg_url_link;
426
-        }
427
-        return add_query_arg($query_args, $this->checkout->reg_page_base_url);
428
-    }
429
-
430
-
431
-    /**
432
-     * creates the default hidden inputs section
433
-     *
434
-     * @return EE_Form_Section_Proper
435
-     * @throws EE_Error
436
-     */
437
-    public function reg_step_hidden_inputs()
438
-    {
439
-        // hidden inputs for admin registrations
440
-        if ($this->checkout->admin_request) {
441
-            return new EE_Form_Section_Proper(
442
-                [
443
-                    'layout_strategy' => new EE_Div_Per_Section_Layout(),
444
-                    'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
445
-                    'subsections'     => [
446
-                        'next_step' => new EE_Fixed_Hidden_Input(
447
-                            [
448
-                                'html_name' => 'next_step',
449
-                                'html_id'   => 'spco-' . $this->slug() . '-next-step',
450
-                                'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
451
-                                    ? $this->checkout->next_step->slug()
452
-                                    : '',
453
-                            ]
454
-                        ),
455
-                    ],
456
-                ]
457
-            );
458
-        }
459
-        // hidden inputs for frontend registrations
460
-        return new EE_Form_Section_Proper(
461
-            [
462
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
463
-                'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
464
-                'subsections'     => [
465
-                    'action'         => new EE_Fixed_Hidden_Input(
466
-                        [
467
-                            'html_name' => 'action',
468
-                            'html_id'   => 'spco-' . $this->slug() . '-action',
469
-                            'default'   => apply_filters(
470
-                                'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action',
471
-                                empty($this->checkout->reg_url_link)
472
-                                    ? 'process_reg_step'
473
-                                    : 'update_reg_step',
474
-                                $this
475
-                            ),
476
-                        ]
477
-                    ),
478
-                    'next_step'      => new EE_Fixed_Hidden_Input(
479
-                        [
480
-                            'html_name' => 'next_step',
481
-                            'html_id'   => 'spco-' . $this->slug() . '-next-step',
482
-                            'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
483
-                                ? $this->checkout->next_step->slug()
484
-                                : '',
485
-                        ]
486
-                    ),
487
-                    'e_reg_url_link' => new EE_Fixed_Hidden_Input(
488
-                        [
489
-                            'html_name' => 'e_reg_url_link',
490
-                            'html_id'   => 'spco-reg_url_link',
491
-                            'default'   => $this->checkout->reg_url_link,
492
-                        ]
493
-                    ),
494
-                    'revisit'        => new EE_Fixed_Hidden_Input(
495
-                        [
496
-                            'html_name' => 'revisit',
497
-                            'html_id'   => 'spco-revisit',
498
-                            'default'   => $this->checkout->revisit,
499
-                        ]
500
-                    ),
501
-                ],
502
-            ]
503
-        );
504
-    }
505
-
506
-
507
-    /**
508
-     * generate_reg_form_for_actions
509
-     *
510
-     * @param array $actions
511
-     * @return void
512
-     */
513
-    public function generate_reg_form_for_actions($actions = [])
514
-    {
515
-        $actions                           = array_merge(
516
-            [
517
-                'generate_reg_form',
518
-                'display_spco_reg_step',
519
-                'process_reg_step',
520
-                'update_reg_step',
521
-            ],
522
-            $actions
523
-        );
524
-        $this->checkout->generate_reg_form = in_array($this->checkout->action, $actions, true);
525
-    }
526
-
527
-
528
-    /**
529
-     * @return string
530
-     * @throws EE_Error
531
-     */
532
-    public function display_reg_form()
533
-    {
534
-        $html = '';
535
-        if ($this->reg_form instanceof EE_Form_Section_Proper) {
536
-            do_action('AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form', $this->reg_form, $this);
537
-            $html .= ! $this->checkout->admin_request ? $this->reg_form->form_open($this->reg_step_url()) : '';
538
-            if ($this->request->isAjax()) {
539
-                $this->reg_form->localize_validation_rules();
540
-                $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
541
-            }
542
-            $html .= $this->reg_form->get_html();
543
-            $html .= ! $this->checkout->admin_request ? $this->reg_step_submit_button() : '';
544
-            $html .= ! $this->checkout->admin_request ? $this->reg_form->form_close() : '';
545
-        }
546
-        return $html;
547
-    }
548
-
549
-
550
-    /**
551
-     * div_class - returns nothing for current step, but a css class of "hidden" for others
552
-     *
553
-     * @return string
554
-     * @throws EE_Error
555
-     */
556
-    public function reg_step_submit_button()
557
-    {
558
-        if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
559
-            return '';
560
-        }
561
-        ob_start();
562
-        do_action(
563
-            'AHEE__before_spco_whats_next_buttons',
564
-            $this->slug(),
565
-            $this->checkout->next_step->slug(),
566
-            $this->checkout
567
-        );
568
-        $html = ob_get_clean();
569
-        // generate submit button
570
-        $submit_btn = new EE_Submit_Input(
571
-            [
572
-                'html_name'             => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
573
-                'html_id'               => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
574
-                'html_class'            => 'spco-next-step-btn',
575
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
576
-                'default'               => $this->submit_button_text(),
577
-            ]
578
-        );
579
-        $submit_btn->set_button_css_attributes(true, 'large');
580
-        $submit_btn_html = $submit_btn->get_html_for_input();
581
-        $html            .= EEH_HTML::div(
582
-            apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $submit_btn_html, $this),
583
-            'spco-' . $this->slug() . '-whats-next-buttons-dv',
584
-            'spco-whats-next-buttons'
585
-        );
586
-        return $html;
587
-    }
588
-
589
-
590
-    /**
591
-     * div_class - returns nothing for current step, but a css class of "hidden" for others
592
-     *
593
-     * @return string
594
-     */
595
-    public function div_class()
596
-    {
597
-        return $this->is_current_step() ? '' : ' hidden';
598
-    }
599
-
600
-
601
-    /**
602
-     * div_class - returns  a css class of "hidden" for current step, but nothing for others
603
-     *
604
-     * @return string
605
-     */
606
-    public function edit_lnk_url()
607
-    {
608
-        return add_query_arg(['step' => $this->slug()], $this->checkout->reg_page_base_url);
609
-    }
610
-
611
-
612
-    /**
613
-     * div_class - returns  a css class of "hidden" for current step, but nothing for others
614
-     *
615
-     * @return string
616
-     */
617
-    public function edit_link_class()
618
-    {
619
-        return $this->is_current_step() ? ' hidden' : '';
620
-    }
621
-
622
-
623
-    /**
624
-     * update_checkout with changes that have been made to the cart
625
-     *
626
-     * @return void
627
-     * @throws EE_Error
628
-     * @throws ReflectionException
629
-     */
630
-    public function update_checkout()
631
-    {
632
-        // grab the cart grand total and reset TXN total
633
-        $this->checkout->transaction->set_total($this->checkout->cart->get_cart_grand_total());
634
-        $this->checkout->stash_transaction_and_checkout();
635
-    }
636
-
637
-
638
-    /**
639
-     *    __sleep
640
-     * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
641
-     * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
642
-     * reg form, because if needed, it will be regenerated anyways
643
-     *
644
-     * @return array
645
-     */
646
-    public function __sleep()
647
-    {
648
-        // remove the reg form and the checkout
649
-        return array_diff(array_keys(get_object_vars($this)), ['reg_form', 'checkout']);
650
-    }
651
-
652
-
653
-    /**
654
-     * @param RequestInterface $request
655
-     */
656
-    public function setRequest(RequestInterface $request)
657
-    {
658
-        $this->request = $request;
659
-    }
16
+	/**
17
+	 *    $_completed - TRUE if this step has fully completed it's duties
18
+	 *
19
+	 * @access protected
20
+	 * @type bool $_completed
21
+	 */
22
+	protected $_completed = false;
23
+
24
+	/**
25
+	 *    $_is_current_step - TRUE if this is the current step
26
+	 *
27
+	 * @access protected
28
+	 * @type bool $_is_current_step
29
+	 */
30
+	protected $_is_current_step = false;
31
+
32
+	/**
33
+	 *    $_order - when the reg step should be run relative to other steps
34
+	 *
35
+	 * @access protected
36
+	 * @type int $_template
37
+	 */
38
+	protected $_order = 0;
39
+
40
+	/**
41
+	 *    $_slug - URL param for this step
42
+	 *
43
+	 * @access protected
44
+	 * @type string $_slug
45
+	 */
46
+	protected $_slug;
47
+
48
+	/**
49
+	 *    $_name - Step Name - translatable string
50
+	 *
51
+	 * @access protected
52
+	 * @type string $_slug
53
+	 */
54
+	protected $_name;
55
+
56
+	/**
57
+	 *    $_submit_button_text - translatable string that appears on this step's submit button
58
+	 *
59
+	 * @access protected
60
+	 * @type string $_slug
61
+	 */
62
+	protected $_submit_button_text;
63
+
64
+	/**
65
+	 *    $_template - template name
66
+	 *
67
+	 * @access protected
68
+	 * @type string $_template
69
+	 */
70
+	protected $_template;
71
+
72
+	/**
73
+	 *    $_reg_form_name - the form input name and id attribute
74
+	 *
75
+	 * @access protected
76
+	 * @var string $_reg_form_name
77
+	 */
78
+	protected $_reg_form_name;
79
+
80
+	/**
81
+	 *    $_success_message - text to display upon successful form submission
82
+	 *
83
+	 * @access private
84
+	 * @var string $_success_message
85
+	 */
86
+	protected $_success_message;
87
+
88
+	/**
89
+	 *    $_instructions - a brief description of how to complete the reg step.
90
+	 *    Usually displayed in conjunction with the previous step's success message.
91
+	 *
92
+	 * @access private
93
+	 * @var string $_instructions
94
+	 */
95
+	protected $_instructions;
96
+
97
+	/**
98
+	 *    $_valid_data - the normalized and validated data for this step
99
+	 *
100
+	 * @access public
101
+	 * @var array $_valid_data
102
+	 */
103
+	protected $_valid_data = [];
104
+
105
+	/**
106
+	 *    $reg_form - the registration form for this step
107
+	 *
108
+	 * @access public
109
+	 * @var EE_Form_Section_Proper $reg_form
110
+	 */
111
+	public $reg_form;
112
+
113
+	/**
114
+	 *    $checkout - EE_Checkout object for handling the properties of the current checkout process
115
+	 *
116
+	 * @access public
117
+	 * @var EE_Checkout $checkout
118
+	 */
119
+	public $checkout;
120
+
121
+	/**
122
+	 * @var RequestInterface $request
123
+	 */
124
+	protected $request;
125
+
126
+
127
+	/**
128
+	 * @return void
129
+	 */
130
+	abstract public function translate_js_strings();
131
+
132
+
133
+	/**
134
+	 * @return void
135
+	 */
136
+	abstract public function enqueue_styles_and_scripts();
137
+
138
+
139
+	/**
140
+	 * @return boolean
141
+	 */
142
+	abstract public function initialize_reg_step();
143
+
144
+
145
+	/**
146
+	 * @return string
147
+	 */
148
+	abstract public function generate_reg_form();
149
+
150
+
151
+	/**
152
+	 * @return boolean
153
+	 */
154
+	abstract public function process_reg_step();
155
+
156
+
157
+	/**
158
+	 * @return boolean
159
+	 */
160
+	abstract public function update_reg_step();
161
+
162
+
163
+	/**
164
+	 * @return boolean
165
+	 */
166
+	public function completed()
167
+	{
168
+		return $this->_completed;
169
+	}
170
+
171
+
172
+	/**
173
+	 * set_completed - toggles $_completed to TRUE
174
+	 */
175
+	public function set_completed()
176
+	{
177
+		// DEBUG LOG
178
+		// $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
179
+		$this->_completed = apply_filters('FHEE__EE_SPCO_Reg_Step__set_completed___completed', true, $this);
180
+	}
181
+
182
+
183
+	/**
184
+	 * set_completed - toggles $_completed to FALSE
185
+	 */
186
+	public function set_not_completed()
187
+	{
188
+		$this->_completed = false;
189
+	}
190
+
191
+
192
+	/**
193
+	 * @return string
194
+	 */
195
+	public function name()
196
+	{
197
+		return $this->_name;
198
+	}
199
+
200
+
201
+	/**
202
+	 * @return string
203
+	 */
204
+	public function slug()
205
+	{
206
+		return $this->_slug;
207
+	}
208
+
209
+
210
+	/**
211
+	 * submit_button_text
212
+	 * the text that appears on the reg step form submit button
213
+	 *
214
+	 * @return string
215
+	 */
216
+	public function submit_button_text()
217
+	{
218
+		return $this->_submit_button_text;
219
+	}
220
+
221
+
222
+	/**
223
+	 * set_submit_button_text
224
+	 * sets the text that appears on the reg step form submit button
225
+	 *
226
+	 * @param string $submit_button_text
227
+	 */
228
+	public function set_submit_button_text($submit_button_text = '')
229
+	{
230
+		if (! empty($submit_button_text)) {
231
+			$this->_submit_button_text = $submit_button_text;
232
+		} elseif ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
233
+			if ($this->checkout->revisit) {
234
+				$this->_submit_button_text = sprintf(
235
+					esc_html__('Update %s', 'event_espresso'),
236
+					$this->checkout->current_step->name()
237
+				);
238
+			} else {
239
+				$this->_submit_button_text = sprintf(
240
+					esc_html__('Proceed to %s', 'event_espresso'),
241
+					$this->checkout->next_step->name()
242
+				);
243
+			}
244
+		}
245
+		// filters the submit button text
246
+		$this->_submit_button_text = apply_filters(
247
+			'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
248
+			$this->_submit_button_text,
249
+			$this->checkout
250
+		);
251
+	}
252
+
253
+
254
+	/**
255
+	 * @param boolean $is_current_step
256
+	 */
257
+	public function set_is_current_step($is_current_step)
258
+	{
259
+		$this->_is_current_step = $is_current_step;
260
+	}
261
+
262
+
263
+	/**
264
+	 * @return boolean
265
+	 */
266
+	public function is_current_step()
267
+	{
268
+		return $this->_is_current_step;
269
+	}
270
+
271
+
272
+	/**
273
+	 * @return boolean
274
+	 */
275
+	public function is_final_step()
276
+	{
277
+		return $this instanceof EE_SPCO_Reg_Step_Finalize_Registration;
278
+	}
279
+
280
+
281
+	/**
282
+	 * @param int $order
283
+	 */
284
+	public function set_order($order)
285
+	{
286
+		$this->_order = $order;
287
+	}
288
+
289
+
290
+	/**
291
+	 * @return int
292
+	 */
293
+	public function order()
294
+	{
295
+		return $this->_order;
296
+	}
297
+
298
+
299
+	/**
300
+	 * @return string
301
+	 */
302
+	public function template()
303
+	{
304
+		return $this->_template;
305
+	}
306
+
307
+
308
+	/**
309
+	 * @return string
310
+	 */
311
+	public function success_message()
312
+	{
313
+		return $this->_success_message;
314
+	}
315
+
316
+
317
+	/**
318
+	 * _set_success_message
319
+	 *
320
+	 * @param string $success_message
321
+	 */
322
+	protected function _set_success_message($success_message)
323
+	{
324
+		$this->_success_message = $success_message;
325
+	}
326
+
327
+
328
+	/**
329
+	 * _reset_success_message
330
+	 *
331
+	 * @return void
332
+	 */
333
+	protected function _reset_success_message()
334
+	{
335
+		$this->_success_message = '';
336
+	}
337
+
338
+
339
+	/**
340
+	 * @return string
341
+	 */
342
+	public function _instructions()
343
+	{
344
+		return $this->_instructions;
345
+	}
346
+
347
+
348
+	/**
349
+	 * @param string $instructions
350
+	 */
351
+	public function set_instructions($instructions)
352
+	{
353
+		$this->_instructions = apply_filters(
354
+			'FHEE__EE_SPCO_Reg_Step__set_instructions__instructions',
355
+			$instructions,
356
+			$this
357
+		);
358
+	}
359
+
360
+
361
+	/**
362
+	 * @param array $valid_data
363
+	 */
364
+	public function set_valid_data($valid_data)
365
+	{
366
+		$this->_valid_data = $valid_data;
367
+	}
368
+
369
+
370
+	/**
371
+	 * @return array
372
+	 * @throws EE_Error
373
+	 * @throws EE_Error
374
+	 */
375
+	public function valid_data()
376
+	{
377
+		if (empty($this->_valid_data)) {
378
+			$this->_valid_data = $this->reg_form->valid_data();
379
+		}
380
+		return $this->_valid_data;
381
+	}
382
+
383
+
384
+	/**
385
+	 * @return string
386
+	 */
387
+	public function reg_form_name()
388
+	{
389
+		if (empty($this->_reg_form_name)) {
390
+			$this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form');
391
+		}
392
+		return $this->_reg_form_name;
393
+	}
394
+
395
+
396
+	/**
397
+	 * @param string $reg_form_name
398
+	 */
399
+	protected function set_reg_form_name($reg_form_name)
400
+	{
401
+		$this->_reg_form_name = $reg_form_name;
402
+	}
403
+
404
+
405
+	/**
406
+	 * reg_step_url
407
+	 *
408
+	 * @param string $action
409
+	 * @return string
410
+	 */
411
+	public function reg_step_url($action = '')
412
+	{
413
+		$query_args = ['step' => $this->slug()];
414
+		if (! empty($action)) {
415
+			$query_args['action'] = $action;
416
+		}
417
+		// final step has no display
418
+		if ($this instanceof EE_SPCO_Reg_Step_Finalize_Registration && $action === 'display_spco_reg_step') {
419
+			$query_args['action'] = 'process_reg_step';
420
+		}
421
+		if ($this->checkout->revisit) {
422
+			$query_args['revisit'] = true;
423
+		}
424
+		if ($this->checkout->reg_url_link) {
425
+			$query_args['e_reg_url_link'] = $this->checkout->reg_url_link;
426
+		}
427
+		return add_query_arg($query_args, $this->checkout->reg_page_base_url);
428
+	}
429
+
430
+
431
+	/**
432
+	 * creates the default hidden inputs section
433
+	 *
434
+	 * @return EE_Form_Section_Proper
435
+	 * @throws EE_Error
436
+	 */
437
+	public function reg_step_hidden_inputs()
438
+	{
439
+		// hidden inputs for admin registrations
440
+		if ($this->checkout->admin_request) {
441
+			return new EE_Form_Section_Proper(
442
+				[
443
+					'layout_strategy' => new EE_Div_Per_Section_Layout(),
444
+					'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
445
+					'subsections'     => [
446
+						'next_step' => new EE_Fixed_Hidden_Input(
447
+							[
448
+								'html_name' => 'next_step',
449
+								'html_id'   => 'spco-' . $this->slug() . '-next-step',
450
+								'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
451
+									? $this->checkout->next_step->slug()
452
+									: '',
453
+							]
454
+						),
455
+					],
456
+				]
457
+			);
458
+		}
459
+		// hidden inputs for frontend registrations
460
+		return new EE_Form_Section_Proper(
461
+			[
462
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
463
+				'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
464
+				'subsections'     => [
465
+					'action'         => new EE_Fixed_Hidden_Input(
466
+						[
467
+							'html_name' => 'action',
468
+							'html_id'   => 'spco-' . $this->slug() . '-action',
469
+							'default'   => apply_filters(
470
+								'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action',
471
+								empty($this->checkout->reg_url_link)
472
+									? 'process_reg_step'
473
+									: 'update_reg_step',
474
+								$this
475
+							),
476
+						]
477
+					),
478
+					'next_step'      => new EE_Fixed_Hidden_Input(
479
+						[
480
+							'html_name' => 'next_step',
481
+							'html_id'   => 'spco-' . $this->slug() . '-next-step',
482
+							'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
483
+								? $this->checkout->next_step->slug()
484
+								: '',
485
+						]
486
+					),
487
+					'e_reg_url_link' => new EE_Fixed_Hidden_Input(
488
+						[
489
+							'html_name' => 'e_reg_url_link',
490
+							'html_id'   => 'spco-reg_url_link',
491
+							'default'   => $this->checkout->reg_url_link,
492
+						]
493
+					),
494
+					'revisit'        => new EE_Fixed_Hidden_Input(
495
+						[
496
+							'html_name' => 'revisit',
497
+							'html_id'   => 'spco-revisit',
498
+							'default'   => $this->checkout->revisit,
499
+						]
500
+					),
501
+				],
502
+			]
503
+		);
504
+	}
505
+
506
+
507
+	/**
508
+	 * generate_reg_form_for_actions
509
+	 *
510
+	 * @param array $actions
511
+	 * @return void
512
+	 */
513
+	public function generate_reg_form_for_actions($actions = [])
514
+	{
515
+		$actions                           = array_merge(
516
+			[
517
+				'generate_reg_form',
518
+				'display_spco_reg_step',
519
+				'process_reg_step',
520
+				'update_reg_step',
521
+			],
522
+			$actions
523
+		);
524
+		$this->checkout->generate_reg_form = in_array($this->checkout->action, $actions, true);
525
+	}
526
+
527
+
528
+	/**
529
+	 * @return string
530
+	 * @throws EE_Error
531
+	 */
532
+	public function display_reg_form()
533
+	{
534
+		$html = '';
535
+		if ($this->reg_form instanceof EE_Form_Section_Proper) {
536
+			do_action('AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form', $this->reg_form, $this);
537
+			$html .= ! $this->checkout->admin_request ? $this->reg_form->form_open($this->reg_step_url()) : '';
538
+			if ($this->request->isAjax()) {
539
+				$this->reg_form->localize_validation_rules();
540
+				$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
541
+			}
542
+			$html .= $this->reg_form->get_html();
543
+			$html .= ! $this->checkout->admin_request ? $this->reg_step_submit_button() : '';
544
+			$html .= ! $this->checkout->admin_request ? $this->reg_form->form_close() : '';
545
+		}
546
+		return $html;
547
+	}
548
+
549
+
550
+	/**
551
+	 * div_class - returns nothing for current step, but a css class of "hidden" for others
552
+	 *
553
+	 * @return string
554
+	 * @throws EE_Error
555
+	 */
556
+	public function reg_step_submit_button()
557
+	{
558
+		if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
559
+			return '';
560
+		}
561
+		ob_start();
562
+		do_action(
563
+			'AHEE__before_spco_whats_next_buttons',
564
+			$this->slug(),
565
+			$this->checkout->next_step->slug(),
566
+			$this->checkout
567
+		);
568
+		$html = ob_get_clean();
569
+		// generate submit button
570
+		$submit_btn = new EE_Submit_Input(
571
+			[
572
+				'html_name'             => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
573
+				'html_id'               => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
574
+				'html_class'            => 'spco-next-step-btn',
575
+				'other_html_attributes' => ' rel="' . $this->slug() . '"',
576
+				'default'               => $this->submit_button_text(),
577
+			]
578
+		);
579
+		$submit_btn->set_button_css_attributes(true, 'large');
580
+		$submit_btn_html = $submit_btn->get_html_for_input();
581
+		$html            .= EEH_HTML::div(
582
+			apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $submit_btn_html, $this),
583
+			'spco-' . $this->slug() . '-whats-next-buttons-dv',
584
+			'spco-whats-next-buttons'
585
+		);
586
+		return $html;
587
+	}
588
+
589
+
590
+	/**
591
+	 * div_class - returns nothing for current step, but a css class of "hidden" for others
592
+	 *
593
+	 * @return string
594
+	 */
595
+	public function div_class()
596
+	{
597
+		return $this->is_current_step() ? '' : ' hidden';
598
+	}
599
+
600
+
601
+	/**
602
+	 * div_class - returns  a css class of "hidden" for current step, but nothing for others
603
+	 *
604
+	 * @return string
605
+	 */
606
+	public function edit_lnk_url()
607
+	{
608
+		return add_query_arg(['step' => $this->slug()], $this->checkout->reg_page_base_url);
609
+	}
610
+
611
+
612
+	/**
613
+	 * div_class - returns  a css class of "hidden" for current step, but nothing for others
614
+	 *
615
+	 * @return string
616
+	 */
617
+	public function edit_link_class()
618
+	{
619
+		return $this->is_current_step() ? ' hidden' : '';
620
+	}
621
+
622
+
623
+	/**
624
+	 * update_checkout with changes that have been made to the cart
625
+	 *
626
+	 * @return void
627
+	 * @throws EE_Error
628
+	 * @throws ReflectionException
629
+	 */
630
+	public function update_checkout()
631
+	{
632
+		// grab the cart grand total and reset TXN total
633
+		$this->checkout->transaction->set_total($this->checkout->cart->get_cart_grand_total());
634
+		$this->checkout->stash_transaction_and_checkout();
635
+	}
636
+
637
+
638
+	/**
639
+	 *    __sleep
640
+	 * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
641
+	 * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
642
+	 * reg form, because if needed, it will be regenerated anyways
643
+	 *
644
+	 * @return array
645
+	 */
646
+	public function __sleep()
647
+	{
648
+		// remove the reg form and the checkout
649
+		return array_diff(array_keys(get_object_vars($this)), ['reg_form', 'checkout']);
650
+	}
651
+
652
+
653
+	/**
654
+	 * @param RequestInterface $request
655
+	 */
656
+	public function setRequest(RequestInterface $request)
657
+	{
658
+		$this->request = $request;
659
+	}
660 660
 }
Please login to merge, or discard this patch.
core/services/request/files/FilesDataHandler.php 2 patches
Indentation   +251 added lines, -251 removed lines patch added patch discarded remove patch
@@ -40,279 +40,279 @@
 block discarded – undo
40 40
  */
41 41
 class FilesDataHandler
42 42
 {
43
-    /**
44
-     * @var Request
45
-     */
46
-    protected $request;
43
+	/**
44
+	 * @var Request
45
+	 */
46
+	protected $request;
47 47
 
48
-    /**
49
-     * @var CollectionInterface | FileSubmissionInterface[]
50
-     */
51
-    protected $file_objects;
48
+	/**
49
+	 * @var CollectionInterface | FileSubmissionInterface[]
50
+	 */
51
+	protected $file_objects;
52 52
 
53
-    /**
54
-     * @var bool
55
-     */
56
-    protected $initialized = false;
53
+	/**
54
+	 * @var bool
55
+	 */
56
+	protected $initialized = false;
57 57
 
58 58
 
59
-    /**
60
-     * FilesDataHandler constructor.
61
-     *
62
-     * @param Request $request
63
-     */
64
-    public function __construct(Request $request)
65
-    {
66
-        $this->request = $request;
67
-    }
59
+	/**
60
+	 * FilesDataHandler constructor.
61
+	 *
62
+	 * @param Request $request
63
+	 */
64
+	public function __construct(Request $request)
65
+	{
66
+		$this->request = $request;
67
+	}
68 68
 
69 69
 
70
-    /**
71
-     * @return CollectionInterface | FileSubmissionInterface[]
72
-     * @throws UnexpectedValueException
73
-     * @throws InvalidArgumentException
74
-     * @since 4.9.80.p
75
-     */
76
-    protected function getFileObjects()
77
-    {
78
-        $this->initialize();
79
-        return $this->file_objects;
80
-    }
70
+	/**
71
+	 * @return CollectionInterface | FileSubmissionInterface[]
72
+	 * @throws UnexpectedValueException
73
+	 * @throws InvalidArgumentException
74
+	 * @since 4.9.80.p
75
+	 */
76
+	protected function getFileObjects()
77
+	{
78
+		$this->initialize();
79
+		return $this->file_objects;
80
+	}
81 81
 
82 82
 
83
-    /**
84
-     * Sets up the file objects from the request's $_FILES data.
85
-     *
86
-     * @throws UnexpectedValueException
87
-     * @throws InvalidArgumentException
88
-     * @throws InvalidInterfaceException
89
-     * @since 4.9.80.p
90
-     */
91
-    protected function initialize()
92
-    {
93
-        if ($this->initialized) {
94
-            return;
95
-        }
96
-        $this->file_objects = new Collection(
97
-        // collection interface
98
-            'EventEspresso\core\services\request\files\FileSubmissionInterface',
99
-            // collection name
100
-            'submitted_files'
101
-        );
102
-        $files_raw_data     = $this->request->filesParams();
103
-        if (empty($files_raw_data)) {
104
-            return;
105
-        }
106
-        if ($this->isStrangeFilesArray($files_raw_data)) {
107
-            $data = $this->fixFilesDataArray($files_raw_data);
108
-        } else {
109
-            $data = $files_raw_data;
110
-        }
111
-        $this->createFileObjects($data);
112
-        $this->initialized = true;
113
-    }
83
+	/**
84
+	 * Sets up the file objects from the request's $_FILES data.
85
+	 *
86
+	 * @throws UnexpectedValueException
87
+	 * @throws InvalidArgumentException
88
+	 * @throws InvalidInterfaceException
89
+	 * @since 4.9.80.p
90
+	 */
91
+	protected function initialize()
92
+	{
93
+		if ($this->initialized) {
94
+			return;
95
+		}
96
+		$this->file_objects = new Collection(
97
+		// collection interface
98
+			'EventEspresso\core\services\request\files\FileSubmissionInterface',
99
+			// collection name
100
+			'submitted_files'
101
+		);
102
+		$files_raw_data     = $this->request->filesParams();
103
+		if (empty($files_raw_data)) {
104
+			return;
105
+		}
106
+		if ($this->isStrangeFilesArray($files_raw_data)) {
107
+			$data = $this->fixFilesDataArray($files_raw_data);
108
+		} else {
109
+			$data = $files_raw_data;
110
+		}
111
+		$this->createFileObjects($data);
112
+		$this->initialized = true;
113
+	}
114 114
 
115 115
 
116
-    /**
117
-     * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not.
118
-     *
119
-     * @param $files_data
120
-     * @return bool
121
-     * @throws UnexpectedValueException
122
-     * @since 4.9.80.p
123
-     */
124
-    protected function isStrangeFilesArray($files_data)
125
-    {
126
-        if (! is_array($files_data)) {
127
-            throw new UnexpectedValueException(
128
-                sprintf(
129
-                    esc_html__(
130
-                        'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
131
-                        'event_espresso'
132
-                    ),
133
-                    (string) $files_data
134
-                )
135
-            );
136
-        }
137
-        $first_value = reset($files_data);
138
-        if (! is_array($first_value)) {
139
-            throw new UnexpectedValueException(
140
-                sprintf(
141
-                    esc_html__(
142
-                        'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
143
-                        'event_espresso'
144
-                    ),
145
-                    (string) $first_value
146
-                )
147
-            );
148
-        }
149
-        $first_sub_array_item = reset($first_value);
150
-        if (is_array($first_sub_array_item)) {
151
-            // not just a 2d array
152
-            return true;
153
-        }
154
-        // yep, just 2d array
155
-        return false;
156
-    }
116
+	/**
117
+	 * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not.
118
+	 *
119
+	 * @param $files_data
120
+	 * @return bool
121
+	 * @throws UnexpectedValueException
122
+	 * @since 4.9.80.p
123
+	 */
124
+	protected function isStrangeFilesArray($files_data)
125
+	{
126
+		if (! is_array($files_data)) {
127
+			throw new UnexpectedValueException(
128
+				sprintf(
129
+					esc_html__(
130
+						'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
131
+						'event_espresso'
132
+					),
133
+					(string) $files_data
134
+				)
135
+			);
136
+		}
137
+		$first_value = reset($files_data);
138
+		if (! is_array($first_value)) {
139
+			throw new UnexpectedValueException(
140
+				sprintf(
141
+					esc_html__(
142
+						'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
143
+						'event_espresso'
144
+					),
145
+					(string) $first_value
146
+				)
147
+			);
148
+		}
149
+		$first_sub_array_item = reset($first_value);
150
+		if (is_array($first_sub_array_item)) {
151
+			// not just a 2d array
152
+			return true;
153
+		}
154
+		// yep, just 2d array
155
+		return false;
156
+	}
157 157
 
158 158
 
159
-    /**
160
-     * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file"
161
-     * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with
162
-     * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]",
163
-     * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird.
164
-     *
165
-     * @param $files_data
166
-     * @return array
167
-     * @since 4.9.80.p
168
-     */
169
-    protected function fixFilesDataArray($files_data)
170
-    {
171
-        $sane_files_array = [];
172
-        foreach ($files_data as $top_level_name => $top_level_children) {
173
-            $sub_array                           = [];
174
-            $sane_files_array[ $top_level_name ] = [];
175
-            foreach ($top_level_children as $file_data_part => $second_level_children) {
176
-                foreach ($second_level_children as $next_level_name => $sub_values) {
177
-                    $sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part);
178
-                }
179
-                $sane_files_array[ $top_level_name ] = array_replace_recursive(
180
-                    $sub_array,
181
-                    $sane_files_array[ $top_level_name ]
182
-                );
183
-            }
184
-        }
185
-        return $sane_files_array;
186
-    }
159
+	/**
160
+	 * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file"
161
+	 * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with
162
+	 * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]",
163
+	 * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird.
164
+	 *
165
+	 * @param $files_data
166
+	 * @return array
167
+	 * @since 4.9.80.p
168
+	 */
169
+	protected function fixFilesDataArray($files_data)
170
+	{
171
+		$sane_files_array = [];
172
+		foreach ($files_data as $top_level_name => $top_level_children) {
173
+			$sub_array                           = [];
174
+			$sane_files_array[ $top_level_name ] = [];
175
+			foreach ($top_level_children as $file_data_part => $second_level_children) {
176
+				foreach ($second_level_children as $next_level_name => $sub_values) {
177
+					$sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part);
178
+				}
179
+				$sane_files_array[ $top_level_name ] = array_replace_recursive(
180
+					$sub_array,
181
+					$sane_files_array[ $top_level_name ]
182
+				);
183
+			}
184
+		}
185
+		return $sane_files_array;
186
+	}
187 187
 
188 188
 
189
-    /**
190
-     * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it.
191
-     *
192
-     * @param $data array|string
193
-     * @param $type 'name', 'tmp_name', 'size', or 'error'
194
-     * @return array
195
-     * @since 4.9.80.p
196
-     */
197
-    protected function organizeFilesData($data, $type)
198
-    {
199
-        if (! is_array($data)) {
200
-            return [
201
-                $type => $data,
202
-            ];
203
-        }
204
-        $organized_data = [];
205
-        foreach ($data as $input_name_part => $sub_inputs_or_value) {
206
-            if (is_array($sub_inputs_or_value)) {
207
-                $organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type);
208
-            } else {
209
-                $organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value;
210
-            }
211
-        }
212
-        return $organized_data;
213
-    }
189
+	/**
190
+	 * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it.
191
+	 *
192
+	 * @param $data array|string
193
+	 * @param $type 'name', 'tmp_name', 'size', or 'error'
194
+	 * @return array
195
+	 * @since 4.9.80.p
196
+	 */
197
+	protected function organizeFilesData($data, $type)
198
+	{
199
+		if (! is_array($data)) {
200
+			return [
201
+				$type => $data,
202
+			];
203
+		}
204
+		$organized_data = [];
205
+		foreach ($data as $input_name_part => $sub_inputs_or_value) {
206
+			if (is_array($sub_inputs_or_value)) {
207
+				$organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type);
208
+			} else {
209
+				$organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value;
210
+			}
211
+		}
212
+		return $organized_data;
213
+	}
214 214
 
215 215
 
216
-    /**
217
-     * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input
218
-     * to be in post data, with all the file's data located side-by-side in an array) and creates a
219
-     * multi-dimensional array of FileSubmissionInterface objects. Stores it in `$this->file_objects`.
220
-     *
221
-     * @param array $organized_files   $_FILES but organized like $_POST
222
-     * @param array $name_parts_so_far for multidimensional HTML form names,
223
-     * @throws UnexpectedValueException
224
-     * @throws InvalidArgumentException
225
-     * @since 4.9.80.p
226
-     */
227
-    protected function createFileObjects($organized_files, $name_parts_so_far = [])
228
-    {
229
-        if (! is_array($organized_files)) {
230
-            throw new UnexpectedValueException(
231
-                sprintf(
232
-                    esc_html__(
233
-                        'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.',
234
-                        'event_espresso'
235
-                    ),
236
-                    (string) $organized_files
237
-                )
238
-            );
239
-        }
240
-        foreach ($organized_files as $key => $value) {
241
-            $this_input_name_parts = $name_parts_so_far;
242
-            array_push(
243
-                $this_input_name_parts,
244
-                $key
245
-            );
246
-            if (isset($value['name'], $value['tmp_name'], $value['size'])) {
247
-                $html_name = $this->inputNameFromParts($this_input_name_parts);
248
-                $this->file_objects->add(
249
-                    new FileSubmission(
250
-                        $value['name'],
251
-                        $value['tmp_name'],
252
-                        $value['size'],
253
-                        $value['error']
254
-                    ),
255
-                    $html_name
256
-                );
257
-            } else {
258
-                $this->createFileObjects($value, $this_input_name_parts);
259
-            }
260
-        }
261
-    }
216
+	/**
217
+	 * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input
218
+	 * to be in post data, with all the file's data located side-by-side in an array) and creates a
219
+	 * multi-dimensional array of FileSubmissionInterface objects. Stores it in `$this->file_objects`.
220
+	 *
221
+	 * @param array $organized_files   $_FILES but organized like $_POST
222
+	 * @param array $name_parts_so_far for multidimensional HTML form names,
223
+	 * @throws UnexpectedValueException
224
+	 * @throws InvalidArgumentException
225
+	 * @since 4.9.80.p
226
+	 */
227
+	protected function createFileObjects($organized_files, $name_parts_so_far = [])
228
+	{
229
+		if (! is_array($organized_files)) {
230
+			throw new UnexpectedValueException(
231
+				sprintf(
232
+					esc_html__(
233
+						'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.',
234
+						'event_espresso'
235
+					),
236
+					(string) $organized_files
237
+				)
238
+			);
239
+		}
240
+		foreach ($organized_files as $key => $value) {
241
+			$this_input_name_parts = $name_parts_so_far;
242
+			array_push(
243
+				$this_input_name_parts,
244
+				$key
245
+			);
246
+			if (isset($value['name'], $value['tmp_name'], $value['size'])) {
247
+				$html_name = $this->inputNameFromParts($this_input_name_parts);
248
+				$this->file_objects->add(
249
+					new FileSubmission(
250
+						$value['name'],
251
+						$value['tmp_name'],
252
+						$value['size'],
253
+						$value['error']
254
+					),
255
+					$html_name
256
+				);
257
+			} else {
258
+				$this->createFileObjects($value, $this_input_name_parts);
259
+			}
260
+		}
261
+	}
262 262
 
263 263
 
264
-    /**
265
-     * Takes the input name parts, like `['my', 'great', 'file', 'input1']`
266
-     * and returns the HTML name for it, "my[great][file][input1]"
267
-     *
268
-     * @throws UnexpectedValueException
269
-     * @since 4.9.80.p
270
-     */
271
-    protected function inputNameFromParts($parts)
272
-    {
273
-        if (! is_array($parts)) {
274
-            throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
275
-        }
276
-        $generated_string = '';
277
-        foreach ($parts as $part) {
278
-            $part = (string) $part;
279
-            // wrap all but the first part in []
280
-            $generated_string .= $generated_string === '' ? $part : '[' . $part . ']';
281
-        }
282
-        return $generated_string;
283
-    }
264
+	/**
265
+	 * Takes the input name parts, like `['my', 'great', 'file', 'input1']`
266
+	 * and returns the HTML name for it, "my[great][file][input1]"
267
+	 *
268
+	 * @throws UnexpectedValueException
269
+	 * @since 4.9.80.p
270
+	 */
271
+	protected function inputNameFromParts($parts)
272
+	{
273
+		if (! is_array($parts)) {
274
+			throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
275
+		}
276
+		$generated_string = '';
277
+		foreach ($parts as $part) {
278
+			$part = (string) $part;
279
+			// wrap all but the first part in []
280
+			$generated_string .= $generated_string === '' ? $part : '[' . $part . ']';
281
+		}
282
+		return $generated_string;
283
+	}
284 284
 
285 285
 
286
-    /**
287
-     * Gets the input by the indicated $name_parts.
288
-     * Eg if you're looking for an input named "my[great][file][input1]", $name_parts
289
-     * should be `['my', 'great', 'file', 'input1']`.
290
-     * Alternatively, you could use `FileDataHandler::getFileObject('my[great][file][input1]');`
291
-     *
292
-     * @param $name_parts
293
-     * @return FileSubmissionInterface
294
-     * @throws UnexpectedValueException
295
-     * @since 4.9.80.p
296
-     */
297
-    public function getFileObjectFromNameParts($name_parts)
298
-    {
299
-        return $this->getFileObjects()->get($this->inputNameFromParts($name_parts));
300
-    }
286
+	/**
287
+	 * Gets the input by the indicated $name_parts.
288
+	 * Eg if you're looking for an input named "my[great][file][input1]", $name_parts
289
+	 * should be `['my', 'great', 'file', 'input1']`.
290
+	 * Alternatively, you could use `FileDataHandler::getFileObject('my[great][file][input1]');`
291
+	 *
292
+	 * @param $name_parts
293
+	 * @return FileSubmissionInterface
294
+	 * @throws UnexpectedValueException
295
+	 * @since 4.9.80.p
296
+	 */
297
+	public function getFileObjectFromNameParts($name_parts)
298
+	{
299
+		return $this->getFileObjects()->get($this->inputNameFromParts($name_parts));
300
+	}
301 301
 
302 302
 
303
-    /**
304
-     * Gets the FileSubmissionInterface corresponding to the HTML name provided.
305
-     *
306
-     * @param $html_name
307
-     * @return mixed
308
-     * @throws InvalidArgumentException
309
-     * @throws UnexpectedValueException
310
-     * @since 4.9.80.p
311
-     */
312
-    public function getFileObject($html_name)
313
-    {
314
-        return $this->getFileObjects()->get($html_name);
315
-    }
303
+	/**
304
+	 * Gets the FileSubmissionInterface corresponding to the HTML name provided.
305
+	 *
306
+	 * @param $html_name
307
+	 * @return mixed
308
+	 * @throws InvalidArgumentException
309
+	 * @throws UnexpectedValueException
310
+	 * @since 4.9.80.p
311
+	 */
312
+	public function getFileObject($html_name)
313
+	{
314
+		return $this->getFileObjects()->get($html_name);
315
+	}
316 316
 }
317 317
 // End of file FilesDataHandler.php
318 318
 // Location: EventEspresso\core\services\request\files/FilesDataHandler.php
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             // collection name
100 100
             'submitted_files'
101 101
         );
102
-        $files_raw_data     = $this->request->filesParams();
102
+        $files_raw_data = $this->request->filesParams();
103 103
         if (empty($files_raw_data)) {
104 104
             return;
105 105
         }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      */
124 124
     protected function isStrangeFilesArray($files_data)
125 125
     {
126
-        if (! is_array($files_data)) {
126
+        if ( ! is_array($files_data)) {
127 127
             throw new UnexpectedValueException(
128 128
                 sprintf(
129 129
                     esc_html__(
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             );
136 136
         }
137 137
         $first_value = reset($files_data);
138
-        if (! is_array($first_value)) {
138
+        if ( ! is_array($first_value)) {
139 139
             throw new UnexpectedValueException(
140 140
                 sprintf(
141 141
                     esc_html__(
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
         $sane_files_array = [];
172 172
         foreach ($files_data as $top_level_name => $top_level_children) {
173 173
             $sub_array                           = [];
174
-            $sane_files_array[ $top_level_name ] = [];
174
+            $sane_files_array[$top_level_name] = [];
175 175
             foreach ($top_level_children as $file_data_part => $second_level_children) {
176 176
                 foreach ($second_level_children as $next_level_name => $sub_values) {
177
-                    $sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part);
177
+                    $sub_array[$next_level_name] = $this->organizeFilesData($sub_values, $file_data_part);
178 178
                 }
179
-                $sane_files_array[ $top_level_name ] = array_replace_recursive(
179
+                $sane_files_array[$top_level_name] = array_replace_recursive(
180 180
                     $sub_array,
181
-                    $sane_files_array[ $top_level_name ]
181
+                    $sane_files_array[$top_level_name]
182 182
                 );
183 183
             }
184 184
         }
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
      */
197 197
     protected function organizeFilesData($data, $type)
198 198
     {
199
-        if (! is_array($data)) {
199
+        if ( ! is_array($data)) {
200 200
             return [
201 201
                 $type => $data,
202 202
             ];
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
         $organized_data = [];
205 205
         foreach ($data as $input_name_part => $sub_inputs_or_value) {
206 206
             if (is_array($sub_inputs_or_value)) {
207
-                $organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type);
207
+                $organized_data[$input_name_part] = $this->organizeFilesData($sub_inputs_or_value, $type);
208 208
             } else {
209
-                $organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value;
209
+                $organized_data[$input_name_part][$type] = $sub_inputs_or_value;
210 210
             }
211 211
         }
212 212
         return $organized_data;
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
      */
227 227
     protected function createFileObjects($organized_files, $name_parts_so_far = [])
228 228
     {
229
-        if (! is_array($organized_files)) {
229
+        if ( ! is_array($organized_files)) {
230 230
             throw new UnexpectedValueException(
231 231
                 sprintf(
232 232
                     esc_html__(
@@ -270,14 +270,14 @@  discard block
 block discarded – undo
270 270
      */
271 271
     protected function inputNameFromParts($parts)
272 272
     {
273
-        if (! is_array($parts)) {
273
+        if ( ! is_array($parts)) {
274 274
             throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
275 275
         }
276 276
         $generated_string = '';
277 277
         foreach ($parts as $part) {
278 278
             $part = (string) $part;
279 279
             // wrap all but the first part in []
280
-            $generated_string .= $generated_string === '' ? $part : '[' . $part . ']';
280
+            $generated_string .= $generated_string === '' ? $part : '['.$part.']';
281 281
         }
282 282
         return $generated_string;
283 283
     }
Please login to merge, or discard this patch.