1 block.class.inc Block::__construct($plugin_name, array $data = array())

Create a new Block object.

Parameters

string $plugin_name: The Layout plugin name. In the case of a block, this is a key identifying the block module, delta, and (if applicable) child delta, separated by colons.

array $data: Settings that provide current configuration of the block, such as access rules, style settings, block settings, etc.

Overrides LayoutHandler::__construct

File

core/modules/layout/includes/block.class.inc, line 87
A class that wraps around a block to store settings information.

Class

Block
@file A class that wraps around a block to store settings information.

Code

function __construct($plugin_name, array $data = array()) {
  parent::__construct($plugin_name, $data);
  $this->plugin = $plugin_name;

  // Provide defaults.
  $data += array(
    'settings' => array(),
    'style' => array(
      'plugin' => 'default',
      'data' => array(),
    ),
    'conditions' => array(),
  );
  $data['settings'] += array(
    'title_display' => LAYOUT_TITLE_DEFAULT,
    'title' => '',
    'style' => 'default',
    'block_settings' => array(),
    'contexts' => array(),
  );

  // Initialize basics, module, delta, UUID, status, and childDelta.
  list($this->module, $this->delta) = explode(':', $plugin_name);
  $this->uuid = isset($data['uuid']) ? $data['uuid'] : NULL;
  $this->is_new = !$this->uuid;
  $this->status = isset($data['status']) ? $data['status'] : BLOCK_ENABLED;
  $parts = explode(':', $this->plugin, 3);
  $this->childDelta = isset($parts[2]) ? $parts[2] : NULL;

  // Initialize the style.
  $this->style = layout_create_handler('layout_style', $data['style']['plugin'], $data['style']['data']);

  // Initialize conditions.
  foreach ($data['conditions'] as $condition) {
    $this->conditions[] = layout_create_handler('layout_access', $condition['plugin'], $condition['data']);
  }

  // All other settings.
  $this->settings = $data['settings'];
}