function rest_admin_form

Form constructor for the REST admin form.

Related topics

1 string reference to 'rest_admin_form'
rest_menu in drupal/core/modules/rest/rest.module
Implements hook_menu().

File

drupal/core/modules/rest/rest.admin.inc, line 13
Admin pages for REST module.

Code

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);
}