updated webform, webform_localization, profile2, term_merge, search_api_saved_pages, rules, redirect, overide_node_options

This commit is contained in:
2019-05-13 18:47:27 +02:00
parent 58cd990c8c
commit 9adc940a67
281 changed files with 28658 additions and 7138 deletions

View File

@@ -0,0 +1,50 @@
<?php
/**
* @file
* Definition of EntityReferenceTermMergeSynonymsBehavior class.
*/
/**
* Synonyms "term_merge" behavior for 'entityreference' field type.
*/
class EntityReferenceTermMergeSynonymsBehavior extends EntityReferenceSynonymsBehavior implements TermMergeSynonymsBehavior {
/**
* Add an entity as a synonym into another entity.
*
* Basically this method should be called when you want to add some entity as
* a synonym to another entity (for example when you merge one entity into
* another and besides merging want to add synonym of the merged entity into
* the trunk entity). You should update $trunk_entity in such a way that it
* holds $synonym_entity as a synonym (it all depends on how data is stored in
* your behavior implementation, but probably you will store entity label or
* its ID as you cannot literally store an entity inside of another entity).
* If entity of type $synonym_entity_type cannot be converted into a format
* expected by your behavior implementation, just do nothing.
*
* @param object $trunk_entity
* Entity into which another one should be added as synonym
* @param object $synonym_entity
* Fully loaded entity object which has to be added as synonym
* @param string $synonym_entity_type
* Entity type of $synonym_entity
*/
public function mergeTerm($trunk_entity, $synonym_entity, $synonym_entity_type) {
// Firstly validating that this entity reference is able to reference that
// type of entity.
$expected_synonym_entity_type = $this->field['settings']['target_type'];
$items = $this->entityItems($trunk_entity);
if ($expected_synonym_entity_type != $synonym_entity_type) {
return;
}
$synonym_entity_id = entity_extract_ids($synonym_entity_type, $synonym_entity);
$synonym_entity_id = $synonym_entity_id[0];
$items[] = array(
'target_id' => $synonym_entity_id,
);
$trunk_entity->{$this->field['field_name']}[LANGUAGE_NONE] = $this->uniqueItems($items, array('target_id'));
}
}

View File

@@ -0,0 +1,72 @@
<?php
/**
* @file
* Definition of TaxonomyTermReferenceTermMergeSynonymsBehavior class.
*/
/**
* Synonyms "term_merge" behavior for 'taxonomy term reference' field type.
*/
class TaxonomyTermReferenceTermMergeSynonymsBehavior extends TaxonomySynonymsBehavior implements TermMergeSynonymsBehavior {
/**
* Add an entity as a synonym into another entity.
*
* Basically this method should be called when you want to add some entity as
* a synonym to another entity (for example when you merge one entity into
* another and besides merging want to add synonym of the merged entity into
* the trunk entity). You should update $trunk_entity in such a way that it
* holds $synonym_entity as a synonym (it all depends on how data is stored in
* your behavior implementation, but probably you will store entity label or
* its ID as you cannot literally store an entity inside of another entity).
* If entity of type $synonym_entity_type cannot be converted into a format
* expected by your behavior implementation, just do nothing.
*
* @param object $trunk_entity
* Entity into which another one should be added as synonym
* @param object $synonym_entity
* Fully loaded entity object which has to be added as synonym
* @param string $synonym_entity_type
* Entity type of $synonym_entity
*/
public function mergeTerm($trunk_entity, $synonym_entity, $synonym_entity_type) {
// Taxonomy term reference supports only referencing of entity types
// 'taxonomy_term'.. duh.
if ($synonym_entity_type != 'taxonomy_term') {
return;
}
$items = $this->entityItems($trunk_entity);
// Checking that $field is configured to reference the vocabulary of
// $synonym_entity term.
$is_allowed = FALSE;
foreach ($this->field['settings']['allowed_values'] as $setting) {
if ($synonym_entity->vocabulary_machine_name == $setting['vocabulary']) {
if ($setting['parent'] == 0) {
// No need to check parent property as there is no limitation on it.
$is_allowed = TRUE;
break;
}
else {
foreach (taxonomy_get_parents_all($synonym_entity->tid) as $parent) {
if ($parent->tid == $setting['parent']) {
$is_allowed = TRUE;
break(2);
}
}
}
}
}
if (!$is_allowed) {
// Synonym term is from a vocabulary that is not expected by this field,
// or under unexpected parent.
return;
}
$items[] = array(
'tid' => $synonym_entity->tid,
);
$trunk_entity->{$this->field['field_name']}[LANGUAGE_NONE] = $this->uniqueItems($items, array('tid'));
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* @file
* Interface of synonyms behaviors for merging terms.
*/
/**
* Interface for merging one term into another.
*/
interface TermMergeSynonymsBehavior extends SynonymsBehavior {
/**
* Add an entity as a synonym into another entity.
*
* Basically this method should be called when you want to add some entity as
* a synonym to another entity (for example when you merge one entity into
* another and besides merging want to add synonym of the merged entity into
* the trunk entity). You should update $trunk_entity in such a way that it
* holds $synonym_entity as a synonym (it all depends on how data is stored in
* your behavior implementation, but probably you will store entity label or
* its ID as you cannot literally store an entity inside of another entity).
* If entity of type $synonym_entity_type cannot be converted into a format
* expected by your behavior implementation, just do nothing.
*
* @param object $trunk_entity
* Entity into which another one should be added as synonym
* @param object $synonym_entity
* Fully loaded entity object which has to be added as synonym
* @param string $synonym_entity_type
* Entity type of $synonym_entity
*/
public function mergeTerm($trunk_entity, $synonym_entity, $synonym_entity_type);
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* @file
* Definition of TextTermMergeSynonymsBehavior class.
*/
/**
* Synonyms "term_merge" behavior for 'text' field type.
*/
class TextTermMergeSynonymsBehavior extends TextSynonymsBehavior implements TermMergeSynonymsBehavior {
/**
* Add an entity as a synonym into another entity.
*
* Basically this method should be called when you want to add some entity as
* a synonym to another entity (for example when you merge one entity into
* another and besides merging want to add synonym of the merged entity into
* the trunk entity). You should update $trunk_entity in such a way that it
* holds $synonym_entity as a synonym (it all depends on how data is stored in
* your behavior implementation, but probably you will store entity label or
* its ID as you cannot literally store an entity inside of another entity).
* If entity of type $synonym_entity_type cannot be converted into a format
* expected by your behavior implementation, just do nothing.
*
* @param object $trunk_entity
* Entity into which another one should be added as synonym
* @param object $synonym_entity
* Fully loaded entity object which has to be added as synonym
* @param string $synonym_entity_type
* Entity type of $synonym_entity
*/
public function mergeTerm($trunk_entity, $synonym_entity, $synonym_entity_type) {
$synonym = entity_label($synonym_entity_type, $synonym_entity);
switch ($this->field['type']) {
case 'text':
break;
// We add synonyms for numbers only if $synonym is a number.
case 'number_integer':
case 'number_float':
case 'number_decimal':
if (!is_numeric($synonym)) {
return;
}
break;
}
$items = $this->entityItems($trunk_entity);
$items[] = array(
'value' => $synonym,
);
$trunk_entity->{$this->field['field_name']}[LANGUAGE_NONE] = $this->uniqueItems($items, array('value'));
}
}