template_preprocess_update_report(&$variables)
Prepares variables for project status report templates.
Default template: update-report.html.twig.
Parameters
array $variables: An associative array containing:
- data: An array of data about each project's status.
File
- core/modules/update/update.report.inc, line 21
- Code required only when rendering the available updates report.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | function template_preprocess_update_report(& $variables ) { $data = $variables [ 'data' ]; $last = \Drupal::state()->get( 'update.last_check' ) ? : 0; $variables [ 'last_checked' ] = array ( '#theme' => 'update_last_check' , '#last' => $last , // Attach the library to a variable that gets printed always. '#attached' => array ( 'library' => array ( 'update/drupal.update.admin' , ), ) ); // For no project update data, populate no data message. if ( empty ( $data )) { $variables [ 'no_updates_message' ] = _update_no_data(); } $rows = array (); foreach ( $data as $project ) { $project_status = array ( '#theme' => 'update_project_status' , '#project' => $project , ); // Build project rows. if (!isset( $rows [ $project [ 'project_type' ]])) { $rows [ $project [ 'project_type' ]] = array ( '#type' => 'table' , '#attributes' => array ( 'class' => array ( 'update' )), ); } $row_key = ! empty ( $project [ 'title' ]) ? Unicode:: strtolower ( $project [ 'title' ]) : Unicode:: strtolower ( $project [ 'name' ]); // Add the project status row and details. $rows [ $project [ 'project_type' ]][ $row_key ][ 'status' ] = $project_status ; // Add project status class attribute to the table row. switch ( $project [ 'status' ]) { case UPDATE_CURRENT: $rows [ $project [ 'project_type' ]][ $row_key ][ '#attributes' ] = array ( 'class' => array ( 'color-success' )); break ; case UPDATE_UNKNOWN: case UPDATE_FETCH_PENDING: case UPDATE_NOT_FETCHED: case UPDATE_NOT_SECURE: case UPDATE_REVOKED: case UPDATE_NOT_SUPPORTED: $rows [ $project [ 'project_type' ]][ $row_key ][ '#attributes' ] = array ( 'class' => array ( 'color-error' )); break ; case UPDATE_NOT_CHECKED: case UPDATE_NOT_CURRENT: default : $rows [ $project [ 'project_type' ]][ $row_key ][ '#attributes' ] = array ( 'class' => array ( 'color-warning' )); break ; } } $project_types = array ( 'core' => t( 'Drupal core' ), 'module' => t( 'Modules' ), 'theme' => t( 'Themes' ), 'module-disabled' => t( 'Uninstalled modules' ), 'theme-disabled' => t( 'Uninstalled themes' ), ); $variables [ 'project_types' ] = array (); foreach ( $project_types as $type_name => $type_label ) { if (! empty ( $rows [ $type_name ])) { ksort( $rows [ $type_name ]); $variables [ 'project_types' ][] = array ( 'label' => $type_label , 'table' => $rows [ $type_name ], ); } } } |
Please login to continue.