original_string: public function map_tool_to_consumer() {
          global $DB;
  
          if (empty($this->consumer)) {
              throw new moodle_exception('invalidtoolconsumer', 'enrol_lti');
          }
  
          // Map the consumer to the tool.
          $mappingparams = [
              'toolid' => $this->tool->id,
              'consumerid' => $this->consumer->getRecordId()
          ];
          $mappingexists = $DB->record_exists('enrol_lti_tool_consumer_map', $mappingparams);
          if (!$mappingexists) {
              $DB->insert_record('enrol_lti_tool_consumer_map', (object) $mappingparams);
          }
      }
code: public function map_tool_to_consumer() {
          global $DB;
  
          if (empty($this->consumer)) {
              throw new moodle_exception('invalidtoolconsumer', 'enrol_lti');
          }
  
          // Map the consumer to the tool.
          $mappingparams = [
              'toolid' => $this->tool->id,
              'consumerid' => $this->consumer->getRecordId()
          ];
          $mappingexists = $DB->record_exists('enrol_lti_tool_consumer_map', $mappingparams);
          if (!$mappingexists) {
              $DB->insert_record('enrol_lti_tool_consumer_map', (object) $mappingparams);
          }
      }
code_tokens: public function map_tool_to_consumer ( ) { global $ DB ; if ( empty ( $ this -> consumer ) ) { throw new moodle_exception ( 'invalidtoolconsumer' , 'enrol_lti' ) ; } // Map the consumer to the tool. $ mappingparams = [ 'toolid' => $ this -> tool -> id , 'consumerid' => $ this -> consumer -> getRecordId ( ) ] ; $ mappingexists = $ DB -> record_exists ( 'enrol_lti_tool_consumer_map' , $ mappingparams ) ; if ( ! $ mappingexists ) { $ DB -> insert_record ( 'enrol_lti_tool_consumer_map' , ( object ) $ mappingparams ) ; } }
docstring: Performs mapping of the tool consumer to a published tool.
  
  @throws moodle_exception
docstring_tokens: Performs mapping of the tool consumer to a published tool .