public function LingotekSettingsTabProfilesForm::buildForm in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 src/Form/LingotekSettingsTabProfilesForm.php \Drupal\lingotek\Form\LingotekSettingsTabProfilesForm::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 ConfigFormBase::buildForm
File
- src/
Form/ LingotekSettingsTabProfilesForm.php, line 34 - Contains \Drupal\lingotek\Form\LingotekSettingsProfilesForm.
Class
- LingotekSettingsTabProfilesForm
- Configure Lingotek
Namespace
Drupal\lingotek\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$profiles = \Drupal::entityManager()
->getListBuilder('lingotek_profile')
->load();
$this->profile_index = 0;
$header = array(
$this
->t('Profile Name'),
$this
->t('Usage'),
$this
->t('Actions'),
);
$table = array(
'#type' => 'table',
'#header' => $header,
'#empty' => $this
->t('No Entries'),
);
foreach ($this->profiles as $profile) {
$row = array();
$row['profile_name'] = array(
'#markup' => $this
->t(ucwords($profile['name'])),
);
$usage = $this
->retrieveUsage($profile);
$row['usage'] = array(
'#markup' => $this
->t($usage . ' content types'),
);
$row['profile_actions'] = $this
->retrieveActions($profile, $usage);
$table[$profile['name']] = $row;
$this->profile_index++;
}
$form['config_parent'] = array(
'#type' => 'details',
'#title' => $this
->t('Translation Profiles'),
);
$form['config_parent']['table'] = $table;
$form['config_parent']['add_profile'] = $this
->retrieveActions();
return $form;
}