original_string: public static function form_policydoc_update_new(stdClass $form) {
          global $DB;
  
          if (empty($form->policyid)) {
              throw new coding_exception('Invalid policy document ID');
          }
  
          $form = clone($form);
  
          $form->id = $DB->insert_record('tool_policy_versions', (new policy_version(0, (object) [
              'timecreated' => time(),
              'policyid' => $form->policyid,
          ]))->to_record());
  
          return static::form_policydoc_update_overwrite($form);
      }
code: public static function form_policydoc_update_new(stdClass $form) {
          global $DB;
  
          if (empty($form->policyid)) {
              throw new coding_exception('Invalid policy document ID');
          }
  
          $form = clone($form);
  
          $form->id = $DB->insert_record('tool_policy_versions', (new policy_version(0, (object) [
              'timecreated' => time(),
              'policyid' => $form->policyid,
          ]))->to_record());
  
          return static::form_policydoc_update_overwrite($form);
      }
code_tokens: public static function form_policydoc_update_new ( stdClass $ form ) { global $ DB ; if ( empty ( $ form -> policyid ) ) { throw new coding_exception ( 'Invalid policy document ID' ) ; } $ form = clone ( $ form ) ; $ form -> id = $ DB -> insert_record ( 'tool_policy_versions' , ( new policy_version ( 0 , ( object ) [ 'timecreated' => time ( ) , 'policyid' => $ form -> policyid , ] ) ) -> to_record ( ) ) ; return static :: form_policydoc_update_overwrite ( $ form ) ; }
docstring: Save the data from the policydoc form as a new policy document version.
  
  @param stdClass $form data submitted from the {@link \tool_policy\form\policydoc} form.
  @return \tool_policy\policy_version persistent
docstring_tokens: Save the data from the policydoc form as a new policy document version .