abstract class NameBase in Plug 7
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\plug_example\Plugin\name\NameBase implements NameInterface
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\nameView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
NameBase:: |
protected | property | The name. | 4 |
NameBase:: |
public | function |
Displays a name. Overrides NameInterface:: |
|
NameBase:: |
protected static | function | 2 | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | |
PluginBase:: |
protected | property | The plugin implementation definition. | |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Constructs a Drupal\Component\Plugin\PluginBase object. | 1 |