You are here

public function BlockEditor::load in Forena Reports 8

Same name and namespace in other branches
  1. 7.5 src/Editor/BlockEditor.php \Drupal\forena\Editor\BlockEditor::load()

Block loader method.

Parameters

string $block_name: Name of block to load.

Return value

array block definition

1 call to BlockEditor::load()
BlockEditor::__construct in src/Editor/BlockEditor.php

File

src/Editor/BlockEditor.php, line 44

Class

BlockEditor

Namespace

Drupal\forena\Editor

Code

public function load($block_name, $edit = TRUE) {
  $block_name = str_replace('.', '/', $block_name);
  @(list($provider, $path) = explode('/', $block_name, 2));
  $this->provider = $provider;
  $this->block_name = $block_name;
  if (isset($_SESSION['forena_query_editor'][$block_name]) && $edit) {
    $block = $_SESSION['forena_query_editor'][$block_name];
    drupal_set_message(t('All changes are stored temporarily.  Click Save to make your changes permanent.  Click Cancel to discard your changes.'), 'warning', FALSE);
    $this->modified = TRUE;
  }
  else {
    $block = $this
      ->dataManager()
      ->loadBlock($block_name);
    $this->modified = FALSE;
    if (!$block) {
      $block = $this->block = $this->new_block;
      $this
        ->update($this->block);
    }
  }
  $this->block = $block;
  return $block;
}