function module_builder_admin_update in Module Builder 7.2
Same name and namespace in other branches
- 6.2 includes/module_builder.admin.inc \module_builder_admin_update()
- 7 includes/module_builder.admin.inc \module_builder_admin_update()
Admin hook update form.
1 string reference to 'module_builder_admin_update'
- module_builder_menu in ./
module_builder.module - Implementation of hook_menu().
File
- includes/
module_builder.admin.inc, line 51 - Menu callbacks for admin pages.
Code
function module_builder_admin_update($form, &$form_state) {
module_builder_init_library();
// Get our task, and check hook data is ready.
try {
$mb_task_handler_report = \DrupalCodeBuilder\Factory::getTask('ReportHookDataFolder');
} catch (\DrupalCodeBuilder\Exception\SanityException $e) {
$failed_sanity_level = $e
->getFailedSanityLevel();
switch ($failed_sanity_level) {
case 'hook_directory':
drupal_set_message(t("The hook data directory could not be created or is not writable."), 'error');
break;
case 'hook_data':
drupal_set_message(t("Hook data is not available. Use the 'Process data' tab to get data about hooks and plugins."), 'error');
break;
}
return $form;
}
// The task handler returns sane values for these even if there's no hook
// data.
$last_update = $mb_task_handler_report
->lastUpdatedDate();
$doc_files = $mb_task_handler_report
->listHookFiles();
$directory = \DrupalCodeBuilder\Factory::getEnvironment()
->getHooksDirectory();
$form['intro'] = array(
'#markup' => '<p>' . t("Module Builder analyses your site's code to find data about Drupal components such as hooks, plugins, tagged services, and more." . ' ' . "This processed data is stored in your local filesystem." . ' ' . "You should update the code analysis when updating site code, or updating Module Builder or Drupal Code Builder.") . '</p>',
);
$form['analyse'] = [
'#type' => 'fieldset',
'#title' => "Perform analysis",
];
$form['analyse']['last_update'] = array(
'#markup' => '<p>' . ($last_update ? t('Your last hook documentation update was %date.', array(
'%date' => format_date($last_update, 'large'),
)) : t("The site's code has not yet been analysed.")) . '</p>',
);
$form['analyse']['submit'] = array(
'#type' => 'submit',
'#value' => $last_update ? t('Update code analysis') : t('Perform code analysis'),
);
if ($last_update) {
$form['results'] = [
'#type' => 'fieldset',
'#title' => "Analysis results",
];
$form['results']['text'] = array(
'#markup' => '<p>' . t('You have the following data saved in %dir: ', array(
'%dir' => $directory,
)) . '</p>',
);
$form['results']["files"] = array(
'#markup' => theme('item_list', array(
'items' => $doc_files,
)),
);
}
return $form;
}