You are here

function ludwig_form_update_manager_update_form_alter in Ludwig 8

Implements hook_form_FORM_ID_alter().

File

./ludwig.module, line 15
This is the primary module file.

Code

function ludwig_form_update_manager_update_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  // Adds the update warnings which remind user to download
  // missing packages for installed Ludwig manged modules
  // before advancing to 'Drupal database update' step.
  $package_manager = \Drupal::service('ludwig.package_manager');
  $packages = $package_manager
    ->getPackages();
  $providers = array_column($packages, 'provider', 'provider');
  foreach ($providers as $name) {
    if (isset($form['projects']["#options"][$name])) {
      $form['projects']["#options"][$name]['title']['data']['#markup'] .= ' ' . t('<strong>Ludwig managed module!</strong> Don\'t forget to <a href="@packages-url" title="@packages-title" target="_blank">download all required libraries</a> for this module before advancing to "Run database updates" step. <a href="@maintainance-guide-url" title="@maintainance-guide-title" target="_blank">Read more.</a>', [
        '@packages-url' => Url::fromRoute('ludwig.packages')
          ->toString(),
        '@packages-title' => 'Reports > Packages page',
        '@maintainance-guide-url' => 'https://www.drupal.org/docs/contributed-modules/ludwig/maintenance-of-ludwig-managed-modules-update-steps',
        '@maintainance-guide-title' => 'Maintenance of Ludwig managed modules guide',
      ]);
    }
  }
}