original_string: public static final function restore(array $data, array $logextra) {
          $classname = $data['eventname'];
          $component = $data['component'];
          $action = $data['action'];
          $target = $data['target'];
  
          // Security: make 100% sure this really is an event class.
          if ($classname !== "\\{$component}\\event\\{$target}_{$action}") {
              return false;
          }
  
          if (!class_exists($classname)) {
              return self::restore_unknown($data, $logextra);
          }
          $event = new $classname();
          if (!($event instanceof \core\event\base)) {
              return false;
          }
  
          $event->init(); // Init method of events could be setting custom properties.
          $event->restored = true;
          $event->triggered = true;
          $event->dispatched = true;
          $event->logextra = $logextra;
  
          foreach (self::$fields as $key) {
              if (!array_key_exists($key, $data)) {
                  debugging("Event restore data must contain key $key");
                  $data[$key] = null;
              }
          }
          if (count($data) != count(self::$fields)) {
              foreach ($data as $key => $value) {
                  if (!in_array($key, self::$fields)) {
                      debugging("Event restore data cannot contain key $key");
                      unset($data[$key]);
                  }
              }
          }
          $event->data = $data;
  
          return $event;
      }
code: public static final function restore(array $data, array $logextra) {
          $classname = $data['eventname'];
          $component = $data['component'];
          $action = $data['action'];
          $target = $data['target'];
  
          // Security: make 100% sure this really is an event class.
          if ($classname !== "\\{$component}\\event\\{$target}_{$action}") {
              return false;
          }
  
          if (!class_exists($classname)) {
              return self::restore_unknown($data, $logextra);
          }
          $event = new $classname();
          if (!($event instanceof \core\event\base)) {
              return false;
          }
  
          $event->init(); // Init method of events could be setting custom properties.
          $event->restored = true;
          $event->triggered = true;
          $event->dispatched = true;
          $event->logextra = $logextra;
  
          foreach (self::$fields as $key) {
              if (!array_key_exists($key, $data)) {
                  debugging("Event restore data must contain key $key");
                  $data[$key] = null;
              }
          }
          if (count($data) != count(self::$fields)) {
              foreach ($data as $key => $value) {
                  if (!in_array($key, self::$fields)) {
                      debugging("Event restore data cannot contain key $key");
                      unset($data[$key]);
                  }
              }
          }
          $event->data = $data;
  
          return $event;
      }
code_tokens: public static final function restore ( array $ data , array $ logextra ) { $ classname = $ data [ 'eventname' ] ; $ component = $ data [ 'component' ] ; $ action = $ data [ 'action' ] ; $ target = $ data [ 'target' ] ; // Security: make 100% sure this really is an event class. if ( $ classname !== "\\{$component}\\event\\{$target}_{$action}" ) { return false ; } if ( ! class_exists ( $ classname ) ) { return self :: restore_unknown ( $ data , $ logextra ) ; } $ event = new $ classname ( ) ; if ( ! ( $ event instanceof \ core \ event \ base ) ) { return false ; } $ event -> init ( ) ; // Init method of events could be setting custom properties. $ event -> restored = true ; $ event -> triggered = true ; $ event -> dispatched = true ; $ event -> logextra = $ logextra ; foreach ( self :: $ fields as $ key ) { if ( ! array_key_exists ( $ key , $ data ) ) { debugging ( "Event restore data must contain key $key" ) ; $ data [ $ key ] = null ; } } if ( count ( $ data ) != count ( self :: $ fields ) ) { foreach ( $ data as $ key => $ value ) { if ( ! in_array ( $ key , self :: $ fields ) ) { debugging ( "Event restore data cannot contain key $key" ) ; unset ( $ data [ $ key ] ) ; } } } $ event -> data = $ data ; return $ event ; }
docstring: Restore event from existing historic data.
  
  @param array $data
  @param array $logextra the format is standardised by logging API
  @return bool|\core\event\base
docstring_tokens: Restore event from existing historic data .