Skip to content

Instantly share code, notes, and snippets.

@johnrobertwilson
Created September 13, 2011 19:29
Show Gist options
  • Save johnrobertwilson/1214818 to your computer and use it in GitHub Desktop.
Save johnrobertwilson/1214818 to your computer and use it in GitHub Desktop.
Entities by typ
/**
* Form builder for the bundle configuration form.
*
* @see apachesolr_indexer_config_form_submit().
*/
function apachesolr_indexer_config_form() {
$form['bundles'] = array(
'#type' => 'markup',
'#markup' => t('Select the entity types and bundles that should be indexed.'),
);
// For future extensibility, when we have multiple cores.
$form['core'] = array(
'#type' => 'value',
'#value' => 'default',
);
foreach (entity_get_info() as $entity_type => $entity_info) {
if ($entity_info['apachesolr']['indexable']) {
$options = array();
foreach ($entity_info['bundles'] as $key => $info) {
$options[$key] = $info['label'];
}
$form['entities']['#tree'] = TRUE;
$form['entities'][$entity_type] = array(
'#type' => 'checkboxes',
'#title' => $entity_info['label'],
'#options' => $options,
'#default_value' => apachesolr_indexer_get_bundles('default', $entity_type),
);
}
}
$form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
return $form;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment