1

I'm writing a custom display plugin for views in Drupal 8, and I'm having a hard time figuring out how the view row plugin is decided.

I'm basing my plugin on the views Serializer style in the rest module. The serializer style is calling out to a row style, either DataEntityRow or DataFieldRow:

public function render() {
  $rows = array();
  // If the Data Entity row plugin is used, this will be an array of entities
  // which will pass through Serializer to one of the registered Normalizers,
  // which will transform it to arrays/scalars. If the Data field row plugin
  // is used, $rows will not contain objects and will pass directly to the
  // Encoder.
  foreach ($this->view->result as $row) {
    $rows[] = $this->view->rowPlugin->render($row);
  }

Somewhere along the line, the rowPlugin is being set to one of the aforementioned styles but I can't figure out whether it's set somewhere and I'm missing it, or if it's auto detected in some way. As far as I can tell, the row plugin is never directly instantiated anywhere.

If it is some sort of automatic detection, is there any way for me to hint or force the use in my own code? I could happily use the DataFieldRow plugin in my own class, but I don't know how.

2

Row is just a plugin. You can write your own. See the core/modules/views/src/Plugin/views/row directory.

1

The row plugin is initialized in \Drupal\views\Plugin\views\style\StylePluginBase::init()

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.