function maestro_spv_content_value_fetch in Maestro 8.2
Same name and namespace in other branches
- 3.x maestro.module \maestro_spv_content_value_fetch()
Set Process Variable built-in helper function to use the maestro_entity_identifiers entity to load the first node of type $content_type and pick off the $field value and set that as the process variable's value.
This function requires that the maestro_entity_identifiers entity actually be set with an appropriate entity ID inside of it for a node of type $content_type passed into this function.
Parameters
string $uniqueIdentifier: The unique identifier set by the task for the entity identifiers entity.
string $field: The field name of the node in question.
int $queueID: The queue ID of the task calling this function.
int $processID: The process ID of the tatsk calling this function.
Return value
string The resulting value that the set process variable custom function requires
File
- ./
maestro.module, line 97 - Provides glue logic, hook implementation and core set process variable functions.
Code
function maestro_spv_content_value_fetch($uniqueIdentifier, $field, $queueID, $processID) {
$returnValue = '';
$entityID = intval(MaestroEngine::getEntityIdentiferByUniqueID($processID, $uniqueIdentifier));
$node = Node::load($entityID);
if ($node) {
// We have a match. let's do our work now on this content type.
$field_ref = $node->{$field};
// TODO: getValue also get taxonomy? What about nested entity refs?
$returnValue = $field_ref
->getValue();
if (is_array($returnValue)) {
// Bail out once we know we have a value.
$returnValue = current($returnValue)['value'];
}
}
return $returnValue;
}