You are here

public function Flexiform::getDisplay in Flexiform 7

Get hold of a particular display.

Parameters

string $display: The display we want to get.

Return value

FlexiformDisplayInterface The flexiform display class if it exists, FlexiformDisplayNull if not.

Throws

Exception

File

./flexiform.entity.inc, line 48
flexiform.entity.inc

Class

Flexiform
The class used for flexiform entities

Code

public function getDisplay($display) {
  if (empty($this->displays[$display])) {
    return new FlexiformDisplayNull($this);
  }
  $display_info = flexiform_display_info($display);
  if (empty($display_info)) {
    drupal_set_message(t('Display plugin @plugin not found.', array(
      '@plugin' => $display,
    )), 'error');
    return new FlexiformDisplayNull($this, $this->displays[$display]);
  }
  $class_name = $display_info['class'];
  if (!class_exists($class_name)) {
    throw new Exception('Display class does not exist.');
  }
  return new $class_name($this, $this->displays[$display]);
}