You are here

class EntityReference_SelectionHandler_Translation_Generic_node in Translated Entity Reference 7

Override for the Node type.

This only exists to workaround core bugs.

Hierarchy

Expanded class hierarchy of EntityReference_SelectionHandler_Translation_Generic_node

File

plugins/selection/EntityReference_SelectionHandler_Translation_Generic.class.php, line 38

View source
class EntityReference_SelectionHandler_Translation_Generic_node extends EntityReference_SelectionHandler_Generic_node {

  /**
   * Overrides EntityReference_SelectionHandler_Generic_node::entityFieldQueryAlter().
   * Adds language filtering logic.
   */
  public function entityFieldQueryAlter(SelectQueryInterface $query) {
    parent::entityFieldQueryAlter($query);
    $base_table = $this
      ->ensureBaseTable($query);
    $entity_info = entity_get_info($this->field['settings']['target_type']);
    if ($this->field['settings']['handler_settings']['filter']['language'] == 1 && $entity_info['translation']['locale'] == TRUE) {
      $node_language = i18n_node_i18n_context_language();
      if (isset($node_language->language) && !is_null($node_language->language)) {
        $query
          ->condition("{$base_table}.language", $node_language->language);
      }
    }
    else {
      global $language;
      $query
        ->condition("{$base_table}.language", $language->language);
    }
  }

  /**
   * Overrides EntityReference_SelectionHandler_Generic::settingsForm().
   * 0 = Makes the filtering configurable. Either show all nodes (filtered on
   * interface language) or show only those nodes with the same language as the
   * referencing (parent) node.
   */
  public static function settingsForm($field, $instance) {
    $form = parent::settingsForm($field, $instance);
    $form['filter']['language'] = array(
      '#type' => 'select',
      '#title' => t('Language handling'),
      '#options' => array(
        0 => t('Select all nodes matching with the interface language'),
        1 => t('Select only nodes matching the parent\'s language'),
      ),
      '#default_value' => isset($field['settings']['handler_settings']['filter']['language']) ? $field['settings']['handler_settings']['filter']['language'] : 0,
    );
    return $form;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityReference_SelectionHandler_Generic::buildEntityFieldQuery protected function Build an EntityFieldQuery to get referencable entities. 1
EntityReference_SelectionHandler_Generic::countReferencableEntities public function Implements EntityReferenceHandler::countReferencableEntities(). Overrides EntityReference_SelectionHandler::countReferencableEntities
EntityReference_SelectionHandler_Generic::ensureBaseTable public function Ensure a base table exists for the query.
EntityReference_SelectionHandler_Generic::getInstance public static function Implements EntityReferenceHandler::getInstance(). Overrides EntityReference_SelectionHandler::getInstance
EntityReference_SelectionHandler_Generic::getLabel public function Implements EntityReferenceHandler::getLabel(). Overrides EntityReference_SelectionHandler::getLabel 1
EntityReference_SelectionHandler_Generic::getReferencableEntities public function Implements EntityReferenceHandler::getReferencableEntities(). Overrides EntityReference_SelectionHandler::getReferencableEntities 1
EntityReference_SelectionHandler_Generic::reAlterQuery protected function Helper method: pass a query to the alteration system again.
EntityReference_SelectionHandler_Generic::validateAutocompleteInput public function Implements EntityReferenceHandler::validateAutocompleteInput(). Overrides EntityReference_SelectionHandler::validateAutocompleteInput
EntityReference_SelectionHandler_Generic::validateReferencableEntities public function Implements EntityReferenceHandler::validateReferencableEntities(). Overrides EntityReference_SelectionHandler::validateReferencableEntities
EntityReference_SelectionHandler_Generic::__construct protected function
EntityReference_SelectionHandler_Translation_Generic_node::entityFieldQueryAlter public function Overrides EntityReference_SelectionHandler_Generic_node::entityFieldQueryAlter(). Adds language filtering logic. Overrides EntityReference_SelectionHandler_Generic_node::entityFieldQueryAlter
EntityReference_SelectionHandler_Translation_Generic_node::settingsForm public static function Overrides EntityReference_SelectionHandler_Generic::settingsForm(). 0 = Makes the filtering configurable. Either show all nodes (filtered on interface language) or show only those nodes with the same language as the referencing (parent) node. Overrides EntityReference_SelectionHandler_Generic::settingsForm