You are here

function organigrams_block_view in Organigrams 7

Implements hook_block_view().

File

./organigrams.module, line 531
Defines the organigrams functions and entity types.

Code

function organigrams_block_view($delta = '') {

  // Initialize block variable.
  $block = array(
    'subject' => NULL,
    'content' => NULL,
  );

  // Load the organigram.
  $organigram = organigrams_load((int) $delta);
  if (!empty($organigram) && organigrams_entity_access('view', $organigram)) {

    // Generate the organigram renderable array.
    $organigram_renderable_array = entity_view('organigrams', array(
      $organigram,
    ), 'organigram_block');

    // Check if generating the organigram was successful.
    if (is_array($organigram_renderable_array)) {

      // Render the organigram renderable array and save the content in the
      // block.
      $block['content'] = drupal_render($organigram_renderable_array);
    }
  }

  // Return the rendered organigram block.
  return $block;
}