You are here

public function RenderStack::drupal_add_assets in Render cache 7.2

Helper function to add JS/CSS assets to the recursion storage.

Parameters

string $type: The type of asset, can be 'js' or 'css'.

mixed $data: The data to add.

array|string|NULL $options: The options to add.

Return value

mixed|NULL What drupal_add_js/drupal_add_css return or NULL when adding something.

See also

drupal_add_css()

drupal_add_js()

File

src/Cache/RenderStack.php, line 405
Contains \Drupal\render_cache\Cache\RenderStack

Class

RenderStack
Defines the RenderStack service.

Namespace

Drupal\render_cache\Cache

Code

public function drupal_add_assets($type, $data = NULL, $options = NULL) {

  // Construct the options when its not an array.
  if (isset($options)) {
    if (!is_array($options)) {
      $options = array(
        'type' => $options,
      );
    }
  }
  else {
    $options = array();
  }
  if (isset($data) && $this
    ->isRecursive()) {
    $new_options = $options;
    $new_options['data'] = $data;
    $storage = array();
    $storage['#attached'][$type][] = $new_options;
    $this
      ->addRecursionStorage($storage, TRUE);
    return;
  }
  return $this
    ->callOriginalFunction("drupal_add_{$type}", $data, $options);
}