You are here

class AbstractPropertySynonymsBehavior in Synonyms 7

Definition of AbstractPropertySynonymsBehavior class.

Hierarchy

Expanded class hierarchy of AbstractPropertySynonymsBehavior

File

synonyms_provider_property/includes/AbstractPropertySynonymsBehavior.class.inc, line 11
Abstract class for enabling entity properties to be source of synonyms.

View source
class AbstractPropertySynonymsBehavior extends AbstractSynonymsBehavior implements AutocompleteSynonymsBehavior, SelectSynonymsBehavior {

  /**
   * Name of the property on which this provider was initialized.
   *
   * @var string
   */
  protected $property;

  /**
   * Entity info of the entity type on which this provider was initialized.
   *
   * @var array
   */
  protected $entity_info;
  public function __construct($behavior_implementation) {
    parent::__construct($behavior_implementation);
    $this->property = synonyms_provider_property_name($this->behavior_implementation['provider']);
    $this->entity_info = entity_get_info($this->behavior_implementation['entity_type']);
  }
  public function extractSynonyms($entity, $langcode = NULL) {
    $synonyms = array();
    if (isset($entity->{$this->property}) && $entity->{$this->property}) {
      $synonyms[] = $entity->{$this->property};
    }
    return $synonyms;
  }
  public function mergeEntityAsSynonym($trunk_entity, $synonym_entity, $synonym_entity_type) {

    // TODO: what to do ???
  }
  public function synonymsFind(QueryConditionInterface $condition) {
    $query = db_select($this->entity_info['base table'], 'base');
    $query
      ->addField('base', $this->entity_info['entity keys']['id'], 'entity_id');
    $query
      ->addField('base', $this->property, 'synonym');
    $this
      ->synonymsFindProcessCondition($condition, 'base.' . $this->property, 'base.' . $this->entity_info['entity keys']['id']);
    $query
      ->condition($condition);
    return $query
      ->execute();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractPropertySynonymsBehavior::$entity_info protected property Entity info of the entity type on which this provider was initialized.
AbstractPropertySynonymsBehavior::$property protected property Name of the property on which this provider was initialized.
AbstractPropertySynonymsBehavior::extractSynonyms public function Extract synonyms from an entity within a specific behavior implementation. Overrides SynonymsBehavior::extractSynonyms
AbstractPropertySynonymsBehavior::mergeEntityAsSynonym public function Add an entity as a synonym into another entity. Overrides SynonymsBehavior::mergeEntityAsSynonym
AbstractPropertySynonymsBehavior::synonymsFind public function Look up entities by their synonyms within a behavior implementation. Overrides SynonymsBehavior::synonymsFind
AbstractPropertySynonymsBehavior::__construct public function Overrides AbstractSynonymsBehavior::__construct
AbstractSynonymsBehavior::$behavior_implementation protected property Behavior implementation on which this class was initialized.
AbstractSynonymsBehavior::COLUMN_ENTITY_ID_PLACEHOLDER constant Constant which denotes placeholder of an entity ID column.
AbstractSynonymsBehavior::COLUMN_SYNONYM_PLACEHOLDER constant Constant which denotes placeholder of a synonym column.
AbstractSynonymsBehavior::featuresExportPipe public function Collect info on features pipe during invocation of hook_features_export(). Overrides SynonymsBehavior::featuresExportPipe 2
AbstractSynonymsBehavior::synonymsFindProcessCondition protected function Process condition in 'synonymsFind' method.