Completed
Branch dependabot/npm_and_yarn/hosted... (af6e61)
by
unknown
19:17 queued 10:20
created
core/libraries/plugin_api/EE_Register_Messages_Template_Pack.lib.php 2 patches
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -12,204 +12,204 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * Holds values for registered template pack
17
-     *
18
-     * @since 4.5.0
19
-     *
20
-     * @var array
21
-     */
22
-    protected static $_registry = array();
23
-
24
-
25
-    /**
26
-     * Used to register a new template pack with the messages system.
27
-     *
28
-     * Template packs are primarily defined via class extending EE_Messages_Template_Pack and are typically used to
29
-     * change entire layouts for a set of message templates.  This method is used to register the new template pack and
30
-     * automatically have it loaded in the appropriate places.
31
-     *
32
-     * This registry also verifies that there isn't already a template pack registered with the same name and if there
33
-     * is then it will add an EE_Error notice.
34
-     *
35
-     * Note that this only handles registering the your Template Pack class with the message template pack system.
36
-     * However, there is also a naming schema you must follow for templates you are providing with your template pack.
37
-     *
38
-     * @see    EE_Messages_Template_Pack_Default for an example class
39
-     * @see    core/libraries/messages/defaults/default/* for all the example templates the default template pack
40
-     *         supports.
41
-     *
42
-     *
43
-     * @since  4.5.0
44
-     * @throws EE_Error
45
-     *
46
-     * @param string $ref        The internal reference used to refer to this template pack.  Note, this is first come,
47
-     *                           first serve.  If there is already a template pack registered with this name then the
48
-     *                           registry will assign a unique reference for it so it can still be activated (but this
49
-     *                           makes it harder to deregister as it will be unique per load - so its best to try to
50
-     *                           make this a unique string!)
51
-     * @param array  $setup_args array {
52
-     *                           An array of required values for registering the template pack.
53
-     * @type string  $path       The path for the new template pack class.
54
-     * @type string  $classname  The name of the new Template Pack Class.
55
-     *                           }
56
-     *
57
-     * @return void
58
-     */
59
-    public static function register($ref = null, $setup_args = array())
60
-    {
61
-
62
-        // check for required params
63
-        if (empty($ref) || empty($setup_args['path']) || empty($setup_args['classname'])) {
64
-            throw new EE_Error(
65
-                __(
66
-                    'In order to register a new template pack for the EE Messages system, you must include a value to reference the template pack being registered and the setup_args must have the path for the new template pack class as well as the classname for the new Template Pack Class. ',
67
-                    'event_espresso'
68
-                )
69
-            );
70
-        }
71
-
72
-        // make sure we don't register twice
73
-        if (isset(self::$_registry[ $ref ])) {
74
-            return;
75
-        }
76
-
77
-        // check that incoming $ref doesn't already exist. If it does then we'll create a unique reference for this template pack.
78
-        if (isset(self::$_registry[ $ref ])) {
79
-            $ref = uniqid() . '_' . $ref;
80
-        }
81
-
82
-
83
-        // make sure this was called in the right place!
84
-        if (! did_action('EE_Brewing_Regular___messages_caf')
85
-            || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
86
-        ) {
87
-            EE_Error::doing_it_wrong(
88
-                __METHOD__,
89
-                sprintf(
90
-                    __(
91
-                        'A EE Messages Template Pack given the reference "%s" has been attempted to be registered with the EE Messages System.  It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.',
92
-                        'event_espresso'
93
-                    ),
94
-                    $ref
95
-                ),
96
-                '4.5.0'
97
-            );
98
-        }
99
-
100
-        if (self::_verify_class_not_exist($setup_args['classname'])) {
101
-            self::$_registry[ $ref ] = array(
102
-                'path'      => (string) $setup_args['path'],
103
-                'classname' => (string) $setup_args['classname'],
104
-            );
105
-        }
106
-
107
-        // hook into the system
108
-        add_filter(
109
-            'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
110
-            array('EE_Register_Messages_Template_Pack', 'set_template_pack_path'),
111
-            10
112
-        );
113
-        add_filter(
114
-            'FHEE__EED_Messages__get_template_packs__template_packs',
115
-            array('EE_Register_Messages_Template_Pack', 'set_template_pack'),
116
-            10
117
-        );
118
-    }
119
-
120
-
121
-    /**
122
-     * Callback for the FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.  This adds this template packs path
123
-     * to the messages autoloader paths.
124
-     *
125
-     * @since  4.5.0
126
-     *
127
-     * @param array $paths Array of paths already registered with the messages autoloader
128
-     *
129
-     * @return array
130
-     */
131
-    public static function set_template_pack_path($paths)
132
-    {
133
-        foreach (self::$_registry as $ref => $args) {
134
-            $paths[] = $args['path'];
135
-        }
136
-        return $paths;
137
-    }
138
-
139
-
140
-    /**
141
-     * Callback for the FHEE__EED_Messages__get_template_packs__template_packs filter. This adds the instantiated,
142
-     * registered template pack to the template packs array when requested by client code.
143
-     *
144
-     * @since 4.5.0
145
-     *
146
-     * @param EE_Messages_Template_Pack[] $template_packs
147
-     * @return EE_Messages_Template_Pack[]
148
-     */
149
-    public static function set_template_pack($template_packs)
150
-    {
151
-        foreach (self::$_registry as $ref => $args) {
152
-            // verify class_exists
153
-            if (! class_exists($args['classname'])) {
154
-                require_once($args['path'] . '/' . $args['classname'] . '.class.php');
155
-            }
156
-
157
-            // check again!
158
-            if (class_exists($args['classname'])) {
159
-                $template_pack = new $args['classname'];
160
-                $template_packs[ $template_pack->dbref ] = $template_pack;
161
-            }
162
-        }
163
-
164
-        return $template_packs;
165
-    }
166
-
167
-
168
-    /**
169
-     * This verifies that the classes for each registered template pack are unique  names.
170
-     *
171
-     * @param string $classname The classname being checked
172
-     *
173
-     * @return bool
174
-     */
175
-    private static function _verify_class_not_exist($classname)
176
-    {
177
-
178
-        // loop through the existing registry and see if the classname is already present.
179
-        foreach (self::$_registry as $ref => $args) {
180
-            if ($args['classname'] == $classname) {
181
-                EE_Error::add_error(
182
-                    sprintf(
183
-                        __(
184
-                            'The %s template pack that you just activated cannot be registered with the messages system because there is already a template pack active using the same classname.  Contact the author of this template pack to let them know of the conflict.  To stop seeing this message you will need to deactivate this template pack.',
185
-                            'event_espresso'
186
-                        ),
187
-                        (string) $setup_args['classname']
188
-                    ),
189
-                    __FILE__,
190
-                    __LINE__,
191
-                    __FUNCTION__
192
-                );
193
-                return false;
194
-            }
195
-        }
196
-        return true;
197
-    }
198
-
199
-
200
-    /**
201
-     * This deregisters a variation set that was previously registered with the given slug.
202
-     *
203
-     * @since 4.5.0
204
-     *
205
-     * @param string $variation_ref The name for the variation set that was previously registered.
206
-     *
207
-     * @return void
208
-     */
209
-    public static function deregister($variation_ref = null)
210
-    {
211
-        if (! empty(self::$_registry[ $variation_ref ])) {
212
-            unset(self::$_registry[ $variation_ref ]);
213
-        }
214
-    }
15
+	/**
16
+	 * Holds values for registered template pack
17
+	 *
18
+	 * @since 4.5.0
19
+	 *
20
+	 * @var array
21
+	 */
22
+	protected static $_registry = array();
23
+
24
+
25
+	/**
26
+	 * Used to register a new template pack with the messages system.
27
+	 *
28
+	 * Template packs are primarily defined via class extending EE_Messages_Template_Pack and are typically used to
29
+	 * change entire layouts for a set of message templates.  This method is used to register the new template pack and
30
+	 * automatically have it loaded in the appropriate places.
31
+	 *
32
+	 * This registry also verifies that there isn't already a template pack registered with the same name and if there
33
+	 * is then it will add an EE_Error notice.
34
+	 *
35
+	 * Note that this only handles registering the your Template Pack class with the message template pack system.
36
+	 * However, there is also a naming schema you must follow for templates you are providing with your template pack.
37
+	 *
38
+	 * @see    EE_Messages_Template_Pack_Default for an example class
39
+	 * @see    core/libraries/messages/defaults/default/* for all the example templates the default template pack
40
+	 *         supports.
41
+	 *
42
+	 *
43
+	 * @since  4.5.0
44
+	 * @throws EE_Error
45
+	 *
46
+	 * @param string $ref        The internal reference used to refer to this template pack.  Note, this is first come,
47
+	 *                           first serve.  If there is already a template pack registered with this name then the
48
+	 *                           registry will assign a unique reference for it so it can still be activated (but this
49
+	 *                           makes it harder to deregister as it will be unique per load - so its best to try to
50
+	 *                           make this a unique string!)
51
+	 * @param array  $setup_args array {
52
+	 *                           An array of required values for registering the template pack.
53
+	 * @type string  $path       The path for the new template pack class.
54
+	 * @type string  $classname  The name of the new Template Pack Class.
55
+	 *                           }
56
+	 *
57
+	 * @return void
58
+	 */
59
+	public static function register($ref = null, $setup_args = array())
60
+	{
61
+
62
+		// check for required params
63
+		if (empty($ref) || empty($setup_args['path']) || empty($setup_args['classname'])) {
64
+			throw new EE_Error(
65
+				__(
66
+					'In order to register a new template pack for the EE Messages system, you must include a value to reference the template pack being registered and the setup_args must have the path for the new template pack class as well as the classname for the new Template Pack Class. ',
67
+					'event_espresso'
68
+				)
69
+			);
70
+		}
71
+
72
+		// make sure we don't register twice
73
+		if (isset(self::$_registry[ $ref ])) {
74
+			return;
75
+		}
76
+
77
+		// check that incoming $ref doesn't already exist. If it does then we'll create a unique reference for this template pack.
78
+		if (isset(self::$_registry[ $ref ])) {
79
+			$ref = uniqid() . '_' . $ref;
80
+		}
81
+
82
+
83
+		// make sure this was called in the right place!
84
+		if (! did_action('EE_Brewing_Regular___messages_caf')
85
+			|| did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
86
+		) {
87
+			EE_Error::doing_it_wrong(
88
+				__METHOD__,
89
+				sprintf(
90
+					__(
91
+						'A EE Messages Template Pack given the reference "%s" has been attempted to be registered with the EE Messages System.  It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.',
92
+						'event_espresso'
93
+					),
94
+					$ref
95
+				),
96
+				'4.5.0'
97
+			);
98
+		}
99
+
100
+		if (self::_verify_class_not_exist($setup_args['classname'])) {
101
+			self::$_registry[ $ref ] = array(
102
+				'path'      => (string) $setup_args['path'],
103
+				'classname' => (string) $setup_args['classname'],
104
+			);
105
+		}
106
+
107
+		// hook into the system
108
+		add_filter(
109
+			'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
110
+			array('EE_Register_Messages_Template_Pack', 'set_template_pack_path'),
111
+			10
112
+		);
113
+		add_filter(
114
+			'FHEE__EED_Messages__get_template_packs__template_packs',
115
+			array('EE_Register_Messages_Template_Pack', 'set_template_pack'),
116
+			10
117
+		);
118
+	}
119
+
120
+
121
+	/**
122
+	 * Callback for the FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.  This adds this template packs path
123
+	 * to the messages autoloader paths.
124
+	 *
125
+	 * @since  4.5.0
126
+	 *
127
+	 * @param array $paths Array of paths already registered with the messages autoloader
128
+	 *
129
+	 * @return array
130
+	 */
131
+	public static function set_template_pack_path($paths)
132
+	{
133
+		foreach (self::$_registry as $ref => $args) {
134
+			$paths[] = $args['path'];
135
+		}
136
+		return $paths;
137
+	}
138
+
139
+
140
+	/**
141
+	 * Callback for the FHEE__EED_Messages__get_template_packs__template_packs filter. This adds the instantiated,
142
+	 * registered template pack to the template packs array when requested by client code.
143
+	 *
144
+	 * @since 4.5.0
145
+	 *
146
+	 * @param EE_Messages_Template_Pack[] $template_packs
147
+	 * @return EE_Messages_Template_Pack[]
148
+	 */
149
+	public static function set_template_pack($template_packs)
150
+	{
151
+		foreach (self::$_registry as $ref => $args) {
152
+			// verify class_exists
153
+			if (! class_exists($args['classname'])) {
154
+				require_once($args['path'] . '/' . $args['classname'] . '.class.php');
155
+			}
156
+
157
+			// check again!
158
+			if (class_exists($args['classname'])) {
159
+				$template_pack = new $args['classname'];
160
+				$template_packs[ $template_pack->dbref ] = $template_pack;
161
+			}
162
+		}
163
+
164
+		return $template_packs;
165
+	}
166
+
167
+
168
+	/**
169
+	 * This verifies that the classes for each registered template pack are unique  names.
170
+	 *
171
+	 * @param string $classname The classname being checked
172
+	 *
173
+	 * @return bool
174
+	 */
175
+	private static function _verify_class_not_exist($classname)
176
+	{
177
+
178
+		// loop through the existing registry and see if the classname is already present.
179
+		foreach (self::$_registry as $ref => $args) {
180
+			if ($args['classname'] == $classname) {
181
+				EE_Error::add_error(
182
+					sprintf(
183
+						__(
184
+							'The %s template pack that you just activated cannot be registered with the messages system because there is already a template pack active using the same classname.  Contact the author of this template pack to let them know of the conflict.  To stop seeing this message you will need to deactivate this template pack.',
185
+							'event_espresso'
186
+						),
187
+						(string) $setup_args['classname']
188
+					),
189
+					__FILE__,
190
+					__LINE__,
191
+					__FUNCTION__
192
+				);
193
+				return false;
194
+			}
195
+		}
196
+		return true;
197
+	}
198
+
199
+
200
+	/**
201
+	 * This deregisters a variation set that was previously registered with the given slug.
202
+	 *
203
+	 * @since 4.5.0
204
+	 *
205
+	 * @param string $variation_ref The name for the variation set that was previously registered.
206
+	 *
207
+	 * @return void
208
+	 */
209
+	public static function deregister($variation_ref = null)
210
+	{
211
+		if (! empty(self::$_registry[ $variation_ref ])) {
212
+			unset(self::$_registry[ $variation_ref ]);
213
+		}
214
+	}
215 215
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -70,18 +70,18 @@  discard block
 block discarded – undo
