class context_prefix_cache in Context 5
Specialized cache for storing prefix information.
Hierarchy
- class \context_prefix_cache
 
Expanded class hierarchy of context_prefix_cache
File
- context_prefix/
context_prefix.module, line 830  
View source
class context_prefix_cache {
  protected $cache = array();
  function __construct() {
    $this->cache[CONTEXT_PREFIX_PATH] = array();
    $this->cache[CONTEXT_PREFIX_PAIR] = array();
    $this->cache[CONTEXT_PREFIX_SUBDOMAIN] = array();
    $this->cache[CONTEXT_PREFIX_DOMAIN] = array();
  }
  /**
   * @param $method
   *   The method to add to the cache for
   * @param $item
   *   Either a integer|string, or keyed array to add
   * @param $merge
   *   Preserve keys and merge into cache for method.
   */
  public function add($method, $item, $merge = true) {
    if (is_array($item) && $merge) {
      // Need to preserve keys so we use the '+' array operator.
      $this->cache[$method] = $this->cache[$method] + $item;
    }
    else {
      $this->cache[$method][] = $item;
    }
  }
  /**
   * @param $method
   *   The method to retrieve from the cache for.
   * @param $item
   *   Optionally and key of the required info.
   *
   * @return the desired info or false if an id doesn't exist.
   */
  public function get($method = false, $id = false) {
    if ($method !== false && $id !== false) {
      return isset($this->cache[$method][$id]) ? $this->cache[$method][$id] : false;
    }
    elseif ($method !== false) {
      return $this->cache[$method];
    }
    else {
      return $this->cache;
    }
  }
}Members
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            context_prefix_cache:: | 
                  protected | property | ||
| 
            context_prefix_cache:: | 
                  public | function | ||
| 
            context_prefix_cache:: | 
                  public | function | ||
| 
            context_prefix_cache:: | 
                  function |