Initial xentral_oss_20.3.c9ffacf
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Widgets\DataTable\Feature;
|
||||
|
||||
use Xentral\Widgets\DataTable\DataTableInterface;
|
||||
|
||||
final class StateSaveFeature implements DataTableFeatureInterface
|
||||
{
|
||||
/** @var bool $enabled */
|
||||
private $enabled;
|
||||
|
||||
/** @var int $duration In seconds (0 = Forever) */
|
||||
private $duration;
|
||||
|
||||
/**
|
||||
* @param bool $enabled
|
||||
* @param int $duration
|
||||
*/
|
||||
public function __construct($enabled = true, $duration = 0)
|
||||
{
|
||||
$this->enabled = (bool)$enabled;
|
||||
$this->duration = (int)$duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataTableInterface $table
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function modifyTable(DataTableInterface $table)
|
||||
{
|
||||
// $options = $table->getOptions()->toArray();
|
||||
// $options['columns'] = $table->getColumns()->toArray();
|
||||
// $table->getOptions()->setOption('revision', md5(json_encode($options)));
|
||||
|
||||
$table->getOptions()->setOption('stateSave', $this->enabled);
|
||||
$table->getOptions()->setOption('stateDuration', $this->duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function enable()
|
||||
{
|
||||
$this->enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function disable()
|
||||
{
|
||||
$this->enabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled()
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDuration()
|
||||
{
|
||||
return $this->duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $duration
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDuration($duration)
|
||||
{
|
||||
$this->duration = (int)$duration;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user