You are here

public function NameBase::displayName in Plug 7

Displays a name.

Return value

string The name representation.

Overrides NameInterface::displayName

File

modules/plug_example/src/Plugin/name/NameBase.php, line 24
Contains Drupal\plug_example\Plugin\name\NameBase

Class

NameBase

Namespace

Drupal\plug_example\Plugin\name

Code

public function displayName() {
  $definition = $this
    ->getPluginDefinition();
  $replacement = empty($this->configuration['em']) ? '@name' : '%name';
  if ($definition['company']) {
    return $this::t('Company name: ' . $replacement . ' Inc.', array(
      $replacement => $this->name,
    ));
  }
  return $this::t('My name is: ' . $replacement, array(
    $replacement => $this->name,
  ));
}