update_page_top()
Implements hook_page_top().
File
- core/modules/update/update.module, line 110
- Handles updates of Drupal core and contributed projects.
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 | function update_page_top() { /** @var \Drupal\Core\Routing\AdminContext $admin_context */ $admin_context = \Drupal::service( 'router.admin_context' ); $route_match = \Drupal::routeMatch(); if ( $admin_context ->isAdminRoute( $route_match ->getRouteObject()) && \Drupal::currentUser()->hasPermission( 'administer site configuration' )) { $route_name = \Drupal::routeMatch()->getRouteName(); switch ( $route_name ) { // These pages don't need additional nagging. case 'update.theme_update' : case 'system.theme_install' : case 'update.module_update' : case 'update.module_install' : case 'update.status' : case 'update.report_update' : case 'update.report_install' : case 'update.settings' : case 'system.status' : case 'update.confirmation_page' : return ; // If we are on the appearance or modules list, display a detailed report // of the update status. case 'system.themes_page' : case 'system.modules_list' : $verbose = TRUE; break ; } module_load_install( 'update' ); $status = update_requirements( 'runtime' ); foreach ( array ( 'core' , 'contrib' ) as $report_type ) { $type = 'update_' . $report_type ; // hook_requirements() supports render arrays therefore we need to render // them before using drupal_set_message(). if (isset( $status [ $type ][ 'description' ]) && is_array ( $status [ $type ][ 'description' ])) { $status [ $type ][ 'description' ] = \Drupal::service( 'renderer' )->renderPlain( $status [ $type ][ 'description' ]); } if (! empty ( $verbose )) { if (isset( $status [ $type ][ 'severity' ])) { if ( $status [ $type ][ 'severity' ] == REQUIREMENT_ERROR) { drupal_set_message( $status [ $type ][ 'description' ], 'error' ); } elseif ( $status [ $type ][ 'severity' ] == REQUIREMENT_WARNING) { drupal_set_message( $status [ $type ][ 'description' ], 'warning' ); } } } // Otherwise, if we're on *any* admin page and there's a security // update missing, print an error message about it. else { if (isset( $status [ $type ]) && isset( $status [ $type ][ 'reason' ]) && $status [ $type ][ 'reason' ] === UPDATE_NOT_SECURE) { drupal_set_message( $status [ $type ][ 'description' ], 'error' ); } } } } } |
Please login to continue.