original_string: public static function get_fragment($component, $callback, $contextid, $args = null) {
          global $OUTPUT, $PAGE;
  
          $params = self::validate_parameters(self::get_fragment_parameters(),
                  array(
                      'component' => $component,
                      'callback' => $callback,
                      'contextid' => $contextid,
                      'args' => $args
                  )
          );
  
          // Reformat arguments into something less unwieldy.
          $arguments = array();
          foreach ($params['args'] as $paramargument) {
              $arguments[$paramargument['name']] = $paramargument['value'];
          }
  
          $context = context::instance_by_id($contextid);
          self::validate_context($context);
          $arguments['context'] = $context;
  
          // Hack alert: Set a default URL to stop the annoying debug.
          $PAGE->set_url('/');
          // Hack alert: Forcing bootstrap_renderer to initiate moodle page.
          $OUTPUT->header();
  
          // Overwriting page_requirements_manager with the fragment one so only JS included from
          // this point is returned to the user.
          $PAGE->start_collecting_javascript_requirements();
          $data = component_callback($params['component'], 'output_fragment_' . $params['callback'], array($arguments));
          $jsfooter = $PAGE->requires->get_end_code();
          $output = array('html' => $data, 'javascript' => $jsfooter);
          return $output;
      }
code: public static function get_fragment($component, $callback, $contextid, $args = null) {
          global $OUTPUT, $PAGE;
  
          $params = self::validate_parameters(self::get_fragment_parameters(),
                  array(
                      'component' => $component,
                      'callback' => $callback,
                      'contextid' => $contextid,
                      'args' => $args
                  )
          );
  
          // Reformat arguments into something less unwieldy.
          $arguments = array();
          foreach ($params['args'] as $paramargument) {
              $arguments[$paramargument['name']] = $paramargument['value'];
          }
  
          $context = context::instance_by_id($contextid);
          self::validate_context($context);
          $arguments['context'] = $context;
  
          // Hack alert: Set a default URL to stop the annoying debug.
          $PAGE->set_url('/');
          // Hack alert: Forcing bootstrap_renderer to initiate moodle page.
          $OUTPUT->header();
  
          // Overwriting page_requirements_manager with the fragment one so only JS included from
          // this point is returned to the user.
          $PAGE->start_collecting_javascript_requirements();
          $data = component_callback($params['component'], 'output_fragment_' . $params['callback'], array($arguments));
          $jsfooter = $PAGE->requires->get_end_code();
          $output = array('html' => $data, 'javascript' => $jsfooter);
          return $output;
      }
code_tokens: public static function get_fragment ( $ component , $ callback , $ contextid , $ args = null ) { global $ OUTPUT , $ PAGE ; $ params = self :: validate_parameters ( self :: get_fragment_parameters ( ) , array ( 'component' => $ component , 'callback' => $ callback , 'contextid' => $ contextid , 'args' => $ args ) ) ; // Reformat arguments into something less unwieldy. $ arguments = array ( ) ; foreach ( $ params [ 'args' ] as $ paramargument ) { $ arguments [ $ paramargument [ 'name' ] ] = $ paramargument [ 'value' ] ; } $ context = context :: instance_by_id ( $ contextid ) ; self :: validate_context ( $ context ) ; $ arguments [ 'context' ] = $ context ; // Hack alert: Set a default URL to stop the annoying debug. $ PAGE -> set_url ( '/' ) ; // Hack alert: Forcing bootstrap_renderer to initiate moodle page. $ OUTPUT -> header ( ) ; // Overwriting page_requirements_manager with the fragment one so only JS included from // this point is returned to the user. $ PAGE -> start_collecting_javascript_requirements ( ) ; $ data = component_callback ( $ params [ 'component' ] , 'output_fragment_' . $ params [ 'callback' ] , array ( $ arguments ) ) ; $ jsfooter = $ PAGE -> requires -> get_end_code ( ) ; $ output = array ( 'html' => $ data , 'javascript' => $ jsfooter ) ; return $ output ; }
docstring: Get a HTML fragment for inserting into something. Initial use is for inserting mforms into
  a page using AJAX.
  This web service is designed to be called only via AJAX and not directly.
  Callbacks that are called by this web service are responsible for doing the appropriate security checks
  to access the information returned. This only does minimal validation on the context.
  
  @param string $component Name of the component.
  @param string $callback Function callback name.
  @param int $contextid Context ID this fragment is in.
  @param array $args optional arguments for the callback.
  @return array HTML and JavaScript fragments for insertion into stuff.
  @since Moodle 3.1
docstring_tokens: Get a HTML fragment for inserting into something . Initial use is for inserting mforms into a page using AJAX . This web service is designed to be called only via AJAX and not directly . Callbacks that are called by this web service are responsible for doing the appropriate security checks to access the information returned . This only does minimal validation on the context .