synonymsFindProcessCondition() method, * so you won't have to worry much about it * @param array $field * Field API field definition array of the field within which the search * for synonyms should be performed * @param array $instance * Field API instance definition array of the instance within which the * search for synonyms should be performed * * @return Traversable * Traversable result set of found synonyms and entity IDs to which those * belong. Each element in the result set should be an object and will have * the following structure: * - synonym: (string) Synonym that was found and which satisfies the * provided condition * - entity_id: (int) ID of the entity to which the found synonym belongs */ public function synonymsFind(QueryConditionInterface $condition, $field, $instance); } /** * Exception thrown by implementations of SynonymsSynonymsBehavior interface. */ class SynonymsSynonymsBehaviorException extends Exception {} /** * Starting point for implementing SynonymsSynonymsBehavior interface. */ abstract class AbstractSynonymsSynonymsBehavior implements SynonymsSynonymsBehavior { /** * Constant which denotes placeholder of a synonym column. * * @var string */ const COLUMN_PLACEHOLDER = '***COLUMN***'; /** * Process condition in 'synonymsFind' method. * * Process condition in 'synonymsFind' method replacing all references of * synonym column with the real name of that column. * * @param QueryConditionInterface $condition * Condition that should be processed * @param string $column * Real name of the synonym column */ protected function synonymsFindProcessCondition(QueryConditionInterface $condition, $column) { $condition_array = &$condition->conditions(); foreach ($condition_array as &$v) { if (is_array($v) && isset($v['field'])) { if ($v['field'] instanceof QueryConditionInterface) { // Recursively process this condition too. $this->synonymsFindProcessCondition($v['field'], $column); } else { $v['field'] = str_replace(self::COLUMN_PLACEHOLDER, $column, $v['field']); } } } } } /** * Interface of the autocomplete synonyms behavior. */ interface AutocompleteSynonymsBehavior extends SynonymsSynonymsBehavior { } /** * Interface of the synonyms friendly select behavior. */ interface SelectSynonymsBehavior extends SynonymsSynonymsBehavior { }