class WeatherSystemDisplayBlock in Weather 8
Same name in this branch
- 8 src/Plugin/Derivative/WeatherSystemDisplayBlock.php \Drupal\weather\Plugin\Derivative\WeatherSystemDisplayBlock
- 8 src/Plugin/Block/WeatherSystemDisplayBlock.php \Drupal\weather\Plugin\Block\WeatherSystemDisplayBlock
Same name and namespace in other branches
- 2.0.x src/Plugin/Derivative/WeatherSystemDisplayBlock.php \Drupal\weather\Plugin\Derivative\WeatherSystemDisplayBlock
Provides block plugin definitions for nodes.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\weather\Plugin\Derivative\WeatherSystemDisplayBlock implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of WeatherSystemDisplayBlock
See also
\Drupal\weather\Plugin\Block\WeatherSystemDisplayBlock
File
- src/
Plugin/ Derivative/ WeatherSystemDisplayBlock.php, line 17
Namespace
Drupal\weather\Plugin\DerivativeView source
class WeatherSystemDisplayBlock extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
/**
* The node storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $weatherDisplayStorage;
/**
* Constructs new WeatherSystemDisplayBlock.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $weatherDisplayStorage
* The weather displays storage.
*/
public function __construct(EntityStorageInterface $weatherDisplayStorage) {
$this->weatherDisplayStorage = $weatherDisplayStorage;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('entity_type.manager')
->getStorage('weather_display'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$weatherDisplays = $this->weatherDisplayStorage
->loadByProperties([
'type' => WeatherDisplayInterface::SYSTEM_WIDE_TYPE,
]);
foreach ($weatherDisplays as $weatherDisplay) {
$display_number = $weatherDisplay->number->value;
$this->derivatives[$weatherDisplay
->id()] = $base_plugin_definition;
$this->derivatives[$weatherDisplay
->id()]['admin_label'] = $this
->t('Weather: system-wide display (#@number)', [
'@number' => $display_number,
]);
}
return $this->derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
WeatherSystemDisplayBlock:: |
protected | property | The node storage. | |
WeatherSystemDisplayBlock:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
WeatherSystemDisplayBlock:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
WeatherSystemDisplayBlock:: |
public | function | Constructs new WeatherSystemDisplayBlock. |