You are here

class OgVocabBehaviorHandler in OG Vocabulary 7

OG vocab behavior handler.

Hierarchy

Expanded class hierarchy of OgVocabBehaviorHandler

1 string reference to 'OgVocabBehaviorHandler'
og_vocab.inc in plugins/behavior/og_vocab.inc

File

plugins/behavior/OgVocabBehaviorHandler.class.php, line 6

View source
class OgVocabBehaviorHandler extends EntityReference_BehaviorHandler_Abstract {
  public function access($field, $instance) {
    return $field['settings']['target_type'] == 'taxonomy_term' && $instance['widget']['type'] == 'og_vocab_complex';
  }
  public function settingsForm($field, $instance) {
    $form = parent::settingsForm($field, $instance);
    $settings = !empty($field['settings']['handler_settings']['behaviors']['og_vocab']) ? $field['settings']['handler_settings']['behaviors']['og_vocab'] : array();
    $settings += array(
      'use_context' => 'yes',
    );
    $form['use_context'] = array(
      '#type' => 'select',
      '#title' => t('Use context'),
      '#required' => TRUE,
      '#options' => array(
        'force' => t('Hide widget if no context found'),
        'yes' => t('Use if possible'),
        'no' => t('Do not use'),
      ),
      '#description' => t('Should the OG vocabularies appear according to OG context. Depends on OG-context module.'),
      '#default_value' => $settings['use_context'],
    );
    return $form;
  }
  public function is_empty_alter(&$empty, $item, $field) {
    if (!empty($item['target_id']) && $item['target_id'] == 'autocreate') {
      $empty = FALSE;
    }
  }
  public function presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
    foreach ($items as $delta => $item) {
      if ($item['target_id'] == 'autocreate') {
        $term = (object) $item;
        unset($term->tid);
        taxonomy_term_save($term);
        $items[$delta]['target_id'] = $term->tid;
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityReference_BehaviorHandler_Abstract::$behavior protected property The name of the behavior plugin.
EntityReference_BehaviorHandler_Abstract::$plugin protected property The plugin definition.
EntityReference_BehaviorHandler_Abstract::delete public function Act before deleting an entity with an entity reference field. Overrides EntityReference_BehaviorHandler::delete 2
EntityReference_BehaviorHandler_Abstract::entityPostDelete public function Act after deleting an entity. Overrides EntityReference_BehaviorHandler::entityPostDelete
EntityReference_BehaviorHandler_Abstract::entityPostInsert public function Act after inserting an entity. Overrides EntityReference_BehaviorHandler::entityPostInsert 1
EntityReference_BehaviorHandler_Abstract::entityPostUpdate public function Act after updating an entity. Overrides EntityReference_BehaviorHandler::entityPostUpdate 1
EntityReference_BehaviorHandler_Abstract::insert public function Act before inserting an entity reference field. Overrides EntityReference_BehaviorHandler::insert 2
EntityReference_BehaviorHandler_Abstract::load public function Act on loading entity reference fields of entities. Overrides EntityReference_BehaviorHandler::load 2
EntityReference_BehaviorHandler_Abstract::postDelete public function Act after deleting an entity with an entity reference field. Overrides EntityReference_BehaviorHandler::postDelete
EntityReference_BehaviorHandler_Abstract::postInsert public function Act after inserting an entity reference field. Overrides EntityReference_BehaviorHandler::postInsert
EntityReference_BehaviorHandler_Abstract::postUpdate public function Act after updating an entity reference field. Overrides EntityReference_BehaviorHandler::postUpdate
EntityReference_BehaviorHandler_Abstract::property_info_alter public function Alter the properties information of a field instance. Overrides EntityReference_BehaviorHandler::property_info_alter
EntityReference_BehaviorHandler_Abstract::schema_alter public function Alter the field schema. Overrides EntityReference_BehaviorHandler::schema_alter
EntityReference_BehaviorHandler_Abstract::update public function Act before updating an entity reference field. Overrides EntityReference_BehaviorHandler::update 2
EntityReference_BehaviorHandler_Abstract::validate public function Act on validating an entity reference field. Overrides EntityReference_BehaviorHandler::validate
EntityReference_BehaviorHandler_Abstract::views_data_alter public function Alter the views data of a field. Overrides EntityReference_BehaviorHandler::views_data_alter 1
EntityReference_BehaviorHandler_Abstract::__construct public function Constructor for the behavior. Overrides EntityReference_BehaviorHandler::__construct
OgVocabBehaviorHandler::access public function Determine if handler should appear. Overrides EntityReference_BehaviorHandler_Abstract::access
OgVocabBehaviorHandler::is_empty_alter public function Alter the empty status of a field item. Overrides EntityReference_BehaviorHandler_Abstract::is_empty_alter
OgVocabBehaviorHandler::presave public function Act on presaving an entity reference field. Overrides EntityReference_BehaviorHandler_Abstract::presave
OgVocabBehaviorHandler::settingsForm public function Generate a settings form for this handler. Overrides EntityReference_BehaviorHandler_Abstract::settingsForm