Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
Zend_Memory_Container_Movable Class Reference
Inheritance diagram for Zend_Memory_Container_Movable:
Zend_Memory_Container Zend_Memory_Container_Interface

Public Member Functions

 __construct (Zend_Memory_Manager $memoryManager, $id, $value)
 
 lock ()
 
 unlock ()
 
 isLocked ()
 
 __get ($property)
 
 __set ($property, $value)
 
getRef ()
 
 touch ()
 
 processUpdate ()
 
 startTrace ()
 
 setValue ($value)
 
 unloadValue ()
 
 markAsSwapped ()
 
 isSwapped ()
 
 getId ()
 
 destroy ()
 

Data Fields

const LOADED = 1
 
const SWAPPED = 2
 
const LOCKED = 4
 

Protected Attributes

 $_id
 

Detailed Description

Definition at line 38 of file Movable.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Zend_Memory_Manager  $memoryManager,
  $id,
  $value 
)

Object constructor

Parameters
Zend_Memory_Manager$memoryManager
integer$id
string$value

Definition at line 79 of file Movable.php.

80  {
81  $this->_memManager = $memoryManager;
82  $this->_id = $id;
83  $this->_state = self::LOADED;
84  $this->_value = new Zend_Memory_Value($value, $this);
85  }
$id
Definition: fieldset.phtml:14
$value
Definition: gender.phtml:16

Member Function Documentation

◆ __get()

__get (   $property)

Get handler

Loads object if necessary and moves it to the top of loaded objects list. Swaps objects from the bottom of loaded objects list, if necessary.

Parameters
string$property
Returns
string
Exceptions
Zend_Memory_Exception

Definition at line 135 of file Movable.php.

136  {
137  if ($property != 'value') {
138  #require_once 'Zend/Memory/Exception.php';
139  throw new Zend_Memory_Exception('Unknown property: Zend_Memory_container::$' . $property);
140  }
141 
142  if ( !($this->_state & self::LOADED) ) {
143  $this->_memManager->load($this, $this->_id);
144  $this->_state |= self::LOADED;
145  }
146 
147  return $this->_value;
148  }

◆ __set()

__set (   $property,
  $value 
)

Set handler

Parameters
string$property
string$value
Exceptions
Zend_Exception

Definition at line 157 of file Movable.php.

158  {
159  if ($property != 'value') {
160  #require_once 'Zend/Memory/Exception.php';
161  throw new Zend_Memory_Exception('Unknown property: Zend_Memory_container::$' . $property);
162  }
163 
164  $this->_state = self::LOADED;
165  $this->_value = new Zend_Memory_Value($value, $this);
166 
167  $this->_memManager->processUpdate($this, $this->_id);
168  }
$value
Definition: gender.phtml:16

◆ destroy()

destroy ( )

Destroy memory container and remove it from memory manager list

We don't clean up swap because of performance considerations Cleaning is performed by Memory Manager destructor

Definition at line 288 of file Movable.php.

289  {
295  $this->_memManager->unlink($this, $this->_id);
296  }

◆ getId()

getId ( )

Get object id

Definition at line 279 of file Movable.php.

280  {
281  return $this->_id;
282  }

◆ getRef()

& getRef ( )

Get string value reference

Must be used for value access before PHP v 5.2 or may be used for performance considerations

Returns
&string

Implements Zend_Memory_Container_Interface.

Definition at line 179 of file Movable.php.

180  {
181  if ( !($this->_state & self::LOADED) ) {
182  $this->_memManager->load($this, $this->_id);
183  $this->_state |= self::LOADED;
184  }
185 
186  return $this->_value->getRef();
187  }

◆ isLocked()

isLocked ( )

Return true if object is locked

Returns
boolean

Implements Zend_Memory_Container_Interface.

Definition at line 120 of file Movable.php.

121  {
122  return $this->_state & self::LOCKED;
123  }

◆ isSwapped()

isSwapped ( )

Check if object is marked as swapped

Definition at line 268 of file Movable.php.

269  {
270  return $this->_state & self::SWAPPED;
271  }

◆ lock()

lock ( )

Lock object in memory.

Todo:
It's possible to set "value" container attribute to avoid modification tracing, while it's locked Check, if it's more effective

Implements Zend_Memory_Container_Interface.

Definition at line 90 of file Movable.php.

91  {
92  if ( !($this->_state & self::LOADED) ) {
93  $this->_memManager->load($this, $this->_id);
94  $this->_state |= self::LOADED;
95  }
96 
97  $this->_state |= self::LOCKED;
98 
104  }

◆ markAsSwapped()

markAsSwapped ( )

Mark, that object is swapped

Definition at line 256 of file Movable.php.

257  {
258  // Clear LOADED state bit
259  $this->_state |= self::LOADED;
260  }

◆ processUpdate()

processUpdate ( )

Process container value update. Must be called only by value object

Definition at line 205 of file Movable.php.

206  {
207  // Clear SWAPPED state bit
208  $this->_state &= ~self::SWAPPED;
209 
210  $this->_memManager->processUpdate($this, $this->_id);
211  }

◆ setValue()

setValue (   $value)

Set value (used by memory manager when value is loaded)

Definition at line 233 of file Movable.php.

234  {
235  $this->_value = new Zend_Memory_Value($value, $this);
236  }
$value
Definition: gender.phtml:16

◆ startTrace()

startTrace ( )

Start modifications trace

Definition at line 218 of file Movable.php.

219  {
220  if ( !($this->_state & self::LOADED) ) {
221  $this->_memManager->load($this, $this->_id);
222  $this->_state |= self::LOADED;
223  }
224 
225  $this->_value->startTrace();
226  }

◆ touch()

touch ( )

Signal, that value is updated by external code.

Should be used together with getRef()

Implements Zend_Memory_Container_Interface.

Definition at line 194 of file Movable.php.

195  {
196  $this->_memManager->processUpdate($this, $this->_id);
197  }

◆ unloadValue()

unloadValue ( )

Clear value (used by memory manager when value is swapped)

Definition at line 243 of file Movable.php.

244  {
245  // Clear LOADED state bit
246  $this->_state &= ~self::LOADED;
247 
248  $this->_value = null;
249  }

◆ unlock()

unlock ( )

Unlock object

Implements Zend_Memory_Container_Interface.

Definition at line 109 of file Movable.php.

110  {
111  // Clear LOCKED state bit
112  $this->_state &= ~self::LOCKED;
113  }

Field Documentation

◆ $_id

$_id
protected

Definition at line 44 of file Movable.php.

◆ LOADED

const LOADED = 1

Value states

Definition at line 61 of file Movable.php.

◆ LOCKED

const LOCKED = 4

Definition at line 63 of file Movable.php.

◆ SWAPPED

const SWAPPED = 2

Definition at line 62 of file Movable.php.


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