You are here

function flag_flag::fetch_content in Flag 5

Same name and namespace in other branches
  1. 6.2 flag.inc \flag_flag::fetch_content()
  2. 6 flag.inc \flag_flag::fetch_content()
  3. 7.2 flag.inc \flag_flag::fetch_content()

Fetches, possibly from some cache, a content object this flag works with.

2 calls to flag_flag::fetch_content()
flag_flag::applies_to_content_id in ./flag.inc
Returns TRUE if the flag applies to the content with the given ID.
flag_flag::remember_content in ./flag.inc
Stores some object in fetch_content()'s cache, so subsequenet calls to fetch_content() return it.

File

./flag.inc, line 258
Implements various flags. Uses object oriented style inspired by that of Views 2.

Class

flag_flag
This abstract class represents a flag, or, in Views 2 terminology, "a handler".

Code

function fetch_content($content_id, $object_to_remember = NULL) {
  static $cache = array();
  if (isset($object_to_remember)) {
    $cache[$content_id] = $object_to_remember;
  }
  if (!array_key_exists($content_id, $cache)) {
    $content = $this
      ->_load_content($content_id);
    $cache[$content_id] = $content ? $content : NULL;
  }
  return $cache[$content_id];
}