TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
Registry Class Reference
Inheritance diagram for Registry:
SingletonInterface

Public Member Functions

 get ($namespace, $key, $defaultValue=null)
 
 set ($namespace, $key, $value)
 
 remove ($namespace, $key)
 
 removeAllByNamespace ($namespace)
 

Protected Member Functions

 isNamespaceLoaded ($namespace)
 
 loadEntriesByNamespace ($namespace)
 
 validateNamespace ($namespace)
 

Protected Attributes

 $entries = []
 
 $loadedNamespaces = []
 

Detailed Description

A class to store and retrieve entries in a registry database table.

This is a simple, persistent key-value-pair store.

The intention is to have a place where we can store things (mainly settings) that should live for more than one request, longer than a session, and that shouldn't expire like it would with a cache. You can actually think of it being like the Windows Registry in some ways.

Definition at line 30 of file Registry.php.

Member Function Documentation

get (   $namespace,
  $key,
  $defaultValue = null 
)

Returns a persistent entry.

Parameters
string$namespaceExtension key of extension
string$keyKey of the entry to return.
mixed$defaultValueOptional default value to use if this entry has never been set. Defaults to NULL.
Returns
mixed Value of the entry.
Exceptions
InvalidArgumentException Throws an exception if the given namespace is not valid

Definition at line 51 of file Registry.php.

References Registry\isNamespaceLoaded(), Registry\loadEntriesByNamespace(), and Registry\validateNamespace().

isNamespaceLoaded (   $namespace)
protected

check if the given namespace is loaded

Parameters
string$namespaceExtension key of extension
Returns
bool True if namespace was loaded already

Definition at line 148 of file Registry.php.

Referenced by Registry\get(), and Registry\set().

loadEntriesByNamespace (   $namespace)
protected

Loads all entries of given namespace into the internal $entries cache.

Parameters
string$namespaceExtension key of extension
Returns
void
Exceptions
InvalidArgumentException Thrown if given namespace is invalid

Definition at line 160 of file Registry.php.

References GeneralUtility\makeInstance(), and Registry\validateNamespace().

Referenced by Registry\get(), and Registry\set().

remove (   $namespace,
  $key 
)

Unset a persistent entry.

Parameters
string$namespaceExtension key of extension
string$keyThe key of the entry to unset.
Returns
void
Exceptions
InvalidArgumentException Throws an exception if the given namespace is not valid

Definition at line 111 of file Registry.php.

References GeneralUtility\makeInstance(), and Registry\validateNamespace().

removeAllByNamespace (   $namespace)

Unset all persistent entries of given namespace.

Parameters
string$namespaceExtension key of extension
Returns
void
Exceptions
InvalidArgumentException Throws an exception if given namespace is invalid

Definition at line 130 of file Registry.php.

References GeneralUtility\makeInstance(), and Registry\validateNamespace().

set (   $namespace,
  $key,
  $value 
)

Sets a persistent entry.

This is the main method that can be used to store a key-value-pair.

Do not store binary data into the registry, it's not build to do that, instead use the proper way to store binary data: The filesystem.

Parameters
string$namespaceExtension key of extension
string$keyThe key of the entry to set.
mixed$valueThe value to set. This can be any PHP data type; This class takes care of serialization
Returns
void
Exceptions
InvalidArgumentException Throws an exception if the given namespace is not valid

Definition at line 74 of file Registry.php.

References Registry\isNamespaceLoaded(), Registry\loadEntriesByNamespace(), GeneralUtility\makeInstance(), and Registry\validateNamespace().

validateNamespace (   $namespace)
protected

Check namespace key It must be at least two characters long. The word 'core' is reserved for TYPO3 core usage.

Parameters
string$namespaceNamespace
Returns
void
Exceptions
InvalidArgumentException Thrown if given namespace is invalid

Definition at line 185 of file Registry.php.

Referenced by Registry\get(), Registry\loadEntriesByNamespace(), Registry\remove(), Registry\removeAllByNamespace(), and Registry\set().

Member Data Documentation

$entries = []
protected

Definition at line 35 of file Registry.php.

$loadedNamespaces = []
protected

Definition at line 40 of file Registry.php.