vBulletin 5.6.5 API

vB_Context
in package
Uses vB_Trait_NoSerialize

Context Container for information about a context that can be serialized and used as an id to determine whether other data or methods are applicable.

This is useful for both caching and state management. A context can be created to retrieve an appropriate cache object or managed state value. The context can be hashed providing a context value for testing.

Values can be set in any order as they will be sorted for integrity before hashing the context id.

Tags
example:

$context = new vB_Context(); $context->widgetid = 55; $context->widgetlabel = 'mywidget'; $context->nodeid = 2; $context->quantity = 10;

// Get cached result based on the above context if (!($result = $cache->read($context))) { // ... code to create the new output // save result to cache $cache->write($context, $data); } return $result;

author

vBulletin Development Team

version

$Revision: 99788 $

since

$Date: 2018-10-24 17:26:31 -0700 (Wed, 24 Oct 2018) $

Table of Contents

$_id  : string
The resolved id of the context.
$_key  : string
A custom key to add to the context.
$_values  : array<string|int, mixed>
The individualising characteristics of the context.
__construct()  : mixed
Constructor.
__serialize()  : mixed
__set()  : mixed
Setter for defining the context characteristics.
__sleep()  : mixed
__toString()  : string
__toString Returns the evaluated context id.
__unserialize()  : mixed
__wakeup()  : mixed
getId()  : string
Gets an individual id for the context.

Properties

$_id

The resolved id of the context.

private string $_id

This can be used to get or test data relating to the appropriate context.

$_key

A custom key to add to the context.

private string $_key

The evaluated md5 string representation of the context can be prefixed with a custom string to allow it to be more easily identified visually. If a key is provided, the resulting string id of the context will be truncated to accomodate the prefix.

$_values

The individualising characteristics of the context.

private array<string|int, mixed> $_values = array()

Methods

__construct()

Constructor.

public __construct([mixed $key = false ][, mixed $values = false ]) : mixed

Allows values to be given as an array on instantiation.

Parameters
$key : mixed = false
$values : mixed = false
Return values
mixed

__serialize()

public __serialize() : mixed
Return values
mixed

__set()

Setter for defining the context characteristics.

public __set(string $property, mixed $value) : mixed
Parameters
$property : string
  • The property id
$value : mixed
  • The value to set
Return values
mixed

__sleep()

public __sleep() : mixed
Return values
mixed

__toString()

__toString Returns the evaluated context id.

public __toString() : string
Return values
string

__unserialize()

public __unserialize(mixed $serialized) : mixed
Parameters
$serialized : mixed
Return values
mixed

__wakeup()

public __wakeup() : mixed
Return values
mixed

getId()

Gets an individual id for the context.

public getId() : string
Return values
string

Search results