Form constructor for the REST admin form.
function rest_admin_form($form, &$form_state) {
$resources = drupal_container()
->get('plugin.manager.rest')
->getDefinitions();
$entity_resources = array();
$other_resources = array();
foreach ($resources as $plugin_name => $definition) {
if (strpos($plugin_name, 'entity:') === FALSE) {
$other_resources[$plugin_name] = $definition['label'];
}
else {
$entity_resources[$plugin_name] = $definition['label'];
}
}
asort($entity_resources);
asort($other_resources);
$enabled_resources = config('rest')
->get('resources') ?: array();
$form['entity_resources'] = array(
'#type' => 'checkboxes',
'#options' => $entity_resources,
'#default_value' => $enabled_resources,
'#title' => t('Entity resource types that should be exposed as web services:'),
);
if (!empty($other_resources)) {
$form['other_resources'] = array(
'#type' => 'checkboxes',
'#options' => $other_resources,
'#default_value' => $enabled_resources,
'#title' => t('Other available resource types that should be exposed as web services:'),
);
}
return system_config_form($form, $form_state);
}