0

Inside a hook_views_pre_render(ViewExecutable $view): When I try to get and use field values from $view->result, I could no more use the $view->result just after and the execution is interrupted with no explicit errors displayed. For example:

function custom_divers_views_pre_render(ViewExecutable $view) {
  if ($view->id() == 'localisation_front' && $view->current_display == 'block_1') {
        
    // This code is well executed.
    \Drupal::logger('custom_divers')->notice(print_r($view->result, TRUE));

    foreach ($view->result as $result) {
      // Getting this value works.
      $type_value =  $result->_entity->type->getValue()[0]['target_id'];
      \Drupal::logger('custom_divers')->notice("type_value: ".$type_value);
    }

    // But this code is no more executed.
    \Drupal::logger('custom_divers')->notice(print_r($view->result, TRUE));     
  }
}
6
  • Is this the full code?
    – berliner
    Dec 10 '21 at 12:47
  • no it is an extract
    – ostry.sn
    Dec 10 '21 at 19:20
  • 2
    Please post the full code. What you have posted shouldn't create the problem that you describe, so the issue must be elsewhere.
    – berliner
    Dec 10 '21 at 19:23
  • 1
    Anything in the server/php logs?
    – berliner
    Dec 14 '21 at 11:15
  • 2
    Ok I found in apache logs "Allowed memory size of 671088640 bytes exhausted" for the second \Drupal::logger call
    – ostry.sn
    Dec 14 '21 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.