Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Storage Class Reference
Inheritance diagram for Storage:
DataObject StorageInterface Storage

Public Member Functions

 __construct ($namespace='default', array $data=[])
 
 init (array $data)
 
 getNamespace ()
 
 getData ($key='', $clear=false)
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 

Protected Attributes

 $namespace
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Definition at line 10 of file Storage.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $namespace = 'default',
array  $data = [] 
)

Constructor

Parameters
string$namespace
array$data

Definition at line 25 of file Storage.php.

26  {
27  $this->namespace = $namespace;
28  parent::__construct($data);
29  }

Member Function Documentation

◆ getData()

getData (   $key = '',
  $clear = false 
)

Additional get data with clear mode

Parameters
string$key
bool$clear
Returns
mixed

Definition at line 58 of file Storage.php.

59  {
60  $data = parent::getData($key);
61  if ($clear && isset($this->_data[$key])) {
62  unset($this->_data[$key]);
63  }
64  return $data;
65  }

◆ getNamespace()

getNamespace ( )

{Get current storage namespace

Returns
string
}

Implements StorageInterface.

Definition at line 46 of file Storage.php.

47  {
48  return $this->namespace;
49  }

◆ init()

init ( array  $data)

{Initialize storage data

Parameters
array$data
Returns
$this
}

Implements StorageInterface.

Definition at line 34 of file Storage.php.

35  {
36  $namespace = $this->getNamespace();
37  if (isset($data[$namespace])) {
38  $this->setData($data[$namespace]);
39  }
40  $_SESSION[$namespace] = & $this->_data;
41  }
setData($key, $value=null)
Definition: DataObject.php:72

Field Documentation

◆ $namespace

$namespace
protected

Definition at line 17 of file Storage.php.


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