70 70
         }
71 71
 
72 72
         // make sure we don't register twice
73
-        if (isset(self::$_registry[ $ref ])) {
73
+        if (isset(self::$_registry[$ref])) {
74 74
             return;
75 75
         }
76 76
 
77 77
         // check that incoming $ref doesn't already exist. If it does then we'll create a unique reference for this template pack.
78
-        if (isset(self::$_registry[ $ref ])) {
79
-            $ref = uniqid() . '_' . $ref;
78
+        if (isset(self::$_registry[$ref])) {
79
+            $ref = uniqid().'_'.$ref;
80 80
         }
81 81
 
82 82
 
83 83
         // make sure this was called in the right place!
84
-        if (! did_action('EE_Brewing_Regular___messages_caf')
84
+        if ( ! did_action('EE_Brewing_Regular___messages_caf')
85 85
             || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
86 86
         ) {
87 87
             EE_Error::doing_it_wrong(
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         }
99 99
 
100 100
         if (self::_verify_class_not_exist($setup_args['classname'])) {
101
-            self::$_registry[ $ref ] = array(
101
+            self::$_registry[$ref] = array(
102 102
                 'path'      => (string) $setup_args['path'],
103 103
                 'classname' => (string) $setup_args['classname'],
104 104
             );
@@ -150,14 +150,14 @@  discard block
 block discarded – undo
150 150
     {
151 151
         foreach (self::$_registry as $ref => $args) {
152 152
             // verify class_exists
153
-            if (! class_exists($args['classname'])) {
154
-                require_once($args['path'] . '/' . $args['classname'] . '.class.php');
153
+            if ( ! class_exists($args['classname'])) {
154
+                require_once($args['path'].'/'.$args['classname'].'.class.php');
155 155
             }
156 156
 
157 157
             // check again!
158 158
             if (class_exists($args['classname'])) {
159 159
                 $template_pack = new $args['classname'];
160
-                $template_packs[ $template_pack->dbref ] = $template_pack;
160
+                $template_packs[$template_pack->dbref] = $template_pack;
161 161
             }
162 162
         }
163 163
 
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
      */
209 209
     public static function deregister($variation_ref = null)
210 210
     {
211
-        if (! empty(self::$_registry[ $variation_ref ])) {
212
-            unset(self::$_registry[ $variation_ref ]);
211
+        if ( ! empty(self::$_registry[$variation_ref])) {
212
+            unset(self::$_registry[$variation_ref]);
213 213
         }
214 214
     }
215 215
 }
Please login to merge, or discard this patch.
core/libraries/messages/EE_Message_Generated_From_Token.php 2 patches
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -12,111 +12,111 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * Sending messenger
17
-     *
18
-     * @type EE_messenger | string
19
-     */
20
-    protected $_sending_messenger = '';
21
-
22
-
23
-    /**
24
-     * Holds the incoming token;
25
-     * @type string
26
-     */
27
-    public $token = '';
28
-
29
-
30
-    /**
31
-     * Constructor
32
-     *
33
-     * @param   string    $sending_messenger_slug     This is used to set what messenger is used to "send"
34
-     *                                                the EE_Message retrieved from the DB via the given token.
35
-     * @param   string $token                         This is a token for a Message that should already exist int the db.
36
-     *                                                This is then used to populate the properties in here.
37
-     * @param   EE_Message_Resource_Manager $message_resource_manager
38
-     */
39
-    public function __construct($token, $sending_messenger_slug = 'html', EE_Message_Resource_Manager $message_resource_manager)
40
-    {
41
-        $this->token = $token;
42
-        $this->_sending_messenger = $this->_set_sending_messenger($sending_messenger_slug, $message_resource_manager);
43
-        $this->_message = $this->_generate_message();
44
-        // set params for parent from the message object
45
-        parent::__construct(
46
-            $this->_message->messenger(),
47
-            $this->_message->message_type(),
48
-            array(),
49
-            $this->_message->context(),
50
-            false
51
-        );
52
-    }
53
-
54
-
55
-
56
-    /**
57
-     * @param string                       $sending_messenger_slug
58
-     * @param \EE_Message_Resource_Manager $message_resource_manager
59
-     * @return \EE_messenger | string
60
-     */
61
-    protected function _set_sending_messenger(
62
-        $sending_messenger_slug,
63
-        EE_Message_Resource_Manager $message_resource_manager
64
-    ) {
65
-        $sending_messenger = $message_resource_manager->get_active_messenger($sending_messenger_slug);
66
-        return $sending_messenger instanceof EE_messenger ? $sending_messenger : $sending_messenger_slug;
67
-    }
68
-
69
-
70
-
71
-    /**
72
-     * @return EE_messenger
73
-     */
74
-    public function sending_messenger()
75
-    {
76
-        return $this->_sending_messenger;
77
-    }
78
-
79
-
80
-
81
-    /**
82
-     * generates an EE_Message using the supplied arguments and some defaults
83
-     *
84
-     * @param array $properties
85
-     * @return EE_Message
86
-     * @throws \EE_Error
87
-     */
88
-    protected function _generate_message($properties = array())
89
-    {
90
-        // a message was generated immediately but the parent class will call this again
91
-        if ($this->_message instanceof EE_Message) {
92
-            return $this->_message;
93
-        }
94
-        $message = EEM_Message::instance()->get_one_by_token($this->token);
95
-        if (! $message instanceof EE_Message) {
96
-            throw new EE_Error(
97
-                sprintf(
98
-                    __('Unable to retrieve generated message from DB using given token: "%1$s"', 'event_espresso'),
99
-                    $this->token
100
-                )
101
-            );
102
-        }
103
-        $message->set_STS_ID(EEM_Message::status_idle);
104
-
105
-        if (! $this->_sending_messenger instanceof EE_messenger) {
106
-            $message->set_STS_ID(EEM_Message::status_failed);
107
-            $message->set_error_message(
108
-                sprintf(
109
-                    __('Unable to send message because the "%1$s" messenger is not active or not installed', 'event_espresso'),
110
-                    $this->_sending_messenger
111
-                )
112
-            );
113
-        }
114
-
115
-        // set properties
116
-        $this->_valid = true;
117
-        $this->_messenger = $message->messenger_object();
118
-        $this->_message_type = $message->message_type_object();
119
-        $this->_send_now = $message->send_now();
120
-        return $message;
121
-    }
15
+	/**
16
+	 * Sending messenger
17
+	 *
18
+	 * @type EE_messenger | string
19
+	 */
20
+	protected $_sending_messenger = '';
21
+
22
+
23
+	/**
24
+	 * Holds the incoming token;
25
+	 * @type string
26
+	 */
27
+	public $token = '';
28
+
29
+
30
+	/**
31
+	 * Constructor
32
+	 *
33
+	 * @param   string    $sending_messenger_slug     This is used to set what messenger is used to "send"
34
+	 *                                                the EE_Message retrieved from the DB via the given token.
35
+	 * @param   string $token                         This is a token for a Message that should already exist int the db.
36
+	 *                                                This is then used to populate the properties in here.
37
+	 * @param   EE_Message_Resource_Manager $message_resource_manager
38
+	 */
39
+	public function __construct($token, $sending_messenger_slug = 'html', EE_Message_Resource_Manager $message_resource_manager)
40
+	{
41
+		$this->token = $token;
42
+		$this->_sending_messenger = $this->_set_sending_messenger($sending_messenger_slug, $message_resource_manager);
43
+		$this->_message = $this->_generate_message();
44
+		// set params for parent from the message object
45
+		parent::__construct(
46
+			$this->_message->messenger(),
47
+			$this->_message->message_type(),
48
+			array(),
49
+			$this->_message->context(),
50
+			false
51
+		);
52
+	}
53
+
54
+
55
+
56
+	/**
57
+	 * @param string                       $sending_messenger_slug
58
+	 * @param \EE_Message_Resource_Manager $message_resource_manager
59
+	 * @return \EE_messenger | string
60
+	 */
61
+	protected function _set_sending_messenger(
62
+		$sending_messenger_slug,
63
+		EE_Message_Resource_Manager $message_resource_manager
64
+	) {
65
+		$sending_messenger = $message_resource_manager->get_active_messenger($sending_messenger_slug);
66
+		return $sending_messenger instanceof EE_messenger ? $sending_messenger : $sending_messenger_slug;
67
+	}
68
+
69
+
70
+
71
+	/**
72
+	 * @return EE_messenger
73
+	 */
74
+	public function sending_messenger()
75
+	{
76
+		return $this->_sending_messenger;
77
+	}
78
+
79
+
80
+
81
+	/**
82
+	 * generates an EE_Message using the supplied arguments and some defaults
83
+	 *
84
+	 * @param array $properties
85
+	 * @return EE_Message
86
+	 * @throws \EE_Error
87
+	 */
88
+	protected function _generate_message($properties = array())
89
+	{
90
+		// a message was generated immediately but the parent class will call this again
91
+		if ($this->_message instanceof EE_Message) {
92
+			return $this->_message;
93
+		}
94
+		$message = EEM_Message::instance()->get_one_by_token($this->token);
95
+		if (! $message instanceof EE_Message) {
96
+			throw new EE_Error(
97
+				sprintf(
98
+					__('Unable to retrieve generated message from DB using given token: "%1$s"', 'event_espresso'),
99
+					$this->token
100
+				)
101
+			);
102
+		}
103
+		$message->set_STS_ID(EEM_Message::status_idle);
104
+
105
+		if (! $this->_sending_messenger instanceof EE_messenger) {
106
+			$message->set_STS_ID(EEM_Message::status_failed);
107
+			$message->set_error_message(
108
+				sprintf(
109
+					__('Unable to send message because the "%1$s" messenger is not active or not installed', 'event_espresso'),
110
+					$this->_sending_messenger
111
+				)
112
+			);
113
+		}
114
+
115
+		// set properties
116
+		$this->_valid = true;
117
+		$this->_messenger = $message->messenger_object();
118
+		$this->_message_type = $message->message_type_object();
119
+		$this->_send_now = $message->send_now();
120
+		return $message;
121
+	}
122 122
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
             return $this->_message;
93 93
         }
94 94
         $message = EEM_Message::instance()->get_one_by_token($this->token);
95
-        if (! $message instanceof EE_Message) {
95
+        if ( ! $message instanceof EE_Message) {
96 96
             throw new EE_Error(
97 97
                 sprintf(
98 98
                     __('Unable to retrieve generated message from DB using given token: "%1$s"', 'event_espresso'),
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         }
103 103
         $message->set_STS_ID(EEM_Message::status_idle);
104 104
 
105
-        if (! $this->_sending_messenger instanceof EE_messenger) {
105
+        if ( ! $this->_sending_messenger instanceof EE_messenger) {
106 106
             $message->set_STS_ID(EEM_Message::status_failed);
107 107
             $message->set_error_message(
108 108
                 sprintf(
Please login to merge, or discard this patch.
core/libraries/messages/EE_Message_Repository.lib.php 2 patches
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -12,256 +12,256 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     *    EE_Message_Repository constructor
17
-     */
18
-    public function __construct()
19
-    {
20
-        $this->interface = 'EE_Message';
21
-        parent::__construct();
22
-    }
15
+	/**
16
+	 *    EE_Message_Repository constructor
17
+	 */
18
+	public function __construct()
19
+	{
20
+		$this->interface = 'EE_Message';
21
+		parent::__construct();
22
+	}
23 23
 
24 24
 
25
-    /**
26
-     * Add the EE_Message to the repository.
27
-     * This also ensures that the MSG_token is saves as a part of the info for retrieval.
28
-     *
29
-     * @param EE_Message $message
30
-     * @param mixed      $info Any included data is saved in the attached object info array indexed by 'data'
31
-     * @return bool
32
-     */
33
-    public function add($message, $info = null)
34
-    {
35
-        $attached = parent::add($message);
36
-        // ensure $info is an array if not already
37
-        $info = $info === null ? $info = array() : (array) $info;
38
-        $data = $this->_init_data($info, $attached, $message);
39
-        if ($attached) {
40
-            $this->set_info($message, $data);
41
-        }
42
-        return $attached;
43
-    }
25
+	/**
26
+	 * Add the EE_Message to the repository.
27
+	 * This also ensures that the MSG_token is saves as a part of the info for retrieval.
28
+	 *
29
+	 * @param EE_Message $message
30
+	 * @param mixed      $info Any included data is saved in the attached object info array indexed by 'data'
31
+	 * @return bool
32
+	 */
33
+	public function add($message, $info = null)
34
+	{
35
+		$attached = parent::add($message);
36
+		// ensure $info is an array if not already
37
+		$info = $info === null ? $info = array() : (array) $info;
38
+		$data = $this->_init_data($info, $attached, $message);
39
+		if ($attached) {
40
+			$this->set_info($message, $data);
41
+		}
42
+		return $attached;
43
+	}
44 44
 
45 45
 
46
-    /**
47
-     * Initializes the data from the incoming info.
48
-     *
49
-     * @param array      $info     incoming data.
50
-     * @param bool       $attached Indicates whether the object was attached successfully.
51
-     * @param EE_Message $message
52
-     * @return array
53
-     */
54
-    protected function _init_data($info, $attached, $message)
55
-    {
56
-        $data = array(
57
-            'test_send'               => false,
58
-            'preview'                 => false,
59
-            'data_handler_class_name' => '',
60
-            'data'                    => array(
61
-                'MSG_generation_data' => array(),
62
-            ),
63
-        );
64
-        if (isset($info['preview'])) {
65
-            $data['preview'] = $info['preview'];
66
-            unset($info['preview']);
67
-        }
68
-        if (isset($info['test_send'])) {
69
-            $data['test_send'] = $info['test_send'];
70
-            unset($info['test_send']);
71
-        }
72
-        if (isset($info['data_handler_class_name'])) {
73
-            $data['data_handler_class_name'] = $info['data_handler_class_name'];
74
-            unset($info['data_handler_class_name']);
75
-        }
76
-        if ($attached && $message->STS_ID() === EEM_Message::status_incomplete) {
77
-            $generation_data = isset($info['MSG_generation_data']) ? $info['MSG_generation_data'] : array();
78
-            // if data isn't in $info...let's see if its available via the message object
79
-            $generation_data = ! $generation_data ? $message->get_generation_data() : $generation_data;
80
-            // still empty then let's just use info
81
-            $generation_data                     = ! $generation_data ? $info : $generation_data;
82
-            $data['data']['MSG_generation_data'] = $generation_data;
83
-        }
84
-        return $data;
85
-    }
46
+	/**
47
+	 * Initializes the data from the incoming info.
48
+	 *
49
+	 * @param array      $info     incoming data.
50
+	 * @param bool       $attached Indicates whether the object was attached successfully.
51
+	 * @param EE_Message $message
52
+	 * @return array
53
+	 */
54
+	protected function _init_data($info, $attached, $message)
55
+	{
56
+		$data = array(
57
+			'test_send'               => false,
58
+			'preview'                 => false,
59
+			'data_handler_class_name' => '',
60
+			'data'                    => array(
61
+				'MSG_generation_data' => array(),
62
+			),
63
+		);
64
+		if (isset($info['preview'])) {
65
+			$data['preview'] = $info['preview'];
66
+			unset($info['preview']);
67
+		}
68
+		if (isset($info['test_send'])) {
69
+			$data['test_send'] = $info['test_send'];
70
+			unset($info['test_send']);
71
+		}
72
+		if (isset($info['data_handler_class_name'])) {
73
+			$data['data_handler_class_name'] = $info['data_handler_class_name'];
74
+			unset($info['data_handler_class_name']);
75
+		}
76
+		if ($attached && $message->STS_ID() === EEM_Message::status_incomplete) {
77
+			$generation_data = isset($info['MSG_generation_data']) ? $info['MSG_generation_data'] : array();
78
+			// if data isn't in $info...let's see if its available via the message object
79
+			$generation_data = ! $generation_data ? $message->get_generation_data() : $generation_data;
80
+			// still empty then let's just use info
81
+			$generation_data                     = ! $generation_data ? $info : $generation_data;
82
+			$data['data']['MSG_generation_data'] = $generation_data;
83
+		}
84
+		return $data;
85
+	}
86 86
 
87 87
 
88
-    /**
89
-     * Save all EE_Message objects to the db.
90
-     *
91
-     * @param bool $do_hooks_only  When true, only the hooks related to saving are fired.
92
-     * @return array array(
93
-     *                  'updated' => 0, //count of how many messages updated
94
-     *                  'notupdated' => 0, //count of how many messages not updated.
95
-     *                  'errors' => array( $token ), //array of message object tokens that had errors in saving
96
-     *                  )
97
-     */
98
-    public function saveAll($do_hooks_only = false)
99
-    {
100
-        $save_tracking = array('updated' => 0, 'notupdated' => 0, 'errors' => array());
88
+	/**
89
+	 * Save all EE_Message objects to the db.
90
+	 *
91
+	 * @param bool $do_hooks_only  When true, only the hooks related to saving are fired.
92
+	 * @return array array(
93
+	 *                  'updated' => 0, //count of how many messages updated
94
+	 *                  'notupdated' => 0, //count of how many messages not updated.
95
+	 *                  'errors' => array( $token ), //array of message object tokens that had errors in saving
96
+	 *                  )
97
+	 */
98
+	public function saveAll($do_hooks_only = false)
99
+	{
100
+		$save_tracking = array('updated' => 0, 'notupdated' => 0, 'errors' => array());
101 101
 
102
-        if (! $do_hooks_only) {
103
-            $this->rewind();
104
-            // exit early if there is nothing to save.
105
-            if ($this->count() < 1) {
106
-                return $save_tracking;
107
-            }
102
+		if (! $do_hooks_only) {
103
+			$this->rewind();
104
+			// exit early if there is nothing to save.
105
+			if ($this->count() < 1) {
106
+				return $save_tracking;
107
+			}
108 108
 
109
-            while ($this->valid()) {
110
-                $saved = $this->current()->save();
111
-                if ($saved === false) {
112
-                    $save_tracking['errors'][] = $this->current()->MSG_token();
113
-                } elseif ($saved) {
114
-                    $save_tracking['updated']++;
115
-                } else {
116
-                    $save_tracking['notupdated']++;
117
-                }
118
-                // maybe persist generation data if this is an incomplete EE_Message.
119
-                $this->_maybe_persist_attached_data();
109
+			while ($this->valid()) {
110
+				$saved = $this->current()->save();
111
+				if ($saved === false) {
112
+					$save_tracking['errors'][] = $this->current()->MSG_token();
113
+				} elseif ($saved) {
114
+					$save_tracking['updated']++;
115
+				} else {
116
+					$save_tracking['notupdated']++;
117
+				}
118
+				// maybe persist generation data if this is an incomplete EE_Message.
119
+				$this->_maybe_persist_attached_data();
120 120
 
121
-                $this->next();
122
-            }
123
-        }
124
-        do_action('AHEE__EE_Message_Repository__saveAll__after', $save_tracking, $this, $do_hooks_only);
125
-        return $save_tracking;
126
-    }
121
+				$this->next();
122
+			}
123
+		}
124
+		do_action('AHEE__EE_Message_Repository__saveAll__after', $save_tracking, $this, $do_hooks_only);
125
+		return $save_tracking;
126
+	}
127 127
 
128 128
 
129
-    /**
130
-     * Retrieves a EE_Message from the repository that matches the given token.
131
-     *
132
-     * @param string $token Token.
133
-     * @return EE_Message | null
134
-     */
135
-    public function getMessageByToken($token)
136
-    {
137
-        $this->rewind();
138
-        while ($this->valid()) {
139
-            if ($this->current()->MSG_token() === $token) {
140
-                $message = $this->current();
141
-                $this->rewind();
142
-                return $message;
143
-            }
144
-            $this->next();
145
-        }
146
-        return null;
147
-    }
129
+	/**
130
+	 * Retrieves a EE_Message from the repository that matches the given token.
131
+	 *
132
+	 * @param string $token Token.
133
+	 * @return EE_Message | null
134
+	 */
135
+	public function getMessageByToken($token)
136
+	{
137
+		$this->rewind();
138
+		while ($this->valid()) {
139
+			if ($this->current()->MSG_token() === $token) {
140
+				$message = $this->current();
141
+				$this->rewind();
142
+				return $message;
143
+			}
144
+			$this->next();
145
+		}
146
+		return null;
147
+	}
148 148
 
149 149
 
150
-    /**
151
-     * This retrieves any data required for generation that may be saved with the current EE_Message in storage.
152
-     *
153
-     * @return array();
154
-     */
155
-    public function get_generation_data()
156
-    {
157
-        // first verify we're at a valid iterator point.
158
-        if (! $this->valid()) {
159
-            return array();
160
-        }
161
-        $info = $this->getInfo();
162
-        return isset($info['data']) && isset($info['data']['MSG_generation_data']) ? $info['data']['MSG_generation_data'] : array();
163
-    }
150
+	/**
151
+	 * This retrieves any data required for generation that may be saved with the current EE_Message in storage.
152
+	 *
153
+	 * @return array();
154
+	 */
155
+	public function get_generation_data()
156
+	{
157
+		// first verify we're at a valid iterator point.
158
+		if (! $this->valid()) {
159
+			return array();
160
+		}
161
+		$info = $this->getInfo();
162
+		return isset($info['data']) && isset($info['data']['MSG_generation_data']) ? $info['data']['MSG_generation_data'] : array();
163
+	}
164 164
 
165 165
 
166
-    /**
167
-     * Retrieves the data_handler_class_name or reference associated with the current EE_Message object in the iterator.
168
-     *
169
-     * @return string
170
-     */
171
-    public function get_data_handler()
172
-    {
173
-        if (! $this->valid()) {
174
-            return '';
175
-        }
176
-        $info = $this->getInfo();
177
-        return isset($info['data_handler_class_name']) ? $info['data_handler_class_name'] : '';
178
-    }
166
+	/**
167
+	 * Retrieves the data_handler_class_name or reference associated with the current EE_Message object in the iterator.
168
+	 *
169
+	 * @return string
170
+	 */
171
+	public function get_data_handler()
172
+	{
173
+		if (! $this->valid()) {
174
+			return '';
175
+		}
176
+		$info = $this->getInfo();
177
+		return isset($info['data_handler_class_name']) ? $info['data_handler_class_name'] : '';
178
+	}
179 179
 
180 180
 
181
-    /**
182
-     * Returns whether this EE_Message is for a preview or not.
183
-     *
184
-     * @return bool
185
-     */
186
-    public function is_preview()
187
-    {
188
-        if (! $this->valid()) {
189
-            return false;
190
-        }
191
-        $info = $this->getInfo();
192
-        return $info['preview'];
193
-    }
181
+	/**
182
+	 * Returns whether this EE_Message is for a preview or not.
183
+	 *
184
+	 * @return bool
185
+	 */
186
+	public function is_preview()
187
+	{
188
+		if (! $this->valid()) {
189
+			return false;
190
+		}
191
+		$info = $this->getInfo();
192
+		return $info['preview'];
193
+	}
194 194
 
195 195
 
196
-    /**
197
-     * Returns whether the current message pointed to is for a test send.
198
-     *
199
-     * @return bool
200
-     */
201
-    public function is_test_send()
202
-    {
203
-        if (! $this->valid()) {
204
-            return false;
205
-        }
206
-        $info = $this->getInfo();
207
-        return $info['test_send'];
208
-    }
196
+	/**
197
+	 * Returns whether the current message pointed to is for a test send.
198
+	 *
199
+	 * @return bool
200
+	 */
201
+	public function is_test_send()
202
+	{
203
+		if (! $this->valid()) {
204
+			return false;
205
+		}
206
+		$info = $this->getInfo();
207
+		return $info['test_send'];
208
+	}
209 209
 
210 210
 
211
-    /**
212
-     *  This checks if the current EE_Message in the iterator is incomplete. If it is, then
213
-     *  data is attached for later retrieval (batch generation).
214
-     */
215
-    protected function _maybe_persist_attached_data()
216
-    {
217
-        if (! $this->valid()) {
218
-            return;
219
-        }
211
+	/**
212
+	 *  This checks if the current EE_Message in the iterator is incomplete. If it is, then
213
+	 *  data is attached for later retrieval (batch generation).
214
+	 */
215
+	protected function _maybe_persist_attached_data()
216
+	{
217
+		if (! $this->valid()) {
218
+			return;
219
+		}
220 220
 
221
-        $info                    = $this->getInfo();
222
-        $data_handler_class_name = isset($info['data_handler_class_name']) ? $info['data_handler_class_name'] : '';
223
-        $data                    = isset($info['data']) && isset($info['data']['MSG_generation_data']) ? $info['data']['MSG_generation_data'] : array();
224
-        if ($data && $this->current()->STS_ID() === EEM_Message::status_incomplete) {
225
-            $this->current()->set_generation_data($data);
226
-            $this->current()->set_field_or_extra_meta('data_handler_class_name', $data_handler_class_name);
227
-        }
228
-    }
221
+		$info                    = $this->getInfo();
222
+		$data_handler_class_name = isset($info['data_handler_class_name']) ? $info['data_handler_class_name'] : '';
223
+		$data                    = isset($info['data']) && isset($info['data']['MSG_generation_data']) ? $info['data']['MSG_generation_data'] : array();
224
+		if ($data && $this->current()->STS_ID() === EEM_Message::status_incomplete) {
225
+			$this->current()->set_generation_data($data);
226
+			$this->current()->set_field_or_extra_meta('data_handler_class_name', $data_handler_class_name);
227
+		}
228
+	}
229 229
 
230 230
 
231
-    /**
232
-     * This method returns a count of messages in the repository that have a given priority.
233
-     *
234
-     * @param int   $priority the priority that is being filtered for the count.
235
-     * @param array $status   the optional status(es) that will also be filtered by when priority matches.
236
-     * @return int  count of messages in the queue matching the conditions.
237
-     */
238
-    public function count_by_priority_and_status($priority, $status = array())
239
-    {
240
-        if (! empty($status)) {
241
-            $status = is_array($status) ? $status : array($status);
242
-        }
231
+	/**
232
+	 * This method returns a count of messages in the repository that have a given priority.
233
+	 *
234
+	 * @param int   $priority the priority that is being filtered for the count.
235
+	 * @param array $status   the optional status(es) that will also be filtered by when priority matches.
236
+	 * @return int  count of messages in the queue matching the conditions.
237
+	 */
238
+	public function count_by_priority_and_status($priority, $status = array())
239
+	{
240
+		if (! empty($status)) {
241
+			$status = is_array($status) ? $status : array($status);
242
+		}
243 243
 
244
-        $count = 0;
245
-        $this->rewind();
246
-        while ($this->valid()) {
247
-            if ($this->current()->priority() === $priority && (($status && in_array(
248
-                $this->current()->STS_ID(),
249
-                $status
250
-            )) || ! $status)
251
-            ) {
252
-                $count++;
253
-            }
254
-            $this->next();
255
-        }
256
-        return $count;
257
-    }
244
+		$count = 0;
245
+		$this->rewind();
246
+		while ($this->valid()) {
247
+			if ($this->current()->priority() === $priority && (($status && in_array(
248
+				$this->current()->STS_ID(),
249
+				$status
250
+			)) || ! $status)
251
+			) {
252
+				$count++;
253
+			}
254
+			$this->next();
255
+		}
256
+		return $count;
257
+	}
258 258
 
259 259
 
260
-    /**
261
-     * @return EE_Message
262
-     */
263
-    public function current()
264
-    {
265
-        return parent::current();
266
-    }
260
+	/**
261
+	 * @return EE_Message
262
+	 */
263
+	public function current()
264
+	{
265
+		return parent::current();
266
+	}
267 267
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     {
100 100
         $save_tracking = array('updated' => 0, 'notupdated' => 0, 'errors' => array());
101 101
 
102
-        if (! $do_hooks_only) {
102
+        if ( ! $do_hooks_only) {
103 103
             $this->rewind();
104 104
             // exit early if there is nothing to save.
105 105
             if ($this->count() < 1) {
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     public function get_generation_data()
156 156
     {
157 157
         // first verify we're at a valid iterator point.
158
-        if (! $this->valid()) {
158
+        if ( ! $this->valid()) {
159 159
             return array();
160 160
         }
161 161
         $info = $this->getInfo();
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public function get_data_handler()
172 172
     {
173
-        if (! $this->valid()) {
173
+        if ( ! $this->valid()) {
174 174
             return '';
175 175
         }
176 176
         $info = $this->getInfo();
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
      */
186 186
     public function is_preview()
187 187
     {
188
-        if (! $this->valid()) {
188
+        if ( ! $this->valid()) {
189 189
             return false;
190 190
         }
191 191
         $info = $this->getInfo();
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      */
201 201
     public function is_test_send()
202 202
     {
203
-        if (! $this->valid()) {
203
+        if ( ! $this->valid()) {
204 204
             return false;
205 205
         }
206 206
         $info = $this->getInfo();
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
      */
215 215
     protected function _maybe_persist_attached_data()
216 216
     {
217
-        if (! $this->valid()) {
217
+        if ( ! $this->valid()) {
218 218
             return;
219 219
         }
220 220
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
      */
238 238
     public function count_by_priority_and_status($priority, $status = array())
239 239
     {
240
-        if (! empty($status)) {
240
+        if ( ! empty($status)) {
241 241
             $status = is_array($status) ? $status : array($status);
242 242
         }
243 243
 
Please login to merge, or discard this patch.
core/libraries/messages/EE_Message_Type_Collection.lib.php 2 patches
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -14,168 +14,168 @@
 block discarded – undo
14 14
 class EE_Message_Type_Collection extends EE_Object_Collection
15 15
 {
16 16
 
17
-    /**
18
-     * EE_Message_Type_Collection constructor.
19
-     */
20
-    public function __construct()
21
-    {
22
-        $this->interface = 'EE_message_type';
23
-    }
24
-
25
-
26
-
27
-    /**
28
-     * add
29
-     *
30
-     * attaches an object to the Collection
31
-     * and sets any supplied data associated with the current iterator entry
32
-     * by calling EE_Object_Collection::set_info()
33
-     *
34
-     * @access public
35
-     * @param object $object
36
-     * @param mixed  $info
37
-     * @return bool
38
-     */
39
-    public function add($object, $info = null)
40
-    {
41
-        $info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
42
-        return parent::add($object, $info);
43
-    }
44
-
45
-
46
-
47
-    /**
48
-     * set_info
49
-     *
50
-     * Sets the data associated with an object in the Collection
51
-     * if no $info is supplied, then the spl_object_hash() is used
52
-     *
53
-     * @access public
54
-     * @param object $object
55
-     * @param mixed  $info
56
-     * @return bool
57
-     */
58
-    public function set_info($object, $info = null)
59
-    {
60
-        $info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
61
-        return parent::set_info($object, $info);
62
-    }
63
-
64
-
65
-
66
-    /**
67
-     * get_by_info
68
-     *
69
-     * finds and returns an object in the Collection based on the info that was set using addObject()
70
-     * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
71
-     *
72
-     * @access public
73
-     * @param mixed
74
-     * @return null | object
75
-     */
76
-    public function get_by_info($info)
77
-    {
78
-        return parent::get_by_info(str_replace(' ', '_', strtolower($info)));
79
-    }
80
-
81
-
82
-
83
-    /**
84
-     * has
85
-     *
86
-     * returns TRUE or FALSE depending on whether the supplied object is within the Collection
87
-     *
88
-     * @access public
89
-     * @param object $object
90
-     * @return bool
91
-     */
92
-    public function has($object)
93
-    {
94
-        return parent::has($object);
95
-    }
96
-
97
-
98
-
99
-    /**
100
-     * has_by_name
101
-     *
102
-     * returns TRUE or FALSE depending on whether the supplied message_type classname is within the Collection
103
-     *
104
-     * @access public
105
-     * @param string $message_type_name
106
-     * @return bool
107
-     */
108
-    public function has_by_name($message_type_name)
109
-    {
110
-        return $this->get_by_info($message_type_name) instanceof $this->interface ? true : false;
111
-    }
112
-
113
-
114
-
115
-    /**
116
-     * remove
117
-     *
118
-     * detaches an object from the Collection
119
-     *
120
-     * @access public
121
-     * @param $object
122
-     * @return bool
123
-     */
124
-    public function remove($object)
125
-    {
126
-        return parent::remove($object);
127
-    }
128
-
129
-
130
-
131
-    /**
132
-     * set_current
133
-     *
134
-     * advances pointer to the provided object
135
-     *
136
-     * @access public
137
-     * @param $object
138
-     * @return void
139
-     */
140
-    public function set_current($object)
141
-    {
142
-        parent::set_current($object);
143
-    }
144
-
145
-
146
-
147
-    /**
148
-     * set_current_by_info
149
-     *
150
-     * advances pointer to the object whose info matches that which was provided
151
-     *
152
-     * @access public
153
-     * @param $info
154
-     * @return void
155
-     */
156
-    public function set_current_by_info($info)
157
-    {
158
-        parent::set_current_by_info($info);
159
-    }
160
-
161
-
162
-
163
-    /**
164
-     * show_collection_classes
165
-     *
166
-     * displays list of collection classes if WP_DEBUG is on
167
-     *
168
-     * @access public
169
-     * @return void
170
-     */
171
-    public function show_collection_classes()
172
-    {
173
-        if (WP_DEBUG) {
174
-            $this->rewind();
175
-            while ($this->valid()) {
176
-                echo '<h5 style="color:#2EA2CC;">' . __CLASS__ . ' class : <span style="color:#E76700">' . $this->getInfo() . '</span></h5>';
177
-                $this->next();
178
-            }
179
-        }
180
-    }
17
+	/**
18
+	 * EE_Message_Type_Collection constructor.
19
+	 */
20
+	public function __construct()
21
+	{
22
+		$this->interface = 'EE_message_type';
23
+	}
24
+
25
+
26
+
27
+	/**
28
+	 * add
29
+	 *
30
+	 * attaches an object to the Collection
31
+	 * and sets any supplied data associated with the current iterator entry
32
+	 * by calling EE_Object_Collection::set_info()
33
+	 *
34
+	 * @access public
35
+	 * @param object $object
36
+	 * @param mixed  $info
37
+	 * @return bool
38
+	 */
39
+	public function add($object, $info = null)
40
+	{
41
+		$info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
42
+		return parent::add($object, $info);
43
+	}
44
+
45
+
46
+
47
+	/**
48
+	 * set_info
49
+	 *
50
+	 * Sets the data associated with an object in the Collection
51
+	 * if no $info is supplied, then the spl_object_hash() is used
52
+	 *
53
+	 * @access public
54
+	 * @param object $object
55
+	 * @param mixed  $info
56
+	 * @return bool
57
+	 */
58
+	public function set_info($object, $info = null)
59
+	{
60
+		$info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
61
+		return parent::set_info($object, $info);
62
+	}
63
+
64
+
65
+
66
+	/**
67
+	 * get_by_info
68
+	 *
69
+	 * finds and returns an object in the Collection based on the info that was set using addObject()
70
+	 * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
71
+	 *
72
+	 * @access public
73
+	 * @param mixed
74
+	 * @return null | object
75
+	 */
76
+	public function get_by_info($info)
77
+	{
78
+		return parent::get_by_info(str_replace(' ', '_', strtolower($info)));
79
+	}
80
+
81
+
82
+
83
+	/**
84
+	 * has
85
+	 *
86
+	 * returns TRUE or FALSE depending on whether the supplied object is within the Collection
87
+	 *
88
+	 * @access public
89
+	 * @param object $object
90
+	 * @return bool
91
+	 */
92
+	public function has($object)
93
+	{
94
+		return parent::has($object);
95
+	}
96
+
97
+
98
+
99
+	/**
100
+	 * has_by_name
101
+	 *
102
+	 * returns TRUE or FALSE depending on whether the supplied message_type classname is within the Collection
103
+	 *
104
+	 * @access public
105
+	 * @param string $message_type_name
106
+	 * @return bool
107
+	 */
108
+	public function has_by_name($message_type_name)
109
+	{
110
+		return $this->get_by_info($message_type_name) instanceof $this->interface ? true : false;
111
+	}
112
+
113
+
114
+
115
+	/**
116
+	 * remove
117
+	 *
118
+	 * detaches an object from the Collection
119
+	 *
120
+	 * @access public
121
+	 * @param $object
122
+	 * @return bool
123
+	 */
124
+	public function remove($object)
125
+	{
126
+		return parent::remove($object);
127
+	}
128
+
129
+
130
+
131
+	/**
132
+	 * set_current
133
+	 *
134
+	 * advances pointer to the provided object
135
+	 *
136
+	 * @access public
137
+	 * @param $object
138
+	 * @return void
139
+	 */
140
+	public function set_current($object)
141
+	{
142
+		parent::set_current($object);
143
+	}
144
+
145
+
146
+
147
+	/**
148
+	 * set_current_by_info
149
+	 *
150
+	 * advances pointer to the object whose info matches that which was provided
151
+	 *
152
+	 * @access public
153
+	 * @param $info
154
+	 * @return void
155
+	 */
156
+	public function set_current_by_info($info)
157
+	{
158
+		parent::set_current_by_info($info);
159
+	}
160
+
161
+
162
+
163
+	/**
164
+	 * show_collection_classes
165
+	 *
166
+	 * displays list of collection classes if WP_DEBUG is on
167
+	 *
168
+	 * @access public
169
+	 * @return void
170
+	 */
171
+	public function show_collection_classes()
172
+	{
173
+		if (WP_DEBUG) {
174
+			$this->rewind();
175
+			while ($this->valid()) {
176
+				echo '<h5 style="color:#2EA2CC;">' . __CLASS__ . ' class : <span style="color:#E76700">' . $this->getInfo() . '</span></h5>';
177
+				$this->next();
178
+			}
179
+		}
180
+	}
181 181
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@
 block discarded – undo
173 173
         if (WP_DEBUG) {
174 174
             $this->rewind();
175 175
             while ($this->valid()) {
176
-                echo '<h5 style="color:#2EA2CC;">' . __CLASS__ . ' class : <span style="color:#E76700">' . $this->getInfo() . '</span></h5>';
176
+                echo '<h5 style="color:#2EA2CC;">'.__CLASS__.' class : <span style="color:#E76700">'.$this->getInfo().'</span></h5>';
177 177
                 $this->next();
178 178
             }
179 179
         }
Please login to merge, or discard this patch.
libraries/messages/defaults/EE_Messages_Template_Pack_Default.class.php 2 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -11,71 +11,71 @@
 block discarded – undo
11 11
 class EE_Messages_Template_Pack_Default extends EE_Messages_Template_Pack
12 12
 {
13 13
 
14
-    public function _set_props()
15
-    {
16
-        $this->label = __('Default', 'event_espresso');
17
-        $this->dbref = 'default';
18
-        $this->description = __('This is the default template pack included with Event Espresso core messages system.', 'event_espresso');
19
-        $this->_base_url = EE_PLUGIN_DIR_URL . 'core/libraries/messages/defaults/default/';
20
-        $this->_base_path = EE_LIBRARIES . 'messages/defaults/default/';
21
-        $this->_supports = array(
22
-            'email' => array(
23
-                'cancelled_registration', 'declined_registration', 'not_approved_registration', 'pending_approval', 'registration',
24
-                    'registration_summary',
25
-                'payment_declined', 'payment', 'payment_refund', 'payment_reminder'
26
-                ),
27
-            'html' => array(
28
-                'receipt', 'invoice'
29
-                )
30
-            );
31
-        $this->_default_variation_labels= array(
32
-            'email' => __('Default', 'event_espresso'),
33
-            'html' =>  __('Simple', 'event_espresso')
34
-             );
35
-        $this->_variations = array(
36
-            'html' => array(
37
-                'receipt' =>
38
-                    array(
39
-                    'bauhaus' => __('Bauhaus', 'event_espresso'),
40
-                    'ejs' => __('Elliot Jay Stocks', 'event_espresso'),
41
-                    'horizon' => __('Horizon', 'event_espresso'),
42
-                    'lola' => __('Lola', 'event_espresso'),
43
-                    'tranquility' => __('Tranquility', 'event_espresso'),
44
-                    'union' => __('Union', 'event_espresso'),
45
-                    ),
46
-                'invoice' =>
47
-                    array(
48
-                    'bauhaus' => __('Bauhaus', 'event_espresso'),
49
-                    'ejs' => __('Elliot Jay Stocks', 'event_espresso'),
50
-                    'horizon' => __('Horizon', 'event_espresso'),
51
-                    'lola' => __('Lola', 'event_espresso'),
52
-                    'tranquility' => __('Tranquility', 'event_espresso'),
53
-                    'union' => __('Union', 'event_espresso'),
54
-                    )
55
-                )
56
-            );
57
-    }
14
+	public function _set_props()
15
+	{
16
+		$this->label = __('Default', 'event_espresso');
17
+		$this->dbref = 'default';
18
+		$this->description = __('This is the default template pack included with Event Espresso core messages system.', 'event_espresso');
19
+		$this->_base_url = EE_PLUGIN_DIR_URL . 'core/libraries/messages/defaults/default/';
20
+		$this->_base_path = EE_LIBRARIES . 'messages/defaults/default/';
21
+		$this->_supports = array(
22
+			'email' => array(
23
+				'cancelled_registration', 'declined_registration', 'not_approved_registration', 'pending_approval', 'registration',
24
+					'registration_summary',
25
+				'payment_declined', 'payment', 'payment_refund', 'payment_reminder'
26
+				),
27
+			'html' => array(
28
+				'receipt', 'invoice'
29
+				)
30
+			);
31
+		$this->_default_variation_labels= array(
32
+			'email' => __('Default', 'event_espresso'),
33
+			'html' =>  __('Simple', 'event_espresso')
34
+			 );
35
+		$this->_variations = array(
36
+			'html' => array(
37
+				'receipt' =>
38
+					array(
39
+					'bauhaus' => __('Bauhaus', 'event_espresso'),
40
+					'ejs' => __('Elliot Jay Stocks', 'event_espresso'),
41
+					'horizon' => __('Horizon', 'event_espresso'),
42
+					'lola' => __('Lola', 'event_espresso'),
43
+					'tranquility' => __('Tranquility', 'event_espresso'),
44
+					'union' => __('Union', 'event_espresso'),
45
+					),
46
+				'invoice' =>
47
+					array(
48
+					'bauhaus' => __('Bauhaus', 'event_espresso'),
49
+					'ejs' => __('Elliot Jay Stocks', 'event_espresso'),
50
+					'horizon' => __('Horizon', 'event_espresso'),
51
+					'lola' => __('Lola', 'event_espresso'),
52
+					'tranquility' => __('Tranquility', 'event_espresso'),
53
+					'union' => __('Union', 'event_espresso'),
54
+					)
55
+				)
56
+			);
57
+	}
58 58
 
59 59
 
60 60
 
61
-    public function get_default_variation($messenger, $message_type, $type, $url, $file_extension)
62
-    {
63
-        $base = $url ? $this->_base_url : $this->_base_path;
64
-        $base_path = $this->_base_path;
65
-        // possible variation paths considering whether message type is present or not in the file name.
66
-        $path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_default' . $file_extension;
67
-        $default_path_string = 'variations/' . $messenger . '_' . $type . '_default' . $file_extension;
68
-        // first see if fully validated file exists.
69
-        if (is_readable($base_path . $path_string)) {
70
-            $variation_path = $base . $path_string;
71
-        // otherwise see if default exists.
72
-        } elseif (is_readable($base_path . $default_path_string)) {
73
-            $variation_path = $base . $default_path_string;
74
-        } else {
75
-            // no matches found so nothing is present.
76
-            $variation_path = '';
77
-        }
61
+	public function get_default_variation($messenger, $message_type, $type, $url, $file_extension)
62
+	{
63
+		$base = $url ? $this->_base_url : $this->_base_path;
64
+		$base_path = $this->_base_path;
65
+		// possible variation paths considering whether message type is present or not in the file name.
66
+		$path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_default' . $file_extension;
67
+		$default_path_string = 'variations/' . $messenger . '_' . $type . '_default' . $file_extension;
68
+		// first see if fully validated file exists.
69
+		if (is_readable($base_path . $path_string)) {
70
+			$variation_path = $base . $path_string;
71
+		// otherwise see if default exists.
72
+		} elseif (is_readable($base_path . $default_path_string)) {
73
+			$variation_path = $base . $default_path_string;
74
+		} else {
75
+			// no matches found so nothing is present.
76
+			$variation_path = '';
77
+		}
78 78
 
79
-        return $variation_path;
80
-    }
79
+		return $variation_path;
80
+	}
81 81
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
         $this->label = __('Default', 'event_espresso');
17 17
         $this->dbref = 'default';
18 18
         $this->description = __('This is the default template pack included with Event Espresso core messages system.', 'event_espresso');
19
-        $this->_base_url = EE_PLUGIN_DIR_URL . 'core/libraries/messages/defaults/default/';
20
-        $this->_base_path = EE_LIBRARIES . 'messages/defaults/default/';
19
+        $this->_base_url = EE_PLUGIN_DIR_URL.'core/libraries/messages/defaults/default/';
20
+        $this->_base_path = EE_LIBRARIES.'messages/defaults/default/';
21 21
         $this->_supports = array(
22 22
             'email' => array(
23 23
                 'cancelled_registration', 'declined_registration', 'not_approved_registration', 'pending_approval', 'registration',
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
                 'receipt', 'invoice'
29 29
                 )
30 30
             );
31
-        $this->_default_variation_labels= array(
31
+        $this->_default_variation_labels = array(
32 32
             'email' => __('Default', 'event_espresso'),
33 33
             'html' =>  __('Simple', 'event_espresso')
34 34
              );
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
         $base = $url ? $this->_base_url : $this->_base_path;
64 64
         $base_path = $this->_base_path;
65 65
         // possible variation paths considering whether message type is present or not in the file name.
66
-        $path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_default' . $file_extension;
67
-        $default_path_string = 'variations/' . $messenger . '_' . $type . '_default' . $file_extension;
66
+        $path_string = 'variations/'.$messenger.'_'.$message_type.'_'.$type.'_default'.$file_extension;
67
+        $default_path_string = 'variations/'.$messenger.'_'.$type.'_default'.$file_extension;
68 68
         // first see if fully validated file exists.
69
-        if (is_readable($base_path . $path_string)) {
70
-            $variation_path = $base . $path_string;
69
+        if (is_readable($base_path.$path_string)) {
70
+            $variation_path = $base.$path_string;
71 71
         // otherwise see if default exists.
72
-        } elseif (is_readable($base_path . $default_path_string)) {
73
-            $variation_path = $base . $default_path_string;
72
+        } elseif (is_readable($base_path.$default_path_string)) {
73
+            $variation_path = $base.$default_path_string;
74 74
         } else {
75 75
             // no matches found so nothing is present.
76 76
             $variation_path = '';
Please login to merge, or discard this patch.
messages/defaults/default/html_receipt_ticket_line_item_no_pms.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 <tr class="item">
7 7
     <td>[LINE_ITEM_NAME][LINE_ITEM_TAXABLE_*]</td>
8 8
     <td colspan="2">[LINE_ITEM_DESCRIPTION]
9
-        <p class="ticket-note"><?php echo sprintf(__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), '[TKT_USES_* schema=' . __('any', 'event_espresso') . ']'); ?></p>
9
+        <p class="ticket-note"><?php echo sprintf(__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), '[TKT_USES_* schema='.__('any', 'event_espresso').']'); ?></p>
10 10
     </td>
11 11
     <td class="item_c">[LINE_ITEM_QUANTITY]</td>
12 12
     <td class="item_c">[LINE_ITEM_AMOUNT]</td>
Please login to merge, or discard this patch.
libraries/messages/defaults/default/html_receipt_event_list.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
  */
5 5
 ?>
6 6
 <h3 class="section-title event-name">
7
-    <img class="icon" src="<?php echo EE_IMAGES_URL . 'calendar_year-24x24.png'; ?>"><?php _e("Event Name:", "event_espresso") ?>
7
+    <img class="icon" src="<?php echo EE_IMAGES_URL.'calendar_year-24x24.png'; ?>"><?php _e("Event Name:", "event_espresso") ?>
8 8
     <span class="plain-text">[EVENT_NAME]</span>
9 9
     <span class="small-text link">( <a href="[EVENT_URL]"><?php _e('view', 'event_espresso'); ?></a> )</span>
10 10
 </h3>
Please login to merge, or discard this patch.
libraries/messages/defaults/default/html_receipt_ticket_list.template.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
         <div class="ticket-time-and-place-details">
23 23
             <div class="ticket-time-details">
24 24
                 <h4 class="sub-section-title no-bottom-margin">
25
-                    <img class="icon" src="<?php echo EE_IMAGES_URL . 'clock-16x16.png'; ?>"><?php _e('Date/Time:', 'event_espresso'); ?>
25
+                    <img class="icon" src="<?php echo EE_IMAGES_URL.'clock-16x16.png'; ?>"><?php _e('Date/Time:', 'event_espresso'); ?>
26 26
                 </h4>
27 27
                 <ul class="event-dates">[DATETIME_LIST]</ul>
28 28
             </div>
29 29
             <div class="ticket-place-details">
30 30
                 <h4 class="sub-section-title no-bottom-margin">
31
-                    <img class="icon" src="<?php echo EE_IMAGES_URL . 'location-pin-16x16.png'; ?>"><?php _e('Venue', 'event_espresso'); ?>
31
+                    <img class="icon" src="<?php echo EE_IMAGES_URL.'location-pin-16x16.png'; ?>"><?php _e('Venue', 'event_espresso'); ?>
32 32
                 </h4>
33 33
                 <ul class="event-venues">
34 34
                     <li>[VENUE_TITLE]
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         </div>
40 40
         <div class="ticket-registrations-area">
41 41
             <h4 class="sub-section-title">
42
-                <img class="icon" src="<?php echo EE_IMAGES_URL . 'users-16x16.png'; ?>"><?php _e("Registration Details", "event_espresso"); ?>
42
+                <img class="icon" src="<?php echo EE_IMAGES_URL.'users-16x16.png'; ?>"><?php _e("Registration Details", "event_espresso"); ?>
43 43
                 <span class="small-text link">( <a class="print_button noPrint" href="[PRIMARY_REGISTRANT_FRONTEND_EDIT_REG_LINK]"><?php _e('edit', 'event_espresso'); ?></a> )</span>
44 44
             </h4>
45 45
             <ul class="ticket-registrations-list">[ATTENDEE_LIST]</ul>
Please login to merge, or discard this patch.
libraries/messages/defaults/default/html_receipt_attendee_list.template.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@
 block discarded – undo
6 6
 <li class="ticket-registration">
7 7
     <table class="registration-details">
8 8
         <tr class="odd">
9
-            <th><?php	_e('Attendee', 'event_espresso');?></th>
9
+            <th><?php	_e('Attendee', 'event_espresso'); ?></th>
10 10
             <td>[FNAME] [LNAME] ([ATTENDEE_EMAIL])</td>
11 11
         </tr>
12 12
         <tr>
13
-            <th><?php _e("Registration Code:", "event_espresso");?></th>
13
+            <th><?php _e("Registration Code:", "event_espresso"); ?></th>
14 14
             <td>[REGISTRATION_CODE] - <span class="[REGISTRATION_STATUS_ID]">[REGISTRATION_STATUS_LABEL]</span></td>
15 15
         </tr>
16 16
     </table>
Please login to merge, or discard this patch.