‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Registry Class Reference
Inheritance diagram for TYPO3\CMS\Core\Registry:
TYPO3\CMS\Core\SingletonInterface

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

array $entries = array( )
 
array $loadedNamespaces = array( )
 

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 32 of file Registry.php.

Member Function Documentation

◆ get()

mixed TYPO3\CMS\Core\Registry::get (   $namespace,
  $key,
  $defaultValue = null 
)

Returns a persistent entry.

Parameters
string$namespace‪Extension key of extension
string$key‪Key of the entry to return.
mixed$defaultValue‪Optional default value to use if this entry has never been set. Defaults to NULL.
Returns
‪mixed Value of the entry.
Exceptions

Definition at line 51 of file Registry.php.

References TYPO3\CMS\Core\Registry\isNamespaceLoaded(), TYPO3\CMS\Core\Registry\loadEntriesByNamespace(), and TYPO3\CMS\Core\Registry\validateNamespace().

◆ isNamespaceLoaded()

bool TYPO3\CMS\Core\Registry::isNamespaceLoaded (   $namespace)
protected

check if the given namespace is loaded

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

Definition at line 147 of file Registry.php.

Referenced by TYPO3\CMS\Core\Registry\get(), and TYPO3\CMS\Core\Registry\set().

◆ loadEntriesByNamespace()

TYPO3\CMS\Core\Registry::loadEntriesByNamespace (   $namespace)
protected

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

Parameters
string$namespace‪Extension key of extension
Exceptions

Definition at line 158 of file Registry.php.

References TYPO3\CMS\Core\Registry\validateNamespace().

Referenced by TYPO3\CMS\Core\Registry\get(), and TYPO3\CMS\Core\Registry\set().

◆ remove()

TYPO3\CMS\Core\Registry::remove (   $namespace,
  $key 
)

Unset a persistent entry.

Parameters
string$namespace‪Extension key of extension
string$key‪The key of the entry to unset.
Exceptions

Definition at line 111 of file Registry.php.

References TYPO3\CMS\Core\Registry\validateNamespace().

◆ removeAllByNamespace()

TYPO3\CMS\Core\Registry::removeAllByNamespace (   $namespace)

Unset all persistent entries of given namespace.

Parameters
string$namespace‪Extension key of extension
Exceptions

Definition at line 129 of file Registry.php.

References TYPO3\CMS\Core\Registry\validateNamespace().

◆ set()

TYPO3\CMS\Core\Registry::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$namespace‪Extension key of extension
string$key‪The key of the entry to set.
mixed$value‪The value to set. This can be any PHP data type; This class takes care of serialization
Exceptions

Definition at line 73 of file Registry.php.

References TYPO3\CMS\Core\Registry\isNamespaceLoaded(), TYPO3\CMS\Core\Registry\loadEntriesByNamespace(), TYPO3\CMS\Core\Database\Connection\PARAM_LOB, and TYPO3\CMS\Core\Registry\validateNamespace().

◆ validateNamespace()

TYPO3\CMS\Core\Registry::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$namespace‪Namespace
Exceptions

Definition at line 182 of file Registry.php.

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

Member Data Documentation

◆ $entries

array TYPO3\CMS\Core\Registry::$entries = array( )
protected

Definition at line 36 of file Registry.php.

◆ $loadedNamespaces

array TYPO3\CMS\Core\Registry::$loadedNamespaces = array( )
protected

Definition at line 40 of file Registry.php.