You are here

abstract class NameBase in Plug 7

Hierarchy

Expanded class hierarchy of NameBase

1 file declares its use of NameBase
NewAcme.php in modules/plug_test/src/Plugin/name/NewAcme.php
Contains Drupal\plug_test\Plugin\name\NewAcme

File

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

Namespace

Drupal\plug_example\Plugin\name
View source
abstract class NameBase extends PluginBase implements NameInterface {

  /**
   * The name.
   *
   * @var string
   */
  protected $name;

  /**
   * {@inheritdoc}
   */
  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,
    ));
  }

  /**
   * @param string $string
   *   A string containing the English string to translate.
   * @param array $args
   *   An associative array of replacements to make after translation. Based
   *   on the first character of the key, the value is escaped and/or themed.
   *   See format_string() for details.
   * @param array $options
   *   An associative array of additional options, with the following elements:
   *   - 'langcode' (defaults to the current language): The language code to
   *     translate to a language other than what is used to display the page.
   *   - 'context' (defaults to the empty context): The context the source string
   *     belongs to.
   *
   * @return string
   *   The translated string.
   *
   * @see t().
   */
  protected static function t($string, array $args = array(), array $options = array()) {
    return t($string, $args, $options);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
NameBase::$name protected property The name. 4
NameBase::displayName public function Displays a name. Overrides NameInterface::displayName
NameBase::t protected static function 2
PluginBase::$configuration protected property Configuration information passed into the plugin.
PluginBase::$pluginDefinition protected property The plugin implementation definition.
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::__construct public function Constructs a Drupal\Component\Plugin\PluginBase object. 1