vBulletin 5.6.5 API

vB_Types
in package
Uses vB_Trait_NoSerialize

vB Types Handler Provides methods to convert id's, class names, packages, class string fragments and friendly titles for the framework object types package and contenttype.

Child classes may add additional types allowing them to be fetched and handled together.

Tags
version

$Revision: 99788 $

since

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

Table of Contents

$aggregators  : mixed
array of aggregator content type ids ****
$attachables  : array<string|int, mixed>
Attachable contenttypes by type key.
$cache_events  : array<string|int, mixed>
Events that expire the type cache.
$cache_key  : string
The key to use to store the type cache.
$contenttype_ids  : array<string|int, mixed>
Valid contenttypes by numeric id.
$contenttypes  : array<string|int, mixed>
Valid contenttypes by type key.
$instance  : vB_Types
A reference to the singleton instance
$loaded  : bool
Whether we have loaded the type info.
$nonaggregators  : mixed
array of non-aggregator content type ids ****
$package_ids  : array<string|int, mixed>
Valid packages by numeric id.
$packages  : array<string|int, mixed>
Valid packages by class string identifier.
$searchables  : array<string|int, mixed>
Searchable contenttypes by type key.
__serialize()  : mixed
__sleep()  : mixed
__unserialize()  : mixed
__wakeup()  : mixed
assertContentType()  : mixed
Checks if a contenttype id is valid and throws an exception if it isn't.
assertPackage()  : mixed
Checks if a package is valid and throws an exception if it isn't.
contentTypeEnabled()  : bool
Checks of a contenttype is enabled.
getAggregatorTypeIds()  : array<string|int, mixed>
This gives up a list of the Aggregator types.
getAttachableContentTypes()  : array<string|int, mixed>
Fetches all attachable content types
getContentClassFromId()  : mixed
Gets the class and package of a contenttypeid.
getContentTypeCacheEvents()  : array<string|int, mixed>
Fetches the cache events that affect contenttypes.
getContentTypeClass()  : string
Gets the class string identifier for a contenttype.
getContentTypeClasses()  : array<string|int, mixed>
Gets the contenttype class strings from a list of content type ids.
getContentTypeID()  : int
Gets a contenttype id from a type key or array(package, class).
getContentTypePackage()  : string
Gets the package class string identifier for a contenttype
getContentTypePackageID()  : int
Gets the package id for a contenttype
getContentTypes()  : array<string|int, mixed>
Fetches all content types
getContentTypeTitle()  : string
Gets the user friendly title of a contenttype.
getNonAggregatorTypeIds()  : array<string|int, mixed>
This gives up a list of the non-Aggregator types.
getPackageClass()  : string
Gets the class string identifier for a package.
getPackageID()  : int
Gets the numeric package id a package class string identifier.
getSearchableContentTypes()  : array<string|int, mixed>
Fetches all searchable content types
getTypeKey()  : string
Gets a unique string key representing a type for the given package and class.
getUntitledContentTypeTitle()  : string
Gets a user friendly phrase for an untitled piece of content.
instance()  : vB_Types
Returns singleton instance of self.
packageEnabled()  : mixed
Checks if a package is enabled.
reloadTypes()  : mixed
This should only be called while in a
__construct()  : mixed
Constructor protected to enforce singleton use.
getTypeInfo()  : array<string|int, mixed>
Builds the type info cache.
loadContentTypes()  : mixed
Loads contenttype info from the type info cache.
loadPackages()  : mixed
Loads package info from the type info cache.
loadTypeInfo()  : mixed
Loads the type info from the type info cache into distinct type properties.
loadTypes()  : mixed
Ensures the type information is loaded.

Properties

$aggregators

array of aggregator content type ids ****

protected mixed $aggregators = array()

$attachables

Attachable contenttypes by type key.

protected array<string|int, mixed> $attachables = array()

Note: The key is generated by vB_Core::getTypeKey() based on the package class string identifer and content type class string identifier.

