You are here

public function ClientEditForm::buildForm in Acquia Content Hub 8.2

Throws

\Exception

Overrides FormInterface::buildForm

File

modules/acquia_contenthub_publisher/src/Form/Client/ClientEditForm.php, line 20

Class

ClientEditForm
Class ClientEditForm.

Namespace

Drupal\acquia_contenthub_publisher\Form\Client

Code

public function buildForm(array $form, FormStateInterface $form_state, $uuid = NULL) {
  $this->uuid = $uuid;
  $clients = $this->client
    ->getClients();
  $key = array_search($uuid, array_column($clients, 'uuid'));
  if (FALSE === $key) {
    $this
      ->messenger()
      ->addError($this
      ->t("Can't edit client %uuid. The client is not found.", [
      '%uuid' => $uuid,
    ]));
    return $this
      ->redirect('acquia_contenthub.subscription_settings');
  }
  $edit_client = $clients[$key];
  $form['name'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Client name'),
    '#required' => TRUE,
    '#default_value' => $edit_client['name'],
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#button_type' => 'primary',
    '#value' => $this
      ->t('Save'),
  ];
  return $form;
}