You are here

public function OgVocab::save in OG Vocabulary 7

Overrides Entity::save().

Overrides Entity::save

File

includes/og_vocab.og_vocab.inc, line 198
A class used for messages.

Class

OgVocab
@file A class used for messages.

Code

public function save() {

  // Add the OG-vocabulary field in the group-content, in case it
  // doesn't already exist.
  if (empty($this->field_name)) {
    $og_vocab_fields = og_vocab_get_og_vocab_fields($this->entity_type, $this->bundle);
    $this->field_name = !empty($og_vocab_fields) ? key($og_vocab_fields) : OG_VOCAB_FIELD;
  }
  if (!field_info_instance($this->entity_type, $this->field_name, $this->bundle)) {

    // Add the new field.
    $og_info = og_fields_info(OG_VOCAB_FIELD);
    og_create_field($this->field_name, $this->entity_type, $this->bundle, $og_info);
  }
  parent::save();
}