2014-06-20 07:48:17 -04:00
|
|
|
<?php
|
2016-02-08 09:41:00 -05:00
|
|
|
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
|
2014-06-20 07:48:17 -04:00
|
|
|
|
|
|
|
|
namespace Icinga\Web\Widget;
|
|
|
|
|
|
2015-11-12 07:04:52 -05:00
|
|
|
use Icinga\Forms\Control\LimiterControlForm;
|
2014-06-20 07:48:17 -04:00
|
|
|
|
|
|
|
|
/**
|
2015-11-12 07:04:52 -05:00
|
|
|
* Limiter control widget
|
2014-06-20 07:48:17 -04:00
|
|
|
*/
|
|
|
|
|
class Limiter extends AbstractWidget
|
|
|
|
|
{
|
2015-09-25 07:36:28 -04:00
|
|
|
/**
|
|
|
|
|
* Default limit for this instance
|
|
|
|
|
*
|
|
|
|
|
* @var int|null
|
|
|
|
|
*/
|
|
|
|
|
protected $defaultLimit;
|
2014-06-20 07:48:17 -04:00
|
|
|
|
2015-09-25 07:36:28 -04:00
|
|
|
/**
|
|
|
|
|
* Get the default limit
|
|
|
|
|
*
|
2015-11-12 07:04:52 -05:00
|
|
|
* @return int|null
|
2015-09-25 07:36:28 -04:00
|
|
|
*/
|
|
|
|
|
public function getDefaultLimit()
|
2014-06-20 07:48:17 -04:00
|
|
|
{
|
2015-11-12 07:04:52 -05:00
|
|
|
return $this->defaultLimit;
|
2014-06-20 07:48:17 -04:00
|
|
|
}
|
|
|
|
|
|
2015-09-25 07:36:28 -04:00
|
|
|
/**
|
|
|
|
|
* Set the default limit
|
|
|
|
|
*
|
|
|
|
|
* @param int $defaultLimit
|
|
|
|
|
*
|
|
|
|
|
* @return $this
|
|
|
|
|
*/
|
|
|
|
|
public function setDefaultLimit($defaultLimit)
|
2015-05-15 09:22:22 -04:00
|
|
|
{
|
2015-09-25 07:36:28 -04:00
|
|
|
$this->defaultLimit = (int) $defaultLimit;
|
2015-05-15 09:22:22 -04:00
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-25 07:36:28 -04:00
|
|
|
/**
|
|
|
|
|
* {@inheritdoc}
|
|
|
|
|
*/
|
2014-06-20 07:48:17 -04:00
|
|
|
public function render()
|
|
|
|
|
{
|
2015-11-12 07:04:52 -05:00
|
|
|
$control = new LimiterControlForm();
|
|
|
|
|
$control
|
|
|
|
|
->setDefaultLimit($this->defaultLimit)
|
|
|
|
|
->handleRequest();
|
|
|
|
|
return (string)$control;
|
2014-06-20 07:48:17 -04:00
|
|
|
}
|
|
|
|
|
}
|