public function UpgradeRectorForm::buildForm in Upgrade Rector 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 FormInterface::buildForm
File
- src/
Form/ UpgradeRectorForm.php, line 88
Class
Namespace
Drupal\upgrade_rector\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['#attached']['library'][] = 'upgrade_rector/upgrade_rector.admin';
// Gather project list grouped by custom and contrib projects.
$projects = $this->projectCollector
->collectProjects();
// List custom project status first.
$custom = [
'#type' => 'markup',
'#markup' => '<br /><strong>' . $this
->t('No custom projects found.') . '</strong>',
];
if (count($projects['custom'])) {
$custom = $this
->buildProjectList($projects['custom'], 'custom');
}
$form['custom'] = [
'#type' => 'details',
'#title' => $this
->t('Custom projects'),
'#description' => $this
->t('Custom code is specific to your site, and must be upgraded manually. <a href=":upgrade">Read more about how developers can upgrade their code to Drupal 9</a>.', [
':upgrade' => 'https://www.drupal.org/docs/9/how-drupal-9-is-made-and-what-is-included/how-and-why-we-deprecate-on-the-way-to-drupal-9',
]),
'#open' => TRUE,
'#attributes' => [
'class' => [
'upgrade-rector-summary',
],
],
'data' => $custom,
'#tree' => TRUE,
];
// List contrib project status second.
$contrib = [
'#type' => 'markup',
'#markup' => '<br /><strong>' . $this
->t('No contributed projects found.') . '</strong>',
];
if (count($projects['contrib'])) {
$contrib = $this
->buildProjectList($projects['contrib'], 'contrib');
}
$form['contrib'] = [
'#type' => 'details',
'#title' => $this
->t('Contributed projects'),
'#description' => $this
->t('Contributed code is available from drupal.org. Problems here may be partially resolved by updating to the latest version. <a href=":update">Read more about how to update contributed projects</a>.', [
':update' => 'https://www.drupal.org/docs/8/update/update-modules',
]),
'#open' => TRUE,
'#attributes' => [
'class' => [
'upgrade-rector-summary',
],
],
'data' => $contrib,
'#tree' => TRUE,
];
return $form;
}