You are here

public function ViewsBlock::isRenderedInCurrentRequest in Search API 8

Returns true if the display is being rendered in the current request.

Return value

bool True when the display is rendered in the current request.

Overrides ViewsDisplayBase::isRenderedInCurrentRequest

File

src/Plugin/search_api/display/ViewsBlock.php, line 19

Class

ViewsBlock
Represents a Views block display.

Namespace

Drupal\search_api\Plugin\search_api\display

Code

public function isRenderedInCurrentRequest() {

  // There can be more than one block rendering the display. If any block is
  // rendered, we return TRUE.
  $plugin_id = 'views_block:' . $this->pluginDefinition['view_id'] . '-' . $this->pluginDefinition['view_display'];
  $blocks = $this
    ->getEntityTypeManager()
    ->getStorage('block')
    ->loadByProperties([
    'plugin' => $plugin_id,
  ]);
  foreach ($blocks as $block) {
    if ($block
      ->access('view')) {
      return TRUE;
    }
  }
  return FALSE;
}