/**
  * Overrides RestfulEntityBase::getFormSchemaAllowedValues().
  *
  * For OG vocab fields we get only the ones of the group passed context.
  */
 protected function getFormSchemaAllowedValues($field)
 {
     if ($field['field_name'] == 'c4m_related_document') {
         // We don't need allowed values for related documents, because we are
         // getting them from library.
         return array();
     }
     if ($field['field_name'] != OG_VOCAB_FIELD) {
         return parent::getFormSchemaAllowedValues($field);
     }
     $request = $this->getRequest();
     if (empty($request['group']) || !intval($request['group'])) {
         throw new \RestfulBadRequestException('The "group" parameter is missing for the request, thus the vocabulary cannot be set for the group.');
     }
     $node = node_load($request['group']);
     if (!$node) {
         throw new \RestfulBadRequestException('The "group" parameter is not a node.');
     } elseif ($node->type != 'group') {
         throw new \RestfulBadRequestException('The "group" parameter is not a of type "group".');
     }
     $return = array();
     foreach (array('tags', 'categories') as $vocab_name) {
         $allowed_values = array();
         $og_vocab = c4m_restful_get_og_vocab_by_name('node', $node->nid, $vocab_name);
         $vocab = taxonomy_vocabulary_load($og_vocab[0]->vid);
         $allowed_values[] = array('vocabulary' => $vocab->machine_name, 'parent' => 0);
         $field['settings']['allowed_values'] = $allowed_values;
         $return[$vocab_name] = taxonomy_allowed_values($field);
     }
     return $return;
 }