I have created a view field plugin to display an "internal status" for each node in a view.
Those status are not stored in a table (and should not) because each status may vary depending the current date (and some other fluctuating data).
The possible status outputted by this virtual field (not sure it is the correct terminology) are 1,2 or 3 (integer)
Here is the simplified code
1-Declare the virtual field in hook_views_data_alter()
function mymodule_views_data_alter(array &$data) {
$data['node']['internal_status'] = [
'title' => t('Internal Status'),
'field' => [
'title' => t('Internal Status'),
'help' => t("Display internal status"),
'id' => 'internal_status',
],
];
}
2- Create the view plugin
/**
* Field handler to display internal status.
*
* @ViewsField("internal_status")
*/
class NodeInternalStatus extends FieldPluginBase {
public function query() {}
public function render(ResultRow $values) {
$node = $values->_entity;
$value= return_1_2_or_3_depending_on_dyn_data_like_the_current_date($node);
switch ($value){
case 1:
return t('This is 1');
case 2:
return t('This is 2');
case 3:
return t('This is 3');
}
//will never go here if everything is ok
return t('n/a');
}
}
My Question: I would like to create a filter plugin to filter nodes according their internal status [by using return_1_2_or_3_depending_on_dyn_data_like_the_current_date($node)
]
I have tried to extend the inOperator
class but as the real column of the "internal status" field doesn't exists in the DB, I keep getting the following error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'node_field_data.internal_status' in 'where clause':