You are here

public function Report::getBlockAccess in Forena Reports 8

1 call to Report::getBlockAccess()
Report::setReport in src/Report.php
Sets the report.

File

src/Report.php, line 124
Basic report provider. Controls the rendering of the report.

Class

Report

Namespace

Drupal\forena

Code

public function getBlockAccess() {
  $repos = [];
  $security = [];
  $block_xml = $this->rpt_xml
    ->xpath('//*[@frx:block]');

  // Extract all the blocks and organize by provider
  foreach ($block_xml as $key => $block_node) {
    $attrs = $block_node
      ->attributes('urn:FrxReports');
    foreach ($attrs as $key => $value) {
      if ($key == 'block') {
        @(list($provider, $block) = explode('/', $value, 2));
        $repos[$provider][] = $block;
      }
    }
  }
  if ($repos) {
    foreach ($repos as $provider_key => $blocks) {
      $provider = $this
        ->dataManager()
        ->repository($provider_key);
      $access = array();
      foreach ($blocks as $block_name) {
        if ($provider && $block_name) {
          if (method_exists($provider, 'loadBlock')) {
            $block = $provider
              ->loadBlock($block_name);
            $obj = @$block['access'];
            if (array_search($obj, $access) === FALSE) {
              $access[] = $obj;
            }
          }
        }
      }
      $security[$provider_key] = $access;
    }
  }
  return $security;
}