original_string: protected static function init_all_observers() {
          global $CFG;
  
          if (is_array(self::$allobservers)) {
              return;
          }
  
          if (!PHPUNIT_TEST and !during_initial_install()) {
              $cache = \cache::make('core', 'observers');
              $cached = $cache->get('all');
              $dirroot = $cache->get('dirroot');
              if ($dirroot === $CFG->dirroot and is_array($cached)) {
                  self::$allobservers = $cached;
                  return;
              }
          }
  
          self::$allobservers = array();
  
          $plugintypes = \core_component::get_plugin_types();
          $plugintypes = array_merge(array('core' => 'not used'), $plugintypes);
          $systemdone = false;
          foreach ($plugintypes as $plugintype => $ignored) {
              if ($plugintype === 'core') {
                  $plugins['core'] = "$CFG->dirroot/lib";
              } else {
                  $plugins = \core_component::get_plugin_list($plugintype);
              }
  
              foreach ($plugins as $plugin => $fulldir) {
                  if (!file_exists("$fulldir/db/events.php")) {
                      continue;
                  }
                  $observers = null;
                  include("$fulldir/db/events.php");
                  if (!is_array($observers)) {
                      continue;
                  }
                  self::add_observers($observers, "$fulldir/db/events.php", $plugintype, $plugin);
              }
          }
  
          self::order_all_observers();
  
          if (!PHPUNIT_TEST and !during_initial_install()) {
              $cache->set('all', self::$allobservers);
              $cache->set('dirroot', $CFG->dirroot);
          }
      }
code: protected static function init_all_observers() {
          global $CFG;
  
          if (is_array(self::$allobservers)) {
              return;
          }
  
          if (!PHPUNIT_TEST and !during_initial_install()) {
              $cache = \cache::make('core', 'observers');
              $cached = $cache->get('all');
              $dirroot = $cache->get('dirroot');
              if ($dirroot === $CFG->dirroot and is_array($cached)) {
                  self::$allobservers = $cached;
                  return;
              }
          }
  
          self::$allobservers = array();
  
          $plugintypes = \core_component::get_plugin_types();
          $plugintypes = array_merge(array('core' => 'not used'), $plugintypes);
          $systemdone = false;
          foreach ($plugintypes as $plugintype => $ignored) {
              if ($plugintype === 'core') {
                  $plugins['core'] = "$CFG->dirroot/lib";
              } else {
                  $plugins = \core_component::get_plugin_list($plugintype);
              }
  
              foreach ($plugins as $plugin => $fulldir) {
                  if (!file_exists("$fulldir/db/events.php")) {
                      continue;
                  }
                  $observers = null;
                  include("$fulldir/db/events.php");
                  if (!is_array($observers)) {
                      continue;
                  }
                  self::add_observers($observers, "$fulldir/db/events.php", $plugintype, $plugin);
              }
          }
  
          self::order_all_observers();
  
          if (!PHPUNIT_TEST and !during_initial_install()) {
              $cache->set('all', self::$allobservers);
              $cache->set('dirroot', $CFG->dirroot);
          }
      }
code_tokens: protected static function init_all_observers ( ) { global $ CFG ; if ( is_array ( self :: $ allobservers ) ) { return ; } if ( ! PHPUNIT_TEST and ! during_initial_install ( ) ) { $ cache = \ cache :: make ( 'core' , 'observers' ) ; $ cached = $ cache -> get ( 'all' ) ; $ dirroot = $ cache -> get ( 'dirroot' ) ; if ( $ dirroot === $ CFG -> dirroot and is_array ( $ cached ) ) { self :: $ allobservers = $ cached ; return ; } } self :: $ allobservers = array ( ) ; $ plugintypes = \ core_component :: get_plugin_types ( ) ; $ plugintypes = array_merge ( array ( 'core' => 'not used' ) , $ plugintypes ) ; $ systemdone = false ; foreach ( $ plugintypes as $ plugintype => $ ignored ) { if ( $ plugintype === 'core' ) { $ plugins [ 'core' ] = "$CFG->dirroot/lib" ; } else { $ plugins = \ core_component :: get_plugin_list ( $ plugintype ) ; } foreach ( $ plugins as $ plugin => $ fulldir ) { if ( ! file_exists ( "$fulldir/db/events.php" ) ) { continue ; } $ observers = null ; include ( "$fulldir/db/events.php" ) ; if ( ! is_array ( $ observers ) ) { continue ; } self :: add_observers ( $ observers , "$fulldir/db/events.php" , $ plugintype , $ plugin ) ; } } self :: order_all_observers ( ) ; if ( ! PHPUNIT_TEST and ! during_initial_install ( ) ) { $ cache -> set ( 'all' , self :: $ allobservers ) ; $ cache -> set ( 'dirroot' , $ CFG -> dirroot ) ; } }
docstring: Initialise the list of observers.
docstring_tokens: Initialise the list of observers .