public function LeafletAttachment::attachTo in Leaflet 8
Same name and namespace in other branches
- 2.1.x modules/leaflet_views/src/Plugin/views/display/LeafletAttachment.php \Drupal\leaflet_views\Plugin\views\display\LeafletAttachment::attachTo()
- 2.0.x modules/leaflet_views/src/Plugin/views/display/LeafletAttachment.php \Drupal\leaflet_views\Plugin\views\display\LeafletAttachment::attachTo()
Allows displays to attach to other views.
Parameters
\Drupal\views\ViewExecutable $view: The views executable.
string $display_id: The display to attach to.
array $build: The parent view render array.
Overrides Attachment::attachTo
File
- modules/
leaflet_views/ src/ Plugin/ views/ display/ LeafletAttachment.php, line 56
Class
- LeafletAttachment
- Plugin attachment of additional leaflet features to leaflet map views.
Namespace
Drupal\leaflet_views\Plugin\views\displayCode
public function attachTo(ViewExecutable $view, $display_id, array &$build) {
$displays = $this
->getOption('displays');
if (empty($displays[$display_id])) {
return;
}
if (!$this
->access()) {
return;
}
$args = $this
->getOption('inherit_arguments') ? $this->view->args : [];
$view
->setArguments($args);
$view
->setDisplay($this->display['id']);
if ($this
->getOption('inherit_pager')) {
$view->display_handler->usesPager = $this->view->displayHandlers
->get($display_id)
->usesPager();
$view->display_handler
->setOption('pager', $this->view->displayHandlers
->get($display_id)
->getOption('pager'));
}
if ($render = $view
->render()) {
$this->view->attachment_before[] = $render + [
'#leaflet-attachment' => TRUE,
];
}
}