1 layout.module layout_get_handler_name($plugin_type, $plugin_name)

Helper function to get a handler class name based on the plugin name.

File

core/modules/layout/layout.module, line 1918
The Layout module creates pages and wraps existing pages in layouts.

Code

function layout_get_handler_name($plugin_type, $plugin_name) {
  // Block "plugins" for Layouts are wrappers around the generic block system.
  $broken_class = NULL;

  if ($plugin_type === 'block') {
    $parts = explode(':', $plugin_name);
    list($module, $delta) = $parts;
    $info = layout_get_block_info($module, $delta);

    if ($info) {
      if (isset($info['class'])) {
        $class_name = $info['class'];
      }
      else {
        $class_name = 'BlockLegacy';
      }
      // Field blocks use the field name as the third part of the plugin name.
      // If the field no longer exists, return a broken block.
      if ($delta == 'field_block' && isset($parts[2])) {
        $field_name = $parts[2];
        $available_fields = field_get_block_list();

        if (empty($available_fields[$field_name])) {
          $class_name = 'BlockBroken';
        }
      }
    }
    else {
      $class_name = 'BlockBroken';
    }
  }
  else {
    $info = _layout_get_all_info($plugin_type);

    switch ($plugin_type) {
      case 'layout_access':
        $broken_class = 'LayoutAccessBroken';
        break;
      case 'layout_context':
        $broken_class = 'LayoutContextBroken';
        break;
      case 'layout_relationship':
        $broken_class = 'LayoutRelationshipBroken';
        break;
      case 'layout_style':
        $broken_class = 'LayoutStyle';
        break;
    }

    if (isset($info[$plugin_name]['class']) && class_exists($info[$plugin_name]['class'])) {
      $class_name = $info[$plugin_name]['class'];
    }
    else {
      $class_name = $broken_class;
    }
  }

  return $class_name;
}