public function InfoForm::buildForm in Advanced CSS/JS Aggregation 8.3
Same name and namespace in other branches
- 8.4 src/Form/InfoForm.php \Drupal\advagg\Form\InfoForm::buildForm()
- 8.2 src/Form/InfoForm.php \Drupal\advagg\Form\InfoForm::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/ InfoForm.php, line 123
Class
- InfoForm
- View AdvAgg information for this site.
Namespace
Drupal\advagg\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['tip'] = [
'#markup' => '<p>' . $this
->t('This page provides debugging information. There are no configuration options here.') . '</p>',
];
// Get all hooks and variables.
$core_hooks = $this->themeRegistry
->get();
$advagg_hooks = advagg_hooks_implemented();
// Output html preprocess functions hooks.
$form['theme_info'] = [
'#type' => 'details',
'#open' => TRUE,
'#title' => $this
->t('Hook Theme Info'),
];
$data = implode("\n", $core_hooks['html']['preprocess functions']);
$form['theme_info']['advagg_theme_info'] = [
'#markup' => '<p>preprocess functions on html.</p><pre>' . $data . '</pre>',
];
$form['hooks_implemented'] = [
'#type' => 'details',
'#open' => TRUE,
'#title' => $this
->t('Core asset hooks implemented by modules'),
];
// Output all advagg hooks implemented.
foreach ($advagg_hooks as $hook => $values) {
if (empty($values)) {
$form['hooks_implemented'][$hook] = [
'#markup' => '<div><strong>' . $hook . ':</strong> 0</div>',
];
}
else {
$form['hooks_implemented'][$hook] = [
'#markup' => '<div><strong>' . $hook . ':</strong> ' . count($values) . $this
->formatList($values) . '</div>',
];
}
}
// Get info about a file.
$form['get_info_about_agg'] = [
'#type' => 'details',
'#open' => TRUE,
'#title' => $this
->t('Get detailed info about an optimized file'),
];
$form['get_info_about_agg']['filename'] = [
'#type' => 'textfield',
'#size' => 170,
'#maxlength' => 256,
'#default_value' => '',
'#title' => $this
->t('Filename'),
];
$form['get_info_about_agg']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Lookup Details'),
'#submit' => [
'::getFileInfoSubmit',
],
'#validate' => [
'::getFileInfoValidate',
],
'#ajax' => [
'callback' => '::getFileInfoAjax',
'wrapper' => 'advagg-file-info-ajax',
'effect' => 'fade',
],
];
if ($tip = $this
->getRandomFile()) {
$form['get_info_about_agg']['tip'] = [
'#markup' => '<p>' . $this
->t('Input an optimized filename like "@css_file".', [
'@css_file' => $tip,
]) . '</p>',
];
}
$form['get_info_about_agg']['wrapper'] = [
'#prefix' => "<div id='advagg-file-info-ajax'>",
'#suffix' => "</div>",
];
$form = parent::buildForm($form, $form_state);
unset($form['actions']);
return $form;
}