class vB_Types

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.

Traits

Properties

static protected vB_Types $instance A reference to the singleton instance
protected bool $loaded Whether we have loaded the type info.
protected array $packages Valid packages by class string identifier.
protected array $package_ids Valid packages by numeric id.
protected array $contenttypes Valid contenttypes by type key.
protected array $searchables Searchable contenttypes by type key.
protected array $attachables Attachable contenttypes by type key.
protected array $contenttype_ids Valid contenttypes by numeric id.
protected string $cache_key The key to use to store the type cache.
protected $aggregators array of aggregator content type ids ****
protected $nonaggregators array of non-aggregator content type ids ****
protected array $cache_events Events that expire the type cache.

Methods

__sleep()

No description

__wakeup()

No description

__construct()

Constructor protected to enforce singleton use.

static vB_Types
instance()

Returns singleton instance of self.

loadTypes()

Ensures the type information is loaded.

array
getTypeInfo()

Builds the type info cache.

array
getAggregatorTypeIds()

This gives up a list of the Aggregator types.

array
getNonAggregatorTypeIds()

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

loadTypeInfo(array $type_info)

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

string
getTypeKey(string $package, string $class)

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

loadPackages(array $type_info)

Loads package info from the type info cache.

int
getPackageID(mixed $package)

Gets the numeric package id a package class string identifier.

string
getPackageClass(mixed $package)

Gets the class string identifier for a package.

assertPackage(mixed $package, vB_Exception $e = null)

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

packageEnabled(mixed $package)

Checks if a package is enabled.

loadContentTypes(array $type_info)

Loads contenttype info from the type info cache.

int
getContentTypeID(mixed $contenttype)

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

array
getContentTypeClasses($contenttypes)

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

assertContentType(mixed $contenttype, vB_Exception $e = null)

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

string
getContentTypePackage(mixed $contenttype)

Gets the package class string identifier for a contenttype

int
getContentTypePackageID(mixed $contenttype)

Gets the package id for a contenttype

string
getContentTypeClass(mixed $contenttype)

Gets the class string identifier for a contenttype.

string
getContentTypeTitle(mixed $contenttype)

Gets the user friendly title of a contenttype.

string
getUntitledContentTypeTitle(mixed $contenttype)

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

getContentClassFromId($contenttypeid)

Gets the class and package of a contenttypeid.

bool
contentTypeEnabled(mixed $contenttype)

Checks of a contenttype is enabled.

array
getContentTypeCacheEvents()

Fetches the cache events that affect contenttypes.

array
getContentTypes()

Fetches all content types

array
getSearchableContentTypes()

Fetches all searchable content types

array
getAttachableContentTypes()

Fetches all attachable content types

reloadTypes()

This should only be called while in a

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

at line 149
protected __construct()

Constructor protected to enforce singleton use.

See also

instance()

at line 162
static vB_Types instance()

Returns singleton instance of self.

Return Value

vB_Types
  • Reference to singleton instance of the type handler

at line 179
protected loadTypes()

Ensures the type information is loaded.

at line 204
protected array getTypeInfo()

Builds the type info cache.

Return Value

array mixed - Assoc array of type info

at line 230
array getAggregatorTypeIds()

This gives up a list of the Aggregator types.

Return Value

array of ID

at line 266
array getNonAggregatorTypeIds()

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

Return Value

array of ID

at line 283
protected loadTypeInfo(array $type_info)

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

Parameters

array $type_info mixed $type_info - The type info cache data

at line 306
string getTypeKey(string $package, string $class)

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

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

Parameters

string $package
  • The package identifier
string $class
  • The class identifier

Return Value

string
  • The resulting single string unique key identifier

at line 322
protected loadPackages(array $type_info)

Loads package info from the type info cache.

Parameters

array $type_info mixed $type_info - The type info cache data

Exceptions

vB_Exception_Critical
  • Thrown if no packages are found

See also

vB_Core::buildTypeCache()

at line 356
int getPackageID(mixed $package)

Gets the numeric package id a package class string identifier.

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

Parameters

mixed $package
  • Class string identifier or numeric id of the package to check

Return Value

int | false

at line 376
string getPackageClass(mixed $package)

Gets the class string identifier for a package.

Parameters

mixed $package
  • Class string identifier or numeric id of the package to check

Return Value

string

Exceptions

vB_Exception_Warning
  • Thrown if an invalid package was given

at line 394
assertPackage(mixed $package, vB_Exception $e = null)

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

Parameters

mixed $package
  • Class string identifier or numeric id of the package to check
vB_Exception $e
  • An alternative exception to throw

Exceptions

mixed
  • Thrown if the package was not valid

at line 410
packageEnabled(mixed $package)

Checks if a package is enabled.

Parameters

mixed $package
  • Class string identifier or numeric id of the package to check

at line 431
protected loadContentTypes(array $type_info)

Loads contenttype info from the type info cache.

Parameters

array $type_info mixed $type_info - The type info cache

Exceptions

vB_Exception_Critical
  • Thrown if no contenttypes were found

See also

vB_Core::buildTypeCache()

at line 474
int getContentTypeID(mixed $contenttype)

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

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

mixed $contenttype
  • Key, array(package, class) or numeric id of the contenttype

Return Value

int | false

at line 506
array getContentTypeClasses($contenttypes)

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

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

Parameters

$contenttypes

Return Value

array of conten type classes

at line 533
assertContentType(mixed $contenttype, vB_Exception $e = null)

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

Parameters

mixed $contenttype
  • Key, array(package, class) or numeric id of the contenttype
vB_Exception $e
  • An alternative exception to throw

Exceptions

mixed
  • Thrown if the given contenttype is not valid

at line 552
string getContentTypePackage(mixed $contenttype)

Gets the package class string identifier for a contenttype

Parameters

mixed $contenttype
  • Key, array(package, class) or numeric id of the contenttype

Return Value

string
  • The class string of the package

at line 571
int getContentTypePackageID(mixed $contenttype)

Gets the package id for a contenttype

Parameters

mixed $contenttype
  • Key, array(package, class) or numeric id of the contenttype

Return Value

int
  • The integer id of the package that the contenttype belongs to

at line 587
string getContentTypeClass(mixed $contenttype)

Gets the class string identifier for a contenttype.

Parameters

mixed $contenttype
  • Key, array(package, class) or numeric id of the contenttype

Return Value

string
  • The class string identifier of the given contenttype

at line 605
string getContentTypeTitle(mixed $contenttype)

Gets the user friendly title of a contenttype.

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

mixed $contenttype

Return Value

string

at line 622
string getUntitledContentTypeTitle(mixed $contenttype)

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

Parameters

mixed $contenttype

Return Value

string

at line 640
getContentClassFromId($contenttypeid)

Gets the class and package of a contenttypeid.

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

at line 654
bool contentTypeEnabled(mixed $contenttype)

Checks of a contenttype is enabled.

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

Parameters

mixed $contenttype
  • Key, array(package, class) or numeric id of the contenttype

Return Value

bool

at line 669
array getContentTypeCacheEvents()

Fetches the cache events that affect contenttypes.

Return Value

array string

at line 678
array getContentTypes()

Fetches all content types

Return Value

array Content types.

at line 687
array getSearchableContentTypes()

Fetches all searchable content types

Return Value

array Content types.

at line 696
array getAttachableContentTypes()

Fetches all attachable content types

Return Value

array Content types.

at line 704
reloadTypes()

This should only be called while in a