public function WorkflowState::count in Workflow 7.2
Returns the number of entities with this state.
@todo: add $options to select on entity type, etc.
Return value
int Counted number.
File
- includes/
Entity/ WorkflowState.php, line 503 - Contains workflow\includes\Entity\WorkflowState. Contains workflow\includes\Entity\WorkflowStateController.
Class
- WorkflowState
- Class WorkflowState
Code
public function count() {
$sid = $this->sid;
// Get the numbers for Workflow Node.
$result = db_select('workflow_node', 'wn')
->fields('wn')
->condition('sid', $sid, '=')
->execute();
$count = count($result
->fetchAll());
// @see #2285983 for using SQLite.
// Get the numbers for Workflow Field.
$fields = _workflow_info_fields();
foreach ($fields as $field_name => $field_map) {
if ($field_map['type'] == 'workflow') {
$query = new EntityFieldQuery();
$query
->fieldCondition($field_name, 'value', $sid, '=')
->count();
// We only need the count.
$result = $query
->execute();
$count += $result;
}
}
return $count;
}