function gc_get_destination_node in GatherContent 8.3
Get Node object based on type of update.
Parameters
int $gc_id: ID of item in GatherContent.
string $node_update_method: Name of the node update method.
int $node_type_id: ID of the node type.
string $langcode: Language of translation if applicable.
Return value
\Drupal\node\NodeInterface Return loaded node.
1 call to gc_get_destination_node()
- _gc_fetcher in ./
gathercontent.module - Function for fetching, creating and updating content from GatherContent.
File
- ./
gathercontent.module, line 241 - Main module file for GatherContent module.
Code
function gc_get_destination_node($gc_id, $node_update_method, $node_type_id, $langcode) {
switch ($node_update_method) {
case 'update_if_not_changed':
$result = \Drupal::entityQuery('node')
->condition('gc_id', $gc_id)
->sort('created', 'DESC')
->range(0, 1)
->execute();
if ($result) {
$node = Node::load(reset($result));
$query_result = \Drupal::entityQuery('gathercontent_operation_item')
->condition('gc_id', $gc_id)
->sort('changed', 'DESC')
->range(0, 1)
->execute();
$operation = OperationItem::load(reset($query_result));
if ($node
->getChangedTime() === $operation
->getChangedTime()) {
return $node;
}
}
break;
case 'always_update':
$result = \Drupal::entityQuery('node')
->condition('gc_id', $gc_id)
->sort('created', 'DESC')
->range(0, 1)
->execute();
if ($result) {
return Node::load(reset($result));
}
break;
}
return Node::create([
'type' => $node_type_id,
'langcode' => $langcode,
]);
}