123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <?php
- interface SynonymsBehavior {
-
- public function extractSynonyms($entity, $langcode = NULL);
-
- public function mergeEntityAsSynonym($trunk_entity, $synonym_entity, $synonym_entity_type);
-
- public function synonymsFind(QueryConditionInterface $condition);
-
- public function featuresExportPipe();
- }
- class SynonymsBehaviorException extends Exception {}
- abstract class AbstractSynonymsBehavior implements SynonymsBehavior {
-
- const COLUMN_SYNONYM_PLACEHOLDER = '***COLUMN***';
-
- const COLUMN_ENTITY_ID_PLACEHOLDER = '***ENTITY_ID***';
-
- protected $behavior_implementation;
- public function __construct($behavior_implementation) {
- $this->behavior_implementation = $behavior_implementation;
- }
- public function featuresExportPipe() {
- return array();
- }
-
- protected function synonymsFindProcessCondition(QueryConditionInterface $condition, $column_synonym, $column_entity_id) {
- $condition_array = &$condition->conditions();
- foreach ($condition_array as &$v) {
- if (is_array($v) && isset($v['field'])) {
- if ($v['field'] instanceof QueryConditionInterface) {
-
- $this->synonymsFindProcessCondition($v['field'], $column_synonym, $column_entity_id);
- }
- else {
- $replace = array(
- self::COLUMN_SYNONYM_PLACEHOLDER => $column_synonym,
- self::COLUMN_ENTITY_ID_PLACEHOLDER => $column_entity_id,
- );
- $v['field'] = str_replace(array_keys($replace), array_values($replace), $v['field']);
- }
- }
- }
- }
- }
- interface AutocompleteSynonymsBehavior extends SynonymsBehavior {
- }
- interface SelectSynonymsBehavior extends SynonymsBehavior {
- }
|