original_string: public function get_contexts_for_userid(int $userid) : contextlist_collection {
          $progress = static::get_log_tracer();
  
          $components = $this->get_component_list();
          $a = (object) [
              'total' => count($components),
              'progress' => 0,
              'component' => '',
              'datetime' => userdate(time()),
          ];
          $clcollection = new contextlist_collection($userid);
  
          $progress->output(get_string('trace:fetchcomponents', 'core_privacy', $a), 1);
          foreach ($components as $component) {
              $a->component = $component;
              $a->progress++;
              $a->datetime = userdate(time());
              $progress->output(get_string('trace:processingcomponent', 'core_privacy', $a), 2);
              $contextlist = $this->handled_component_class_callback($component, core_user_data_provider::class,
                  'get_contexts_for_userid', [$userid]);
              if ($contextlist === null) {
                  $contextlist = new local\request\contextlist();
              }
  
              // Each contextlist is tied to its respective component.
              $contextlist->set_component($component);
  
              // Add contexts that the component may not know about.
              // Example of these include activity completion which modules do not know about themselves.
              $contextlist = local\request\helper::add_shared_contexts_to_contextlist_for($userid, $contextlist);
  
              if (count($contextlist)) {
                  $clcollection->add_contextlist($contextlist);
              }
          }
          $progress->output(get_string('trace:done', 'core_privacy'), 1);
  
          return $clcollection;
      }
code: public function get_contexts_for_userid(int $userid) : contextlist_collection {
          $progress = static::get_log_tracer();
  
          $components = $this->get_component_list();
          $a = (object) [
              'total' => count($components),
              'progress' => 0,
              'component' => '',
              'datetime' => userdate(time()),
          ];
          $clcollection = new contextlist_collection($userid);
  
          $progress->output(get_string('trace:fetchcomponents', 'core_privacy', $a), 1);
          foreach ($components as $component) {
              $a->component = $component;
              $a->progress++;
              $a->datetime = userdate(time());
              $progress->output(get_string('trace:processingcomponent', 'core_privacy', $a), 2);
              $contextlist = $this->handled_component_class_callback($component, core_user_data_provider::class,
                  'get_contexts_for_userid', [$userid]);
              if ($contextlist === null) {
                  $contextlist = new local\request\contextlist();
              }
  
              // Each contextlist is tied to its respective component.
              $contextlist->set_component($component);
  
              // Add contexts that the component may not know about.
              // Example of these include activity completion which modules do not know about themselves.
              $contextlist = local\request\helper::add_shared_contexts_to_contextlist_for($userid, $contextlist);
  
              if (count($contextlist)) {
                  $clcollection->add_contextlist($contextlist);
              }
          }
          $progress->output(get_string('trace:done', 'core_privacy'), 1);
  
          return $clcollection;
      }
code_tokens: public function get_contexts_for_userid ( int $ userid ) : contextlist_collection { $ progress = static :: get_log_tracer ( ) ; $ components = $ this -> get_component_list ( ) ; $ a = ( object ) [ 'total' => count ( $ components ) , 'progress' => 0 , 'component' => '' , 'datetime' => userdate ( time ( ) ) , ] ; $ clcollection = new contextlist_collection ( $ userid ) ; $ progress -> output ( get_string ( 'trace:fetchcomponents' , 'core_privacy' , $ a ) , 1 ) ; foreach ( $ components as $ component ) { $ a -> component = $ component ; $ a -> progress ++ ; $ a -> datetime = userdate ( time ( ) ) ; $ progress -> output ( get_string ( 'trace:processingcomponent' , 'core_privacy' , $ a ) , 2 ) ; $ contextlist = $ this -> handled_component_class_callback ( $ component , core_user_data_provider :: class , 'get_contexts_for_userid' , [ $ userid ] ) ; if ( $ contextlist === null ) { $ contextlist = new local \ request \ contextlist ( ) ; } // Each contextlist is tied to its respective component. $ contextlist -> set_component ( $ component ) ; // Add contexts that the component may not know about. // Example of these include activity completion which modules do not know about themselves. $ contextlist = local \ request \ helper :: add_shared_contexts_to_contextlist_for ( $ userid , $ contextlist ) ; if ( count ( $ contextlist ) ) { $ clcollection -> add_contextlist ( $ contextlist ) ; } } $ progress -> output ( get_string ( 'trace:done' , 'core_privacy' ) , 1 ) ; return $ clcollection ; }
docstring: Gets a collection of resultset objects for all components.
  
  
  @param int $userid the id of the user we're fetching contexts for.
  @return contextlist_collection the collection of contextlist items for the respective components.
docstring_tokens: Gets a collection of resultset objects for all components .