You are here

function ctools_context_entity_get_children in Chaos Tool Suite (ctools) 7

1 call to ctools_context_entity_get_children()
ctools_context_entity_get_child in plugins/contexts/entity.inc
1 string reference to 'ctools_context_entity_get_children'
entity.inc in plugins/contexts/entity.inc
Plugin to provide a node context. A node context is a node wrapped in a context object that can be utilized by anything that accepts contexts.

File

plugins/contexts/entity.inc, line 36
Plugin to provide a node context. A node context is a node wrapped in a context object that can be utilized by anything that accepts contexts.

Code

function ctools_context_entity_get_children($plugin, $parent) {
  $entities = entity_get_info();
  $plugins = array();
  foreach ($entities as $entity_type => $entity) {
    $child_plugin = $plugin;
    $child_plugin['title'] = $entity['label'];
    $child_plugin['keyword'] = $entity_type;
    $child_plugin['context name'] = $entity_type;
    $child_plugin['name'] = $parent . ':' . $entity_type;
    $child_plugin['description'] = t('Creates @entity context from an entity ID.', array(
      '@entity' => $entity_type,
    ));
    $child_plugin_id = $parent . ':' . $entity_type;
    drupal_alter('ctools_entity_context', $child_plugin, $entity, $child_plugin_id);
    $plugins[$child_plugin_id] = $child_plugin;
  }
  drupal_alter('ctools_entity_contexts', $plugins);
  return $plugins;
}