You are here

private function DataPolicyInformBlock::getInformBlock in Data Policy 8

Get entity of inform_block for current page.

Return value

\Drupal\data_policy\InformBlockInterface|null If current page has data for information block then will be returned entity else NULL.

3 calls to DataPolicyInformBlock::getInformBlock()
DataPolicyInformBlock::blockAccess in src/Plugin/Block/DataPolicyInformBlock.php
Indicates whether the block should be shown.
DataPolicyInformBlock::build in src/Plugin/Block/DataPolicyInformBlock.php
Builds and returns the renderable array for this block plugin.
DataPolicyInformBlock::getConfiguration in src/Plugin/Block/DataPolicyInformBlock.php

File

src/Plugin/Block/DataPolicyInformBlock.php, line 187

Class

DataPolicyInformBlock
Provides a 'Data Policy' block.

Namespace

Drupal\data_policy\Plugin\Block

Code

private function getInformBlock() {
  $inform_blocks = $this->entityTypeManager
    ->getStorage('informblock')
    ->loadByProperties([
    'status' => TRUE,
  ]);
  foreach ($inform_blocks as $inform_block) {
    $link = $inform_block->page;
    $request = $this->requestStack
      ->getCurrentRequest();
    $path = $this->currentPath
      ->getPath($request);
    $path = $path === '/' ? $path : rtrim($path, '/');
    $path_alias = Unicode::strtolower($this->aliasManager
      ->getAliasByPath($path));
    if ($this->pathMatcher
      ->matchPath($path_alias, $link) || $path != $path_alias && $this->pathMatcher
      ->matchPath($path, $link)) {
      return $inform_block;
    }
  }
  return NULL;
}