You are here

public static function PaddingModifier::modification in Modifiers Pack 8

1 call to PaddingModifier::modification()
PaddingModifierTest::testModification in modules/modifiers_padding/tests/src/Unit/PaddingModifierTest.php
@covers ::modification

File

modules/modifiers_padding/src/Plugin/modifiers/PaddingModifier.php, line 22

Class

PaddingModifier
Provides a Modifier to set the padding on an element.

Namespace

Drupal\modifiers_padding\Plugin\modifiers

Code

public static function modification($selector, array $config) {
  $media = parent::getMediaQuery($config);
  if (!empty($config['padding_t_size']) && !empty($config['padding_t_units'])) {
    $css[$media][$selector][] = 'padding-top:' . $config['padding_t_size'] . $config['padding_t_units'];
  }
  if (!empty($config['padding_r_size']) && !empty($config['padding_r_units'])) {
    $css[$media][$selector][] = 'padding-right:' . $config['padding_r_size'] . $config['padding_r_units'];
  }
  if (!empty($config['padding_b_size']) && !empty($config['padding_b_units'])) {
    $css[$media][$selector][] = 'padding-bottom:' . $config['padding_b_size'] . $config['padding_b_units'];
  }
  if (!empty($config['padding_l_size']) && !empty($config['padding_l_units'])) {
    $css[$media][$selector][] = 'padding-left:' . $config['padding_l_size'] . $config['padding_l_units'];
  }
  if (!empty($css)) {
    return new Modification($css);
  }
  return NULL;
}