You are here

class CheckboxWithExclude in Block Style Plugins 8

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

Class to demonstrate excluding a block.

Provides a 'CheckboxWithExclude' block style for adding a checkbox to all blocks except for the "Powered by Drupal" block.

The plugin definition for this class is defined in the block_style_plugins_test.blockstyle.yml file.

Hierarchy

Expanded class hierarchy of CheckboxWithExclude

1 string reference to 'CheckboxWithExclude'
block_style_plugins_test.blockstyle.yml in tests/modules/block_style_plugins_test/block_style_plugins_test.blockstyle.yml
tests/modules/block_style_plugins_test/block_style_plugins_test.blockstyle.yml

File

tests/modules/block_style_plugins_test/src/Plugin/BlockStyle/CheckboxWithExclude.php, line 17

Namespace

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

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'checkbox_class' => '',
    ];
  }

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

    // Checkboxes are do not apply a class automatically like other form
    // elements. Instead, they simply pass a boolean value that can be accessed
    // inside a Twig template like:
    // {% set checkbox_class = (block_styles.checkbox_with_exclude.checkbox_class == '1') ? TRUE : FALSE %}.
    $elements['checkbox_class'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Check this box to pass a boolean to the theme'),
      '#default_value' => $this->configuration['checkbox_class'],
    ];
    return $elements;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BlockStyleBase::$blockContentBundle protected property Bundle type for 'Block Content' blocks.
BlockStyleBase::$blockPlugin protected property Plugin instance for the Block being configured.
BlockStyleBase::$entityRepository protected property Instance of the Entity Repository service.
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::$styles Deprecated protected property Style settings for the block styles.
BlockStyleBase::baseIdMatch protected function Determine if a plugin ID matches a Base ID in a list of include/exclude.
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::defaultStyles Deprecated public function Gets default style configuration for this plugin.
BlockStyleBase::exclude public function Exclude styles from appearing on a block. Overrides BlockStyleInterface::exclude
BlockStyleBase::formAlter Deprecated public function Overrides BlockStyleInterface::formAlter
BlockStyleBase::formElements Deprecated public function Returns an array of field elements.
BlockStyleBase::getConfiguration public function Gets this plugin's configuration. Overrides ConfigurableInterface::getConfiguration
BlockStyleBase::getStyles Deprecated public function Gets this plugin's style configuration.
BlockStyleBase::getStylesFromVariables protected function Get styles for a block set in a preprocess $variables array.
BlockStyleBase::includeOnly public function Only show styles on specific blocks. Overrides BlockStyleInterface::includeOnly
BlockStyleBase::prepareForm public function Returns the configuration form elements specific to a block configuration. Overrides BlockStyleInterface::prepareForm
BlockStyleBase::setBlockContentBundle public function Set the block content bundle type.
BlockStyleBase::setConfiguration public function Sets the configuration for this plugin instance. Overrides ConfigurableInterface::setConfiguration
BlockStyleBase::setStyles Deprecated public function Sets the style configuration for this plugin instance.
BlockStyleBase::submitConfigurationForm public function Form submission handler. Overrides PluginFormInterface::submitConfigurationForm
BlockStyleBase::submitForm Deprecated public function Overrides BlockStyleInterface::submitForm
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::validateForm Deprecated public function Adds block style specific validation handling for the block form.
BlockStyleBase::__construct public function Construct method for BlockStyleBase. Overrides PluginBase::__construct
CheckboxWithExclude::buildConfigurationForm public function Form constructor. Overrides BlockStyleBase::buildConfigurationForm
CheckboxWithExclude::defaultConfiguration public function Gets default configuration for this plugin. Overrides BlockStyleBase::defaultConfiguration
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
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.