vBulletin v6.0.4

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

since

$Date: 2021-02-16 11:04:48 -0800 (Tue, 16 Feb 2021) $

Table of Contents

Methods

__construct()  : mixed
Constructor.
__serialize()  : array<string|int, mixed>
__set()  : mixed
Setter for defining the context characteristics.
__sleep()  : array<string|int, mixed>
__toString()  : string
__toString Returns the evaluated context id.
__unserialize()  : void
__wakeup()  : void
getId()  : string
Gets an individual id for the context.

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

__serialize()

public __serialize() : array<string|int, mixed>
Return values
array<string|int, 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

__sleep()

public __sleep() : array<string|int, mixed>
Return values
array<string|int, mixed>

__toString()

__toString Returns the evaluated context id.

public __toString() : string
Return values
string

__unserialize()

public __unserialize(array<string|int, mixed> $serialized) : void
Parameters
$serialized : array<string|int, mixed>

getId()

Gets an individual id for the context.

public getId() : string
Return values
string

        
On this page

Search results