The array is in the format array(string contenttype key => array('class' => string, 'package' => package, 'id' => integer)

Note: The package value is a reference to an element in $packages.

$cache_events

Events that expire the type cache.

protected array<string|int, mixed> $cache_events = array('vb_types.type_updated', 'vb_types.package_updated', 'vb_types.contenttype_updated')

$cache_key

The key to use to store the type cache.

protected string $cache_key = 'vb_types.types'

$contenttype_ids

Valid contenttypes by numeric id.

protected array<string|int, mixed> $contenttype_ids = array()

An integer lookup for all contenttypes. The values are references to $contenttypes.

Tags
see
vB_Core::$contenttypes

$contenttypes

Valid contenttypes by type key.

protected array<string|int, mixed> $contenttypes = array()

Note: The key is generated by vB_Core::getTypeKey() based on the package class string identifer and content type class string identifier.

The array is in the format array(string contenttype key => array('class' => string, 'package' => package, 'id' => integer)

Note: The package value is a reference to an element in $packages.

$instance

A reference to the singleton instance

protected static vB_Types $instance

$loaded

Whether we have loaded the type info.

protected bool $loaded

$nonaggregators

array of non-aggregator content type ids ****

protected mixed $nonaggregators = array()

$package_ids

Valid packages by numeric id.

protected array<string|int, mixed> $package_ids = array()

An integer lookup for all packages. The values are references to $packages.

Tags
see
vB_Core::$packages

$packages

Valid packages by class string identifier.

protected array<string|int, mixed> $packages = array()

A string lookup for all packages. The array is in the format array(class string => array('enabled' => bool, 'class' => string, 'id' => int)

$searchables

Searchable contenttypes by type key.

protected array<string|int, mixed> $searchables = array()

Note: The key is generated by vB_Core::getTypeKey() based on the package class string identifer and content type class string identifier.

The array is in the format array(string contenttype key => array('class' => string, 'package' => package, 'id' => integer)

Note: The package value is a reference to an element in $packages.

Methods

__serialize()

public __serialize() : mixed
Return values
mixed

__sleep()

public __sleep() : mixed
Return values
mixed

__unserialize()

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

__wakeup()

public __wakeup() : mixed
Return values
mixed

assertContentType()

Checks if a contenttype id is valid and throws an exception if it isn't.

public assertContentType(mixed $contenttype[, vB_Exception $e = null ]) : mixed
Parameters
$contenttype : mixed
  • Key, array(package, class) or numeric id of the contenttype
$e : vB_Exception = null
  • An alternative exception to throw
Tags
throws
mixed
  • Thrown if the given contenttype is not valid
Return values
mixed

assertPackage()

Checks if a package is valid and throws an exception if it isn't.

public assertPackage(mixed $package[, vB_Exception $e = null ]) : mixed
Parameters
$package : mixed
  • Class string identifier or numeric id of the package to check
$e : vB_Exception = null
  • An alternative exception to throw
Tags
throws
mixed
  • Thrown if the package was not valid
Return values
mixed

contentTypeEnabled()

Checks of a contenttype is enabled.

public contentTypeEnabled(mixed $contenttype) : bool

A contenttype is disabled if it's package is disabled.

Parameters
$contenttype : mixed
  • Key, array(package, class) or numeric id of the contenttype
Return values
bool

getAggregatorTypeIds()

This gives up a list of the Aggregator types.

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

of ID

getAttachableContentTypes()

Fetches all attachable content types

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

Content types.

getContentClassFromId()

Gets the class and package of a contenttypeid.

public getContentClassFromId(mixed $contenttypeid) : mixed

Note: The title is not stored as part of the contenttype and is instead a phrase that is evaluated from the contenttype's package and class.

Parameters
$contenttypeid : mixed
Return values
mixed

getContentTypeCacheEvents()

Fetches the cache events that affect contenttypes.

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

string

getContentTypeClass()

Gets the class string identifier for a contenttype.

public getContentTypeClass(mixed $contenttype) : string
Parameters
$contenttype : mixed
  • Key, array(package, class) or numeric id of the contenttype
Return values
string
  • The class string identifier of the given contenttype

getContentTypeClasses()

Gets the contenttype class strings from a list of content type ids.

public getContentTypeClasses(mixed $contenttypes) : array<string|int, mixed>

Note: This will also accept content type namesso the function can be used for normalisation and validation.

Parameters
$contenttypes : mixed
Return values
array<string|int, mixed>

of conten type classes

getContentTypeID()

Gets a contenttype id from a type key or array(package, class).

public getContentTypeID(mixed $contenttype) : int

Note: This will also return the numeric id if one is given, allowing the function to be used for normalisation and validation.

If the contenttype is given as an array, it must be in the form array('package' => package class string, 'class' => contenttype class string)

Parameters
$contenttype : mixed
  • Key, array(package, class) or numeric id of the contenttype
Return values
int

| false

getContentTypePackage()

Gets the package class string identifier for a contenttype

public getContentTypePackage(mixed $contenttype) : string
Parameters
$contenttype : mixed
  • Key, array(package, class) or numeric id of the contenttype
Return values
string
  • The class string of the package

getContentTypePackageID()

Gets the package id for a contenttype

public getContentTypePackageID(mixed $contenttype) : int
Parameters
$contenttype : mixed
  • Key, array(package, class) or numeric id of the contenttype
Return values
int
  • The integer id of the package that the contenttype belongs to

getContentTypes()

Fetches all content types

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

Content types.

getContentTypeTitle()

Gets the user friendly title of a contenttype.

public getContentTypeTitle(mixed $contenttype) : string

Note: The title is not stored as part of the contenttype and is instead a phrase that is evaluated from the contenttype's package and class.

Parameters
$contenttype : mixed
Return values
string

getNonAggregatorTypeIds()

This gives up a list of the non-Aggregator types.

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

of ID

getPackageClass()

Gets the class string identifier for a package.

public getPackageClass(mixed $package) : string
Parameters
$package : mixed
  • Class string identifier or numeric id of the package to check
Tags
throws
vB_Exception_Warning
  • Thrown if an invalid package was given
Return values
string

getPackageID()

Gets the numeric package id a package class string identifier.

public getPackageID(mixed $package) : int

Note: This will also return a package id for a given package id after verification so the function can be used for normalisation.

Parameters
$package : mixed
  • Class string identifier or numeric id of the package to check
Return values
int

| false

getSearchableContentTypes()

Fetches all searchable content types

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

Content types.

getTypeKey()

Gets a unique string key representing a type for the given package and class.

public getTypeKey(string $package, string $class) : string

Note: The key is only unique per type (ie, unique for contenttypes).

Parameters
$package : string
  • The package identifier
$class : string
  • The class identifier
Return values
string
  • The resulting single string unique key identifier

getUntitledContentTypeTitle()

Gets a user friendly phrase for an untitled piece of content.

public getUntitledContentTypeTitle(mixed $contenttype) : string
Parameters
$contenttype : mixed
Return values
string

instance()

Returns singleton instance of self.

public static instance() : vB_Types
Tags
todo

This can be inherited once late static binding is available. For now it has to be redefined in the child classes

Return values
vB_Types
  • Reference to singleton instance of the type handler

packageEnabled()

Checks if a package is enabled.

public packageEnabled(mixed $package) : mixed
Parameters
$package : mixed
  • Class string identifier or numeric id of the package to check
Return values
mixed

reloadTypes()

This should only be called while in a

public reloadTypes() : mixed
Return values
mixed

__construct()

Constructor protected to enforce singleton use.

protected __construct() : mixed
Tags
see
instance()
Return values
mixed

getTypeInfo()

Builds the type info cache.

protected getTypeInfo() : array<string|int, mixed>
Tags
TODO

Use type collection

Return values
array<string|int, mixed>

mixed - Assoc array of type info

loadContentTypes()

Loads contenttype info from the type info cache.

protected loadContentTypes(mixed $type_info) : mixed
Parameters
$type_info : mixed
Tags
see
vB_Core::buildTypeCache()
throws
vB_Exception_Critical
  • Thrown if no contenttypes were found
Return values
mixed

loadPackages()

Loads package info from the type info cache.

protected loadPackages(mixed $type_info) : mixed
Parameters
$type_info : mixed
Tags
see
vB_Core::buildTypeCache()
throws
vB_Exception_Critical
  • Thrown if no packages are found
Return values
mixed

loadTypeInfo()

Loads the type info from the type info cache into distinct type properties.

protected loadTypeInfo(mixed $type_info) : mixed
Parameters
$type_info : mixed
Return values
mixed

loadTypes()

Ensures the type information is loaded.

protected loadTypes() : mixed
Return values
mixed

Search results