Untitled
unknown
plain_text
2 years ago
855 B
10
Indexable
use Drupal\Core\Database\Database;
/**
* Fetch nodes of a specific type with field_request_workflow_state_value field using JOIN.
*/
function fetchNodesWithWorkflowStateFieldByType($nodeType) {
$database = Database::getConnection();
$query = $database->select('node_field_data', 'nfd')
->fields('nfd', ['nid', 'title'])
->condition('nfd.type', $nodeType) // Replace $nodeType with your desired node type.
->join('node__field_request_workflow_state', 'wf_state', 'nfd.nid = wf_state.entity_id')
->fields('wf_state', ['field_request_workflow_state_value']);
$result = $query->execute();
$nodes = [];
foreach ($result as $row) {
$nodes[] = [
'nid' => $row->nid,
'title' => $row->title,
'workflow_state' => $row->field_request_workflow_state_value,
];
}
return $nodes;
}
Editor is loading...