Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions | Static Protected Member Functions
Zend_Registry Class Reference
Inheritance diagram for Zend_Registry:

Public Member Functions

 __construct ($array=array(), $flags=parent::ARRAY_AS_PROPS)
 
 offsetExists ($index)
 

Static Public Member Functions

static getInstance ()
 
static setInstance (Zend_Registry $registry)
 
static setClassName ($registryClassName='Zend_Registry')
 
static _unsetInstance ()
 
static get ($index)
 
static set ($index, $value)
 
static isRegistered ($index)
 

Static Protected Member Functions

static init ()
 

Detailed Description

Definition at line 30 of file Registry.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $array = array(),
  $flags = parent::ARRAY_AS_PROPS 
)

Constructs a parent ArrayObject with default ARRAY_AS_PROPS to allow acces as an object

Parameters
array$arraydata array
integer$flagsArrayObject flags

Definition at line 193 of file Registry.php.

194  {
195  parent::__construct($array, $flags);
196  }

Member Function Documentation

◆ _unsetInstance()

static _unsetInstance ( )
static

Unset the default registry instance. Primarily used in tearDown() in unit tests.

Returns
void

Definition at line 125 of file Registry.php.

126  {
127  self::$_registry = null;
128  }

◆ get()

static get (   $index)
static

getter method, basically same as offsetGet().

This method can be called from an object of type Zend_Registry, or it can be called statically. In the latter case, it uses the default static instance stored in the class.

Parameters
string$index- get the value associated with $index
Returns
mixed
Exceptions
Zend_Exceptionif no entry is registered for $index.

Definition at line 141 of file Registry.php.

142  {
143  $instance = self::getInstance();
144 
145  if (!$instance->offsetExists($index)) {
146  #require_once 'Zend/Exception.php';
147  throw new Zend_Exception("No entry is registered for key '$index'");
148  }
149 
150  return $instance->offsetGet($index);
151  }
static getInstance()
Definition: Registry.php:49
$index
Definition: list.phtml:44

◆ getInstance()

static getInstance ( )
static

Retrieves the default registry instance.

Returns
Zend_Registry

Definition at line 49 of file Registry.php.

50  {
51  if (self::$_registry === null) {
52  self::init();
53  }
54 
55  return self::$_registry;
56  }
static init()
Definition: Registry.php:82

◆ init()

static init ( )
staticprotected

Initialize the default registry instance.

Returns
void

Definition at line 82 of file Registry.php.

83  {
84  self::setInstance(new self::$_registryClassName());
85  }
static setInstance(Zend_Registry $registry)
Definition: Registry.php:66

◆ isRegistered()

static isRegistered (   $index)
static

Returns TRUE if the $index is a named value in the registry, or FALSE if $index was not found in the registry.

Parameters
string$index
Returns
boolean

Definition at line 178 of file Registry.php.

179  {
180  if (self::$_registry === null) {
181  return false;
182  }
183  return self::$_registry->offsetExists($index);
184  }
$index
Definition: list.phtml:44

◆ offsetExists()

offsetExists (   $index)
Parameters
string$index
Returns
mixed

Workaround for http://bugs.php.net/bug.php?id=40442 (ZF-960).

Definition at line 204 of file Registry.php.

205  {
206  return array_key_exists($index, $this);
207  }
$index
Definition: list.phtml:44

◆ set()

static set (   $index,
  $value 
)
static

setter method, basically same as offsetSet().

This method can be called from an object of type Zend_Registry, or it can be called statically. In the latter case, it uses the default static instance stored in the class.

Parameters
string$indexThe location in the ArrayObject in which to store the value.
mixed$valueThe object to store in the ArrayObject.
Returns
void

Definition at line 165 of file Registry.php.

166  {
167  $instance = self::getInstance();
168  $instance->offsetSet($index, $value);
169  }
$value
Definition: gender.phtml:16
static getInstance()
Definition: Registry.php:49
$index
Definition: list.phtml:44

◆ setClassName()

static setClassName (   $registryClassName = 'Zend_Registry')
static

Set the class name to use for the default registry instance. Does not affect the currently initialized instance, it only applies for the next time you instantiate.

Parameters
string$registryClassName
Returns
void
Exceptions
Zend_Exceptionif the registry is initialized or if the class name is not valid.
See also
Zend_Loader

Definition at line 97 of file Registry.php.

98  {
99  if (self::$_registry !== null) {
100  #require_once 'Zend/Exception.php';
101  throw new Zend_Exception('Registry is already initialized');
102  }
103 
104  if (!is_string($registryClassName)) {
105  #require_once 'Zend/Exception.php';
106  throw new Zend_Exception("Argument is not a class name");
107  }
108 
112  if (!class_exists($registryClassName)) {
113  #require_once 'Zend/Loader.php';
114  Zend_Loader::loadClass($registryClassName);
115  }
116 
117  self::$_registryClassName = $registryClassName;
118  }
static loadClass($class, $dirs=null)
Definition: Loader.php:52

◆ setInstance()

static setInstance ( Zend_Registry  $registry)
static

Set the default registry instance to a specified instance.

Parameters
Zend_Registry$registryAn object instance of type Zend_Registry, or a subclass.
Returns
void
Exceptions
Zend_Exceptionif registry is already initialized.

Definition at line 66 of file Registry.php.

67  {
68  if (self::$_registry !== null) {
69  #require_once 'Zend/Exception.php';
70  throw new Zend_Exception('Registry is already initialized');
71  }
72 
73  self::setClassName(get_class($registry));
74  self::$_registry = $registry;
75  }
static setClassName($registryClassName='Zend_Registry')
Definition: Registry.php:97

The documentation for this class was generated from the following file: