src/Table/Configure.php
<?php
/**
* Copyright (c) Allan Carvalho 2020.
* Under Mit License
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
*/
declare(strict_types = 1);
namespace DataTables\Table;
use Cake\Core\Configure as CakePhpConfigure;
/**
* Class Configure
* Created by allancarvalho in june 28, 2020
*/
class Configure {
/**
* @var \DataTables\Table\Configure
*/
private static $_instance;
/**
* @var bool
*/
private $columnAutoGeneratedWarning;
/**
* @var string
*/
private $storageEngine;
/**
* @var bool
*/
private $forceCache;
public function __construct() {
$this->setColumnAutoGeneratedWarning(CakePhpConfigure::read('DataTables.columnAutoGeneratedWarning'));
$this->setStorageEngine(CakePhpConfigure::read('DataTables.StorageEngine.class'));
$this->setForceCache(CakePhpConfigure::read('DataTables.StorageEngine.forceCache'));
}
/**
* Return a instance of builder object.
*
* @param bool $reset
* @return \DataTables\Table\Configure
*/
public static function getInstance(bool $reset = false) {
if (static::$_instance === null || $reset === true) {
static::$_instance = new self();
}
return static::$_instance;
}
/**
* Check if the table columns data is auto generated.
*
* @return bool
*/
public function isColumnAutoGeneratedWarning(): bool {
return $this->columnAutoGeneratedWarning;
}
/**
* Set if the plugin must show a blink alert when the table columns data is auto generated.
*
* @param bool $columnAutoGeneratedWarning
* @return $this
*/
public function setColumnAutoGeneratedWarning(bool $columnAutoGeneratedWarning) {
$this->columnAutoGeneratedWarning = $columnAutoGeneratedWarning;
return $this;
}
/**
* Get the current StorageEngine class FQN
*
* @return string
*/
public function getStorageEngine(): string {
return $this->storageEngine;
}
/**
* Set the StorageEngine class FQN
*
* @param string $storageEngine
* @return $this
*/
public function setStorageEngine(string $storageEngine) {
$this->storageEngine = $storageEngine;
return $this;
}
/**
* Check if the plugin must do the cache even debug is on.
*
* @return bool
*/
public function isForceCache(): bool {
return $this->forceCache;
}
/**
* Set if the plugin must do the cache even debug is on.
*
* @param bool $forceCache
* @return $this
*/
public function setForceCache(bool $forceCache) {
$this->forceCache = $forceCache;
return $this;
}
}