Working on a module in which I'm trying to utilize this hook. According to the API docs, the arguments to this hook are:

\Drupal\views\ViewExecutable $view: The view object about to be processed.

string $output: A flat string with the rendered output of the view.

\Drupal\views\Plugin\views\cache\CachePluginBase $cache: The cache settings.

However, the second argument ($output), does not in fact, come in as a "flat string". It comes in as an array. Also, shouldn't that be "&$output", instead of "$output"?

So the API docs are wrong?

Assuming they are for a moment, anyone have any guidance on how best to obtain the rendered view output programatically?

Thanks in advance!

Comments

Jaypan’s picture

However, the second argument ($output), does not in fact, come in as a "flat string". It comes in as an array.

You should do some tests to confirm if this is always the case, or if it's specific to your installation (maybe you have something that is breaking normal functionality). I'd test on a vanilla installation. If you find that it is indeed an array, then you should file an issue on the matter (click the 'file an issue' link on the api page), and potentially submit a patch with a correction to the documentation.

Also, shouldn't that be "&$output", instead of "$output"?

It's listed as &$output in the function definition. It wouldn't be listed as such in the documentation.

incursus’s picture

Problem exists under vanilla as well. I've opened an issue: https://www.drupal.org/node/2790915

Cheers.