1
0
Fork 0
mirror of synced 2024-06-15 01:04:51 +12:00

feat(Database): introduce enabling/disabling filters

This commit is contained in:
Torsten Dittmann 2021-01-15 12:56:39 +01:00
parent 538510d171
commit bda5e13ac0

View file

@ -57,6 +57,11 @@ class Database
*/
static protected $filters = [];
/**
* @var bool
*/
static protected $statusFilters = true;
/**
* @var array
*/
@ -448,6 +453,26 @@ class Database
];
}
/**
* Disable Attribute decoding
*
* @return void
*/
public static function disableFilters(): void
{
self::$statusFilters = false;
}
/**
* Enable Attribute decoding
*
* @return void
*/
public static function enableFilters(): void
{
self::$statusFilters = true;
}
public function encode(Document $document):Document
{
$collection = $this->getDocument($document->getCollection(), true , false);
@ -550,6 +575,10 @@ class Database
*/
static protected function decodeAttribute(string $name, $value)
{
if (!self::$statusFilters) {
return $value;
}
if (!isset(self::$filters[$name])) {
return $value;
throw new Exception('Filter not found');