function gc_gc_process_metatag_pane in GatherContent 8.3
Same name and namespace in other branches
- 8 gathercontent.module \gc_gc_process_metatag_pane()
Processing function for metatag panes.
Parameters
\Drupal\node\NodeInterface $entity: Object of node.
string $local_field_name: Name of local Drupal field.
object $field: Object of GatherContent field.
string $content_type: Name of Content type, we are mapping to.
bool $is_translatable: Indicator if node is translatable.
string $language: Language of translation if applicable.
Throws
\Exception If content save fails, exceptions is thrown.
1 call to gc_gc_process_metatag_pane()
- _gc_fetcher in ./
gathercontent.module - Function for fetching, creating and updating content from GatherContent.
File
- ./
gathercontent.module, line 307 - Main module file for GatherContent module.
Code
function gc_gc_process_metatag_pane(NodeInterface &$entity, $local_field_name, $field, $content_type, $is_translatable, $language) {
if (\Drupal::moduleHandler()
->moduleExists('metatag') && check_metatag($content_type)) {
$metatag_fields = get_metatag_fields($content_type);
foreach ($metatag_fields as $metatag_field) {
if ($is_translatable) {
$current_value = unserialize($entity
->getTranslation($language)->{$metatag_field}->value);
$current_value[$local_field_name] = $field->value;
$entity
->getTranslation($language)->{$metatag_field}->value = serialize($current_value);
}
else {
$current_value = unserialize($entity->{$metatag_field}->value);
$current_value[$local_field_name] = $field->value;
$entity->{$metatag_field}->value = serialize($current_value);
}
}
}
else {
throw new Exception("Metatag module not enabled or entity doesn't support\n metatags while trying to map values with metatag content.");
}
}