You are here

function views_content_cache_key::view_key_replace_arguments in Views content cache 6.2

Same name and namespace in other branches
  1. 7.3 plugins/views_content_cache/base.inc \views_content_cache_key::view_key_replace_arguments()

Replaces values corresponding to argument values set dynamically.

2 calls to views_content_cache_key::view_key_replace_arguments()
views_content_cache_key::view_key in plugins/base.inc
An array of keys to check in this cache segment when viewing the view.
views_content_cache_key_og::view_key in plugins/og.inc
An array of keys to check in this cache segment when viewing the view.

File

plugins/base.inc, line 74

Class

views_content_cache_key
Base class for the views content cache plugins.

Code

function view_key_replace_arguments($values, &$handler) {
  foreach ($values as $value) {
    if (strpos($value, '__arg:') === 0) {

      // Get the argument and make sure its actually on the view still.
      $arg_id = substr($value, strlen('__arg:'));
      if (isset($handler->view->argument[$arg_id]) && $handler->view->argument[$arg_id]->argument_validated) {

        // Argument is there and ready to go!
        $argument = drupal_clone($handler->view->argument[$arg_id]);
        $arg_value = $argument
          ->get_value();

        // Might need to split this up.
        if (!empty($argument->options['break_phrase'])) {
          views_break_phrase($argument
            ->get_value(), $argument);
          foreach ($argument->value as $new_val) {
            $values[$new_val] = $new_val;
          }
        }
        else {
          $new_val = $argument
            ->get_value();
          $values[$new_val] = $new_val;
        }
      }

      // Always remove the dummy argument value.
      unset($values[$value]);
    }
  }
  return $values;
}