TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Core\Registry Class Reference
Inheritance diagram for TYPO3\CMS\Core\Registry:
TYPO3\CMS\Core\SingletonInterface t3lib_Registry

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 = array()
 
 $loadedNamespaces = array()
 

Detailed Description

This file is part of the TYPO3 CMS project.

It is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, either version 2 of the License, or any later version.

For the full copyright and license information, please read the LICENSE.txt file that was distributed with this source code.

The TYPO3 project - inspiring people to share! A class to store and retrieve entries in a registry database table.

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.

Credits: Heavily inspired by Drupal's variable_*() functions.

Author
Ingo Renner ingo@.nosp@m.typo.nosp@m.3.org
Bastian Waidelich basti.nosp@m.an@t.nosp@m.ypo3..nosp@m.org

Definition at line 29 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 for extensions starting with 'tx_' / 'Tx_' / 'user_' or 'core' for core registry entries
string$keyThe key of the entry to return.
mixed$defaultValueOptional default value to use if this entry has never been set. Defaults to NULL.
Returns
mixed The value of the entry.
Exceptions

Definition at line 50 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$namespaceNamespace. extension key for extensions or 'core' for core registry entries
Returns
bool

Definition at line 130 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 the given namespace into the internal $entries cache.

Parameters
string$namespaceNamespace. extension key for extensions or 'core' for core registry entries
Returns
void
Exceptions

Definition at line 141 of file Registry.php.

References $GLOBALS, 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 
)

Unsets a persistent entry.

Parameters
string$namespaceNamespace. extension key for extensions or 'core' for core registry entries
string$keyThe key of the entry to unset.
Returns
void
Exceptions

Definition at line 104 of file Registry.php.

References $GLOBALS, and TYPO3\CMS\Core\Registry\validateNamespace().

◆ removeAllByNamespace()

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

Unsets all persistent entries of the given namespace.

Parameters
string$namespaceNamespace. extension key for extensions or 'core' for core registry entries
Returns
void
Exceptions

Definition at line 117 of file Registry.php.

References $GLOBALS, 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. It is name spaced with a unique string. This name space should be chosen from extensions that it is unique. It is advised to use something like 'tx_extensionname'. The prefix 'core' is reserved for the TYPO3 core.

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 for extensions starting with 'tx_' / 'Tx_' / 'user_' or 'core' for core registry entries.
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 if necessary.
Returns
void
Exceptions

Definition at line 75 of file Registry.php.

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

◆ validateNamespace()

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

Checks the given namespace. It must be at least two characters long. The word 'core' is reserved for TYPO3 core usage.

If it does not have a valid format an exception is thrown.

Parameters
string$namespaceNamespace
Returns
void
Exceptions

Definition at line 162 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 = array()
protected

Definition at line 34 of file Registry.php.

◆ $loadedNamespaces

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

Definition at line 39 of file Registry.php.