You are here

protected function RestUIForm::getGranularity in REST UI 8

Gets a REST resource config's granularity: from the form, otherwise config.

Parameters

string $id: A REST resource config entity ID.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

string Either:

1 call to RestUIForm::getGranularity()
RestUIForm::buildForm in src/Form/RestUIForm.php

File

src/Form/RestUIForm.php, line 137

Class

RestUIForm
Provides a REST resource configuration form.

Namespace

Drupal\restui\Form

Code

protected function getGranularity($id, FormStateInterface $form_state) {
  $granularity = $this
    ->config("rest.resource.{$id}")
    ->get('granularity');
  if ($form_state
    ->hasValue('granularity')) {
    $granularity = $form_state
      ->getValue('granularity');
  }
  if ($granularity === NULL) {
    $granularity = RestResourceConfigInterface::RESOURCE_GRANULARITY;
  }
  return $granularity;
}