You are here

public function OpenIDConnectLoginForm::buildForm in OpenID Connect / OAuth client 8

Same name and namespace in other branches
  1. 2.x src/Form/OpenIDConnectLoginForm.php \Drupal\openid_connect\Form\OpenIDConnectLoginForm::buildForm()

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 FormInterface::buildForm

File

src/Form/OpenIDConnectLoginForm.php, line 82

Class

OpenIDConnectLoginForm
Provides the OpenID Connect login form.

Namespace

Drupal\openid_connect\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $definitions = $this->pluginManager
    ->getDefinitions();
  foreach ($definitions as $client_id => $client) {
    if (!$this
      ->config('openid_connect.settings.' . $client_id)
      ->get('enabled')) {
      continue;
    }
    $form['openid_connect_client_' . $client_id . '_login'] = [
      '#type' => 'submit',
      '#value' => $this
        ->t('Log in with @client_title', [
        '@client_title' => $client['label'],
      ]),
      '#name' => $client_id,
      '#prefix' => '<div>',
      '#suffix' => '</div>',
    ];
  }
  return $form;
}