ApplicationStateController: Initalize `$autorefreshInterval`

Instead of defining it with the setter. This prevents the
user's preferences from having an effect on this route.
This commit is contained in:
Johannes Meyer 2020-12-07 16:01:57 +01:00
parent f1dd69d877
commit accbd9d847
2 changed files with 21 additions and 4 deletions

View File

@ -17,6 +17,8 @@ class ApplicationStateController extends Controller
{ {
protected $requiresAuthentication = false; protected $requiresAuthentication = false;
protected $autorefreshInterval = 60;
public function init() public function init()
{ {
$this->_helper->layout->disableLayout(); $this->_helper->layout->disableLayout();
@ -63,8 +65,6 @@ class ApplicationStateController extends Controller
} }
} }
} }
$this->setAutorefreshInterval(60, true);
} }
public function summaryAction() public function summaryAction()
@ -72,8 +72,6 @@ class ApplicationStateController extends Controller
if ($this->Auth()->isAuthenticated()) { if ($this->Auth()->isAuthenticated()) {
$this->getResponse()->setBody((string) Widget::create('ApplicationStateMessages')); $this->getResponse()->setBody((string) Widget::create('ApplicationStateMessages'));
} }
$this->setAutorefreshInterval(60, true);
} }
public function acknowledgeMessageAction() public function acknowledgeMessageAction()

View File

@ -64,6 +64,13 @@ class ActionController extends Zend_Controller_Action
*/ */
protected $moduleName; protected $moduleName;
/**
* A page's automatic refresh interval
*
* The initial value will not be subject to a user's preferences.
*
* @var int
*/
protected $autorefreshInterval; protected $autorefreshInterval;
protected $reloadCss = false; protected $reloadCss = false;
@ -341,6 +348,18 @@ class ActionController extends Zend_Controller_Action
} }
} }
/**
* Set the interval (in seconds) at which the page should automatically refresh
*
* This may be adjusted based on the user's preferences. The result could be a
* lower or higher rate of the page's automatic refresh. If this is not desired,
* the only way to bypass this is to initialize the {@see ActionController::$autorefreshInterval}
* property or to set the `autorefreshInterval` property of the layout directly.
*
* @param int $interval
*
* @return $this
*/
public function setAutorefreshInterval($interval) public function setAutorefreshInterval($interval)
{ {
if (! is_int($interval) || $interval < 1) { if (! is_int($interval) || $interval < 1) {