original_string: public function add_related_tags($tagnames) {
          $context = context_system::instance();
          $tagobjects = static::create_if_missing($this->tagcollid, $tagnames);
  
          $currenttags = static::get_item_tags('core', 'tag', $this->id);
  
          foreach ($tagobjects as $name => $tag) {
              foreach ($currenttags as $currenttag) {
                  if ($currenttag->name === $name) {
                      continue 2;
                  }
              }
              $this->add_instance('core', 'tag', $tag->id, $context, 0);
              $tag->add_instance('core', 'tag', $this->id, $context, 0);
              $currenttags[] = $tag;
          }
      }
code: public function add_related_tags($tagnames) {
          $context = context_system::instance();
          $tagobjects = static::create_if_missing($this->tagcollid, $tagnames);
  
          $currenttags = static::get_item_tags('core', 'tag', $this->id);
  
          foreach ($tagobjects as $name => $tag) {
              foreach ($currenttags as $currenttag) {
                  if ($currenttag->name === $name) {
                      continue 2;
                  }
              }
              $this->add_instance('core', 'tag', $tag->id, $context, 0);
              $tag->add_instance('core', 'tag', $this->id, $context, 0);
              $currenttags[] = $tag;
          }
      }
code_tokens: public function add_related_tags ( $ tagnames ) { $ context = context_system :: instance ( ) ; $ tagobjects = static :: create_if_missing ( $ this -> tagcollid , $ tagnames ) ; $ currenttags = static :: get_item_tags ( 'core' , 'tag' , $ this -> id ) ; foreach ( $ tagobjects as $ name => $ tag ) { foreach ( $ currenttags as $ currenttag ) { if ( $ currenttag -> name === $ name ) { continue 2 ; } } $ this -> add_instance ( 'core' , 'tag' , $ tag -> id , $ context , 0 ) ; $ tag -> add_instance ( 'core' , 'tag' , $ this -> id , $ context , 0 ) ; $ currenttags [ ] = $ tag ; } }
docstring: Adds to the list of related tags without removing existing
  
  Tag relations are recorded by two instances linking two tags to each other.
  For tag relations ordering is not used and may be random.
  
  @param array $tagnames
docstring_tokens: Adds to the list of related tags without removing existing