Problem/Motivation
When trying to access a view result from inside hook_cron, no result is returned.
Steps to reproduce
The following code runs fine within hook_form_alter but not within hook_cron:
$view = \Drupal\views\Views::getView('my_view');
$view->execute();
$view_result = $view->result;
if ($view->result) {
drupal_set_message("Yay!");
}
I tested it from /admin/config/system/cron page and ran the cron manually.