function linkit_entity_ctools_linkit_get_children in Linkit 7.3
Same name and namespace in other branches
- 7.2 plugins/linkit_plugins/entity.inc \linkit_entity_ctools_linkit_get_children()
Get all child Linkit search plugins.
1 call to linkit_entity_ctools_linkit_get_children()
- linkit_entity_ctools_linkit_get_child in plugins/
linkit_search/ entity.inc - Get a single Linkit search plugin.
1 string reference to 'linkit_entity_ctools_linkit_get_children'
- entity.inc in plugins/
linkit_search/ entity.inc - Linkit Entity Search Plugin.
File
- plugins/
linkit_search/ entity.inc, line 35 - Linkit Entity Search Plugin.
Code
function linkit_entity_ctools_linkit_get_children($plugin, $parent) {
$entities = entity_get_info();
$plugins = array();
// The alternative plugins is extensions of the provided
// LinkitSearchPluginEntity class provided by Linkit.
$alternative_plugins = array(
'entity:node',
'entity:user',
'entity:taxonomy_term',
'entity:file',
);
foreach ($entities as $entity_type => $entity) {
// The entity must have an URI CALLBACK defined.
if (!isset($entity['uri callback'])) {
continue;
}
$plugin_child = $plugin;
$plugin_child['ui_title'] = $entity['label'];
$plugin_child['ui_description'] = t('Extend Linkit with @entity support.', array(
'@entity' => $entity_type,
));
$plugin_child['name'] = $parent . ':' . $entity_type;
$plugin_child['entity_type'] = $entity_type;
// If there is an alternative search class for this entity, change the handler.
if (in_array('entity:' . $entity_type, $alternative_plugins)) {
$handler = array(
'class' => 'LinkitSearchPlugin' . drupal_ucfirst($entity_type),
'file' => $entity_type . '.class.php',
);
$plugin_child['handler'] = $handler;
}
drupal_alter('linkit_search_plugin_entity', $plugin_child, $entity);
$plugins[$parent . ':' . $entity_type] = $plugin_child;
}
drupal_alter('linkit_search_plugin_entities', $plugins);
// Test the plugins.
foreach ($plugins as $plugin_name => $plugin) {
// In some cases the plugins isn't auto loaded. Ctools handle this for us.
// This is typical when installing Linkit.
if (!class_exists($plugin['handler']['class'])) {
continue;
}
$tested_plugin = new $plugin['handler']['class']($plugin, new LinkitProfile());
if (isset($tested_plugin->unusable) && $tested_plugin->unusable) {
unset($plugins[$plugin_name]);
}
}
return $plugins;
}