You are here

abstract class FlagCookieStorage in Flag 6.2

Same name and namespace in other branches
  1. 7.3 includes/flag.cookie_storage.inc \FlagCookieStorage
  2. 7.2 flag.inc \FlagCookieStorage

Utility class to handle cookies.

Cookies are used to record flaggings for anonymous users on cached pages.

This class contains only two instance methods. Usage example:

$storage = FlagCookieStorage::factory($flag);
$storage
  ->flag(145);
$storage
  ->unflag(17);

You may delete all the cookies with <code>FlagCookieStorage::drop()</code>.

Hierarchy

Expanded class hierarchy of FlagCookieStorage

File

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

View source
abstract class FlagCookieStorage {

  /**
   * Returns the actual storage object compatible with the flag.
   */
  static function factory($flag) {
    if ($flag->global) {
      return new FlagGlobalCookieStorage($flag);
    }
    else {
      return new FlagNonGlobalCookieStorage($flag);
    }
  }
  function __construct($flag) {
    $this->flag = $flag;
  }

  /**
   * "Flags" an item.
   *
   * It just records this fact in a cookie.
   */
  abstract function flag($content_id);

  /**
   * "Unflags" an item.
   *
   * It just records this fact in a cookie.
   */
  abstract function unflag($content_id);

  /**
   * Deletes all the cookies.
   *
   * (Etymology: "drop" as in "drop database".)
   */
  static function drop() {
    FlagGlobalCookieStorage::drop();
    FlagNonGlobalCookieStorage::drop();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FlagCookieStorage::drop static function Deletes all the cookies. 2
FlagCookieStorage::factory static function Returns the actual storage object compatible with the flag.
FlagCookieStorage::flag abstract function "Flags" an item. 2
FlagCookieStorage::unflag abstract function "Unflags" an item. 2
FlagCookieStorage::__construct function 1