You are here

public function DomainSourceSettingsForm::buildForm in Domain Access 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 ConfigFormBase::buildForm

File

domain_source/src/Form/DomainSourceSettingsForm.php, line 32

Class

DomainSourceSettingsForm
Class DomainSourceSettingsForm.

Namespace

Drupal\domain_source\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $manager = \Drupal::entityTypeManager();
  $routes = $manager
    ->getDefinition('node')
    ->getLinkTemplates();
  $options = [];
  foreach ($routes as $route => $path) {

    // Some parts of the system prepend drupal:, which the routing
    // system doesn't use. The routing system also uses underscores instead
    // of dashes. Because Drupal.
    $route = str_replace([
      '-',
      'drupal:',
    ], [
      '_',
      '',
    ], $route);
    $options[$route] = $route;
  }
  $config = $this
    ->config('domain_source.settings');
  $form['exclude_routes'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Disable link rewrites for the selected routes.'),
    '#default_value' => $config
      ->get('exclude_routes') ?: [],
    '#options' => $options,
    '#description' => $this
      ->t('Check the routes to disable. Any entity URL with a Domain Source field will be rewritten unless its corresponding route is disabled.'),
  ];
  return parent::buildForm($form, $form_state);
}