1
1
<?php
2
+
2
3
/**
3
4
* @file
4
5
* Patternkit wrapper/abstraction for panels.
@@ -53,12 +54,12 @@ function pkplugins_flush_metadata_cache() {
53
54
/**
54
55
* Utility function to get all Patternkit module metadata.
55
56
*
56
- * @param null $subtype
57
+ * @param string| null $subtype
57
58
* If specified, return only metadata for this subtype.
58
59
* @param bool $reset
59
60
* Optionally force the meta data to be reloaded.
60
61
*
61
- * @return array|stdClass
62
+ * @return array|object
62
63
* Array of metadata objects found or object if specific module requested.
63
64
*/
64
65
function _pkplugins_get_metadata($subtype = NULL, $reset = FALSE) {
@@ -78,23 +79,24 @@ function _pkplugins_get_metadata($subtype = NULL, $reset = FALSE) {
78
79
$patternkit_host . '/api/patterns',
79
80
array(
80
81
'headers' => array('Content-Type' => 'application/json'),
81
- 'timeout' => 10
82
+ 'timeout' => 10,
82
83
)
83
84
);
84
85
if (!empty($patterns) && empty($patterns->error) && $patterns->code == 200) {
85
- $cached_metadata = (array)json_decode($patterns->data);
86
+ $cached_metadata = (array) json_decode($patterns->data);
86
87
87
88
// Cache the data so that we don't have to build it again.
88
89
// (if cache enabled, otherwise just a slow, redundant memcache set).
89
90
if ($pkplugins_cache_enabled == TRUE) {
90
91
cache_set('pkplugins_pk_metadata', $cached_metadata, 'cache', CACHE_PERMANENT);
91
92
}
92
- } else {
93
+ }
94
+ else {
93
95
_pkplugins_show_error(
94
96
'Patternkit failed to load metadata from service (%service_uri): %error',
95
97
array(
96
98
'%service_uri' => $patternkit_host . '/api/patterns',
97
- '%error' => !empty($patterns->error) ? $patterns->error : $patterns->code
99
+ '%error' => !empty($patterns->error) ? $patterns->error : $patterns->code,
98
100
)
99
101
);
100
102
return NULL;
@@ -129,18 +131,16 @@ function _pkplugins_get_metadata($subtype = NULL, $reset = FALSE) {
129
131
*
130
132
* @param string $msg
131
133
* The message to display (with t vars as appropriate).
132
- * @param array $vars
134
+ * @param array $vars
133
135
* Optional array of replacement text appropriate for use in t function.
134
136
* @param string $status
135
137
* Status for the error message. Passed to drupal_set_message.
136
138
*/
137
- function _pkplugins_show_error($msg, $vars = array(), $status = 'error') {
139
+ function _pkplugins_show_error($msg, array $vars = array(), $status = 'error') {
138
140
if (variable_get('pkplugins_show_errors', FALSE) && user_is_logged_in()) {
139
- drupal_set_message(t ($msg, $vars), $status);
141
+ drupal_set_message(format_string ($msg, $vars), $status);
140
142
}
141
143
if (variable_get('pkplugins_log_errors', FALSE)) {
142
144
watchdog('pkplugins', $msg, $vars, WATCHDOG_ERROR);
143
145
}
144
146
}
145
-
146
-
0 commit comments