You are here

class HideModifier in Modifiers Pack 8

Provides a Modifier to hide an element.

Plugin annotation


@Modifier(
  id = "hide_modifier",
  label = @Translation("Hide Modifier"),
  description = @Translation("Provides a Modifier to hide an element."),
)

Hierarchy

  • class \Drupal\modifiers_hide\Plugin\modifiers\HideModifier extends \Drupal\modifiers\ModifierPluginBase

Expanded class hierarchy of HideModifier

1 file declares its use of HideModifier
HideModifierTest.php in modules/modifiers_hide/tests/src/Unit/HideModifierTest.php

File

modules/modifiers_hide/src/Plugin/modifiers/HideModifier.php, line 17

Namespace

Drupal\modifiers_hide\Plugin\modifiers
View source
class HideModifier extends ModifierPluginBase {

  /**
   * {@inheritdoc}
   */
  public static function modification($selector, array $config) {
    if (filter_var($config['hide'], FILTER_VALIDATE_BOOLEAN)) {
      $media = parent::getMediaQuery($config);
      $css[$media][$selector][] = 'display:none';
      return new Modification($css);
    }
    return NULL;
  }

}

Members