You are here

function magic_assets_exclude in Magic 7.2

Eliminates elements from an array using a simplified regex pattern.

Parameters

$elements: The array of elements that should have some of its items removed.

$steps: A set of regex as generated by magic_prepare_regex().

3 calls to magic_assets_exclude()
MagicCSSTestCase::testMagicCSSExcludes in ./magic.test
Test magic_assets_exclude().
MagicJSTestCase::testMagicJSExcludes in ./magic.test
Test magic_assets_exclude().
magic_css_js_alter in ./magic.module
Helper function to remove unwanted css or js.

File

includes/magic.assets.inc, line 136
A file to contain functions for the magic module to abuse.

Code

function magic_assets_exclude(&$elements, $steps) {
  $mapping = magic_assets_generate_mapping($elements);
  $remove = array();
  foreach ($steps as $step) {
    list($exclude, $include) = $step;
    $remove += preg_grep($exclude, !empty($remove) ? array_diff_key($mapping, $remove) : $mapping);
    if (!empty($include)) {
      $remove = array_diff_key($remove, preg_grep($include, $remove));
    }
  }
  $elements = array_diff_key($elements, $remove);
}