You are here

public function ThemeSwitcherRuleListBuilder::buildForm in Theme Switcher Rules 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

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

Return value

array The form structure.

Overrides DraggableListBuilder::buildForm

File

src/Controller/ThemeSwitcherRuleListBuilder.php, line 74

Class

ThemeSwitcherRuleListBuilder
Provides a listing of theme_switcher_rule.

Namespace

Drupal\theme_switcher\Controller

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $form[$this->entitiesKey]['#rules'] = $this->entities;
  $form['actions']['submit']['#value'] = $this
    ->t('Save configuration');

  // Only super-admins may sort switch theme rules.
  if (!$this->currentUser
    ->hasPermission('administer theme switcher rules')) {
    $form['actions']['submit']['#access'] = FALSE;
    unset($form['entities']['#tabledrag']);
  }
  return $form;
}