Projet

Général

Profil

Révision 1e39edcb

Ajouté par Assos Assos il y a plus de 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/ctools/includes/plugins.inc
200 200
/**
201 201
 * Fetch a group of plugins by name.
202 202
 *
203
 * @param $module
204
 *   The name of the module that utilizes this plugin system. It will be
205
 *   used to call hook_ctools_plugin_$plugin() to get more data about the plugin.
206
 * @param $type
203
 * @param string $module
204
 *   The name of the module that utilizes this plugin system. It will be used to
205
 *   get more data about the plugin as defined on hook_ctools_plugin_type().
206
 * @param string $type
207 207
 *   The type identifier of the plugin.
208
 * @param $id
208
 * @param string $id
209 209
 *   If specified, return only information about plugin with this identifier.
210 210
 *   The system will do its utmost to load only plugins with this id.
211 211
 *
212
 * @return
213
 *   An array of information arrays about the plugins received. The contents
214
 *   of the array are specific to the plugin.
212
 * @return array
213
 *   An array of information arrays about the plugins received. The contents of
214
 *   the array are specific to the plugin.
215 215
 */
216 216
function ctools_get_plugins($module, $type, $id = NULL) {
217 217
  // Store local caches of plugins and plugin info so we don't have to do full
......
224 224

  
225 225
  $info = ctools_plugin_get_plugin_type_info();
226 226

  
227
  // Bail out noisily if an invalid module/type combination is requested.
228 227
  if (!isset($info[$module][$type])) {
229
    watchdog('ctools', 'Invalid plugin module/type combination requested: module @module and type @type', array('@module' => $module, '@type' => $type), WATCHDOG_ERROR);
230
    return array();
228
    // If we don't find the plugin we attempt a cache rebuild before bailing out
229
    $info = ctools_plugin_get_plugin_type_info(TRUE);
230
    // Bail out noisily if an invalid module/type combination is requested.
231
    if (!isset($info[$module][$type])) {
232
      watchdog('ctools', 'Invalid plugin module/type combination requested: module @module and type @type', array('@module' => $module, '@type' => $type), WATCHDOG_ERROR);
233
      return array();
234
    }
231 235
  }
232 236

  
233 237
  // Make sure our plugins array is populated.
......
235 239
    $plugins[$module][$type] = array();
236 240
  }
237 241

  
238
  // Attempt to shortcut this whole piece of code if we already have
239
  // the requested plugin:
242
  // Attempt to shortcut this whole piece of code if we already have the
243
  // requested plugin:
240 244
  if ($id && array_key_exists($id, $plugins[$module][$type])) {
241 245
    return $plugins[$module][$type][$id];
242 246
  }
......
271 275
    $plugins[$module][$type] = ctools_plugin_load_hooks($info[$module][$type]);
272 276
  }
273 277

  
274
  // Then see if we should load all files. We only do this if we
275
  // want a list of all plugins or there was a cache miss.
278
  // Then see if we should load all files. We only do this if we want a list of
279
  // all plugins or there was a cache miss.
276 280
  if (empty($setup[$module][$type]) && ($build_cache || !$id)) {
277 281
    $setup[$module][$type] = TRUE;
278 282
    $plugins[$module][$type] = array_merge($plugins[$module][$type], ctools_plugin_load_includes($info[$module][$type]));
......
296 300
  }
297 301

  
298 302

  
299
  // If we were told earlier that this is cacheable and the cache was
300
  // empty, give something back.
303
  // If we were told earlier that this is cacheable and the cache was empty,
304
  // give something back.
301 305
  if ($build_cache) {
302 306
    cache_set("plugins:$module:$type", $plugins[$module][$type], $info[$module][$type]['cache table']);
303 307
  }

Formats disponibles : Unified diff