function opigno_lms_form_install_configure_form_alter in Opigno LMS 3.x
Same name and namespace in other branches
- 8.2 opigno_lms.profile \opigno_lms_form_install_configure_form_alter()
- 8 opigno_lms.profile \opigno_lms_form_install_configure_form_alter()
- 7 opigno_lms.profile \opigno_lms_form_install_configure_form_alter()
Implements hook_form_FORM_ID_alter() for install_configure_form().
Allows the profile to alter the site configuration form.
File
- ./
opigno_lms.profile, line 45 - Enables modules and site configuration for a opigno_lms site installation.
Code
function opigno_lms_form_install_configure_form_alter(&$form, FormStateInterface $form_state) {
$messenger = \Drupal::messenger();
// Check if Tincan PHP library is installed.
$has_library = class_exists('TinCan\\Statement');
if (!$has_library) {
$messenger
->addWarning(Markup::create("Please install the TinCanPHP library using Composer, with the command: <em>composer require rusticisoftware/tincan:@stable</em>"));
}
else {
// Check if the LRS settings are set.
$config = \Drupal::config('opigno_tincan_api.settings');
$endpoint = $config
->get('opigno_tincan_api_endpoint');
$username = $config
->get('opigno_tincan_api_username');
$password = $config
->get('opigno_tincan_api_password');
if (empty($endpoint) || empty($username) || empty($password)) {
$messenger
->addWarning(t('Please configure the LRS connection in the @setting_page.', [
'@setting_page' => Link::createFromRoute('settings page', 'opigno_tincan_api.settings_form')
->toString(),
]));
return;
}
}
// Send message for install pdf.js library if it's not installed.
$pdf_js_library = file_exists('libraries/pdf.js/build/pdf.js') && file_exists('libraries/pdf.js/build/pdf.worker.js');
if (!$pdf_js_library) {
$message = t('pdf.js library is not installed. Please install it from <a href="@library">here</a> and place in <em>libraries/</em> folder', [
'@library' => 'http://mozilla.github.io/pdf.js/getting_started/',
]);
$messenger
->addWarning(Markup::create($message));
}
}