Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Zend_ProgressBar Class Reference

Public Member Functions

 __construct (Zend_ProgressBar_Adapter $adapter, $min=0, $max=100, $persistenceNamespace=null)
 
 getAdapter ()
 
 update ($value=null, $text=null)
 
 next ($diff=1, $text=null)
 
 finish ()
 

Protected Attributes

 $_min
 
 $_max
 
 $_current
 
 $_startTime
 
 $_statusText = null
 
 $_adapter
 
 $_persistenceNamespace = null
 

Detailed Description

Definition at line 28 of file ProgressBar.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Zend_ProgressBar_Adapter  $adapter,
  $min = 0,
  $max = 100,
  $persistenceNamespace = null 
)

Create a new progressbar backend.

Parameters
Zend_ProgressBar_Adapter$adapter
float$min
float$max
string$persistenceNamespace
Exceptions
Zend_ProgressBar_ExceptionWhen $min is greater than $max

Definition at line 88 of file ProgressBar.php.

89  {
90  // Check min/max values and set them
91  if ($min > $max) {
92  #require_once 'Zend/ProgressBar/Exception.php';
93  throw new Zend_ProgressBar_Exception('$max must be greater than $min');
94  }
95 
96  $this->_min = (float) $min;
97  $this->_max = (float) $max;
98  $this->_current = (float) $min;
99 
100  // See if we have to open a session namespace
101  if ($persistenceNamespace !== null) {
102  #require_once 'Zend/Session/Namespace.php';
103 
104  $this->_persistenceNamespace = new Zend_Session_Namespace($persistenceNamespace);
105  }
106 
107  // Set adapter
108  $this->_adapter = $adapter;
109 
110  // Track the start time
111  $this->_startTime = time();
112 
113  // See If a persistenceNamespace exists and handle accordingly
114  if ($this->_persistenceNamespace !== null) {
115  if (isset($this->_persistenceNamespace->isSet)) {
116  $this->_startTime = $this->_persistenceNamespace->startTime;
117  $this->_current = $this->_persistenceNamespace->current;
118  $this->_statusText = $this->_persistenceNamespace->statusText;
119  } else {
120  $this->_persistenceNamespace->isSet = true;
121  $this->_persistenceNamespace->startTime = $this->_startTime;
122  $this->_persistenceNamespace->current = $this->_current;
123  $this->_persistenceNamespace->statusText = $this->_statusText;
124  }
125  } else {
126  $this->update();
127  }
128  }
update($value=null, $text=null)
$adapter
Definition: webapi_user.php:16

Member Function Documentation

◆ finish()

finish ( )

Call the adapters finish() behaviour

Returns
void

Definition at line 201 of file ProgressBar.php.

202  {
203  if ($this->_persistenceNamespace !== null) {
204  unset($this->_persistenceNamespace->isSet);
205  }
206 
207  $this->_adapter->finish();
208  }

◆ getAdapter()

getAdapter ( )

Get the current adapter

Returns
Zend_ProgressBar_Adapter

Definition at line 135 of file ProgressBar.php.

136  {
137  return $this->_adapter;
138  }

◆ next()

next (   $diff = 1,
  $text = null 
)

Update the progressbar to the next value

Parameters
string$text
Returns
void

Definition at line 191 of file ProgressBar.php.

192  {
193  $this->update(max($this->_min, min($this->_max, $this->_current + $diff)), $text);
194  }
update($value=null, $text=null)
endifif( $block->getLastPageNum()>1)( 'Page') ?></strong >< ul class $text
Definition: pager.phtml:43

◆ update()

update (   $value = null,
  $text = null 
)

Update the progressbar

Parameters
float$value
string$text
Returns
void

Definition at line 147 of file ProgressBar.php.

148  {
149  // Update value if given
150  if ($value !== null) {
151  $this->_current = min($this->_max, max($this->_min, $value));
152  }
153 
154  // Update text if given
155  if ($text !== null) {
156  $this->_statusText = $text;
157  }
158 
159  // See if we have to update a namespace
160  if ($this->_persistenceNamespace !== null) {
161  $this->_persistenceNamespace->current = $this->_current;
162  $this->_persistenceNamespace->statusText = $this->_statusText;
163  }
164 
165  // Calculate percent
166  if ($this->_min === $this->_max) {
167  $percent = false;
168  } else {
169  $percent = (float) ($this->_current - $this->_min) / ($this->_max - $this->_min);
170  }
171 
172  // Calculate ETA
173  $timeTaken = time() - $this->_startTime;
174 
175  if ($percent === .0 || $percent === false) {
176  $timeRemaining = null;
177  } else {
178  $timeRemaining = round(((1 / $percent) * $timeTaken) - $timeTaken);
179  }
180 
181  // Poll the adapter
182  $this->_adapter->notify($this->_current, $this->_max, $percent, $timeTaken, $timeRemaining, $this->_statusText);
183  }
if($this->helper('Magento\Tax\Helper\Data') ->displayFullSummary()) foreach( $block->getTotal() ->getFullInfo() as $info)(isset($info['hidden']) && $info['hidden']) $percent
Definition: tax.phtml:33
endifif( $block->getLastPageNum()>1)( 'Page') ?></strong >< ul class $text
Definition: pager.phtml:43
$value
Definition: gender.phtml:16

Field Documentation

◆ $_adapter

$_adapter
protected

Definition at line 70 of file ProgressBar.php.

◆ $_current

$_current
protected

Definition at line 49 of file ProgressBar.php.

◆ $_max

$_max
protected

Definition at line 42 of file ProgressBar.php.

◆ $_min

$_min
protected

Definition at line 35 of file ProgressBar.php.

◆ $_persistenceNamespace

$_persistenceNamespace = null
protected

Definition at line 77 of file ProgressBar.php.

◆ $_startTime

$_startTime
protected

Definition at line 56 of file ProgressBar.php.

◆ $_statusText

$_statusText = null
protected

Definition at line 63 of file ProgressBar.php.


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