You are here

class DropdownWithInclude in Block Style Plugins 8.2

Same name and namespace in other branches
  1. 8 tests/modules/block_style_plugins_test/src/Plugin/BlockStyle/DropdownWithInclude.php \Drupal\block_style_plugins_test\Plugin\BlockStyle\DropdownWithInclude

Demonstrate using the 'include' parameter.

Provides a 'DropdownWithInclude' block style for only adding styles to the "Powered by Drupal" block.

Plugin annotation


@BlockStyle(
 id = "dropdown_with_include",
 label = @Translation("Dropdown with Include"),
 include = {
   "system_powered_by_block",
   "basic",
 }
)

Hierarchy

Expanded class hierarchy of DropdownWithInclude

File

tests/modules/block_style_plugins_test/src/Plugin/BlockStyle/DropdownWithInclude.php, line 23

Namespace

Drupal\block_style_plugins_test\Plugin\BlockStyle
View source
class DropdownWithInclude extends BlockStyleBase {

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {

    // Default this to the third option.
    return [
      'dropdown_class' => 'style-3',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {

    // The value of the options should be the class name which will be applied.
    $elements['dropdown_class'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Choose a style from the dropdown'),
      '#options' => [
        'style-1' => $this
          ->t('Style 1'),
        'style-2' => $this
          ->t('Style 2'),
        'style-3' => $this
          ->t('Style 3'),
      ],
      '#default_value' => $this->configuration['dropdown_class'],
    ];
    return $elements;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BlockStyleBase::$entityTypeManager protected property Instance of the Entity Type Manager service.
BlockStyleBase::$pluginId protected property Plugin ID for the Block being configured. Overrides PluginBase::$pluginId
BlockStyleBase::build public function Builds and returns the renderable array for this block style plugin. Overrides BlockStyleInterface::build
BlockStyleBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
BlockStyleBase::getConfiguration public function Gets this plugin's configuration. Overrides ConfigurableInterface::getConfiguration
BlockStyleBase::getStylesFromVariables protected function Get styles for a block set in a preprocess $variables array.
BlockStyleBase::setConfiguration public function Sets the configuration for this plugin instance. Overrides ConfigurableInterface::setConfiguration
BlockStyleBase::submitConfigurationForm public function Form submission handler. Overrides PluginFormInterface::submitConfigurationForm
BlockStyleBase::themeSuggestion public function Add theme suggestions for the block. Overrides BlockStyleInterface::themeSuggestion 1
BlockStyleBase::validateConfigurationForm public function Form validation handler. Overrides PluginFormInterface::validateConfigurationForm
BlockStyleBase::__construct public function Construct method for BlockStyleBase. Overrides PluginBase::__construct
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
DropdownWithInclude::buildConfigurationForm public function Form constructor. Overrides BlockStyleBase::buildConfigurationForm
DropdownWithInclude::defaultConfiguration public function Gets default configuration for this plugin. Overrides BlockStyleBase::defaultConfiguration
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
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 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.