TYPO3 CMS  TYPO3_8-7
TYPO3\CMS\Core\Registry Class Reference
Inheritance diagram for TYPO3\CMS\Core\Registry:
TYPO3\CMS\Core\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 31 of file Registry.php.

Member Function Documentation

◆ get()

TYPO3\CMS\Core\Registry::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

Definition at line 52 of file Registry.php.

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

◆ isNamespaceLoaded()

TYPO3\CMS\Core\Registry::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 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$namespaceExtension key of extension
Exceptions

Definition at line 159 of file Registry.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), and 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$namespaceExtension key of extension
string$keyThe key of the entry to unset.
Exceptions

Definition at line 112 of file Registry.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), and TYPO3\CMS\Core\Registry\validateNamespace().

◆ removeAllByNamespace()

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

Unset all persistent entries of given namespace.

Parameters
string$namespaceExtension key of extension
Exceptions

Definition at line 130 of file Registry.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), and 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$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
Exceptions

Definition at line 74 of file Registry.php.

References TYPO3\CMS\Core\Registry\isNamespaceLoaded(), TYPO3\CMS\Core\Registry\loadEntriesByNamespace(), TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), 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$namespaceNamespace
Exceptions

Definition at line 183 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

TYPO3\CMS\Core\Registry::$entries = []
protected

Definition at line 36 of file Registry.php.

◆ $loadedNamespaces

TYPO3\CMS\Core\Registry::$loadedNamespaces = []
protected

Definition at line 41 of file Registry.php.