Same name in other branches
- 5.0.x src/Form/InfoForm.php \Drupal\advagg\Form\InfoForm::buildForm()
- 6.0.x src/Form/InfoForm.php \Drupal\advagg\Form\InfoForm::buildForm()
- 8.x-3.x src/Form/InfoForm.php \Drupal\advagg\Form\InfoForm::buildForm()
- 8.x-4.x src/Form/InfoForm.php \Drupal\advagg\Form\InfoForm::buildForm()
Fichier
-
src/
Form/ InfoForm.php, line 125
Classe
- InfoForm
- View AdvAgg information for this site.
Namespace
Drupal\advagg\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form = [];
$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',
'#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>',
];
$file_data = $this->advaggFiles
->getAll();
// Get all parent css and js files.
$types = [
'css',
'js',
];
foreach ($types as $type) {
$form[$type] = [
'#type' => 'details',
'#title' => $this->t('@type files', [
'@type' => Unicode::strtoupper($type),
]),
];
}
foreach ($file_data as $name => $info) {
if (!in_array($info['fileext'], $types)) {
continue;
}
$form[$info['fileext']][$info['filename_hash']] = [
'#markup' => '<details><summary>' . $this->translation
->formatPlural($info['changes'], 'changed 1 time - %file<br />', 'changed %changes times - %file<br />', [
'%changes' => $info['changes'],
'%file' => $name,
]) . '</summary><div class="details-wrapper"><pre>' . print_r($info, TRUE) . '</pre></div></details>',
];
}
// Display as module -> hook instead of hook -> module.
ksort($advagg_hooks);
$module_hooks = [];
foreach ($advagg_hooks as $hook => $values) {
if (!empty($values)) {
foreach ($values as $module_name) {
if (!isset($module_hooks[$module_name])) {
$module_hooks[$module_name] = [];
}
$module_hooks[$module_name][] = $hook;
}
}
else {
$module_hooks['not in use'][] = $hook;
}
}
ksort($module_hooks);
$form['modules_implementing_advagg'] = [
'#type' => 'details',
'#title' => $this->t('Modules implementing aggregate hooks'),
];
$form['hooks_implemented'] = [
'#type' => 'details',
'#title' => $this->t('AdvAgg CSS/JS hooks implemented by modules'),
];
// Output all advagg hooks implemented.
foreach ($module_hooks as $hook => $values) {
if (empty($values)) {
$form['modules_implementing_advagg'][$hook] = [
'#markup' => '<div><strong>' . $hook . ':</strong> 0</div>',
];
}
else {
$form['modules_implementing_advagg'][$hook] = [
'#markup' => '<div><strong>' . $hook . ':</strong> ' . count($values) . $this->formatList($values) . '</div>',
];
}
}
// 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>',
];
}
}
// Output what is used inside of advagg_get_current_hooks_hash().
$form['hooks_variables_hash'] = [
'#type' => 'details',
'#title' => $this->t('Hooks And Variables Used In Hash'),
];
$form['hooks_variables_hash']['description'] = [
'#markup' => $this->t('Current Value: %value. Below is the listing of variables and hooks used to generate the 3rd hash of an aggregates filename.', [
'%value' => advagg_get_current_hooks_hash(),
]),
];
$form['hooks_variables_hash']['output'] = [
// @ignore production_php
'#markup' => '<pre>' . print_r(advagg_current_hooks_hash_array(), TRUE) . '</pre>',
];
// Get info about a file.
$form['get_info_about_agg'] = [
'#type' => 'details',
'#open' => TRUE,
'#title' => $this->t('Get detailed info about an aggregate 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',
],
];
$form['get_info_about_agg']['tip'] = [
'#markup' => '<p>' . $this->t('Takes input like "@css_file" or a full aggregate name like "@advagg_js"', [
'@css_file' => $this->advaggFiles
->getRandomKey(),
'@advagg_js' => $this->advaggAggregates
->getRandom()['uid'],
]) . '</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;
}