@author   Vova Feldman (@svovaf)
@since    1.0.7

@param bool     $store
@param string[] $exceptions Set of keys to keep and not clear.
197873
function clear_all( $store = true, $exceptions = array() ) {
			$new_data = array();
			foreach ( $exceptions as $key ) {
				if ( isset( $this->_data[ $key ] ) ) {
					$new_data[ $key ] = $this->_data[ $key ];
				}
			}

			$this->_data = $new_data;

			if ( $store ) {
				$all_data                 = $this->get_all_data();
				$all_data[ $this->_secondary_id ] = $this->_data;
				$options_manager          = $this->get_option_manager();
				$options_manager->set_option( $this->_id, $all_data, true );
			}
		}
791113
public function assertIsTrue($value, $message='%s must be True', $exception='Asserts')
    {
        if (is_bool($value) === false || $value !== true) {
            $this->throwException($exception, $message, $value);
        }
    }
594645
public function isDebugModeOn($store = null)
    {
        return $this->getScopeConfig()->isSetFlag(
            self::XML_PATH_DEBUG,
            ScopeInterface::SCOPE_STORE,
            $store
        );
    }
1153568
public static function isOn($exception = false)
    {
        if (isset($_SESSION)) {
            return true;
        }

        exception_if($exception, SessionSurfaceIsOffException::class);

        return false;
    }
720201
public static function Exception ($exception, $exit = TRUE) {
		if (static::$originalDebugClass) {
			$dumpedValue = static::dumpHandler(
				$exception, NULL, ['bar' => !$exit, 'backtraceIndex' => 1]
			);
			if (static::$debugging) {
				echo $dumpedValue;
			} else {
				static::storeLogRecord($dumpedValue, \MvcCore\IDebug::EXCEPTION);
			}
		} else {
			@call_user_func_array(static::$handlers['exceptionHandler'], func_get_args());
		}
	}
305856
public function handleBatch(array $records)
	{
		foreach ($records as $key => $record) {
	        if ($this->isHandling($record)) {
	        	$record = $this->processRecord($record);
	    		$records['records'][] = $record;
	    	}

			unset($records[$key]);
	    }

	    $records['formatted'] = $this->getFormatter()->formatBatch($records['records'] ?? []);

	    $this->write($records);

	    return false === $this->bubble;
	}
864009
public function useStoreCreditConfig($store = null)
    {
        return $this->getScopeConfig()->isSetFlag(
            self::XML_PATH_STORE_CREDIT,
            ScopeInterface::SCOPE_STORE,
            $store
        );
    }
1294480
public function write($showDebug = false, $forceInsert = false, $forceWrite = false, $writeComponents = false)
    {
        throw new Exception("{$this->ClassName} can not be written back to the database.");
    }
1260024
public function exceptionHandler(Exception $exception)
    {
        $this->logger->addError($exception->getMessage(), array($exception->getFile(), $exception->getLine()));
        exit(-1);
    }
983009
private function _store_user( $store = true ) {
            $this->_logger->entrance();

            if ( empty( $this->_user->id ) ) {
                $this->_logger->error( "Empty user ID, can't store user." );

                return;
            }

            $users                     = self::get_all_users();
            $users[ $this->_user->id ] = $this->_user;
            self::$_accounts->set_option( 'users', $users, $store );
        }
622795
public function write($records)
    {
        // Array for tracking successfully harvested IDs:
        $harvestedIds = [];

        // Date of most recent record encountered:
        $endDate = 0;

        $this->strategy->beginWrite();

        // Loop through the records:
        foreach ($records as $record) {
            // Die if the record is missing its header:
            if (empty($record->header)) {
                throw new \Exception('Unexpected missing record header.');
            }

            // Get the ID of the current record:
            $id = $this->extractID($record);

            // Save the current record, either as a deleted or as a regular file:
            $attribs = $record->header->attributes();
            if (strtolower($attribs['status']) == 'deleted') {
                $this->strategy->addDeletedRecord($id);
            } else {
                $recordXML = $this->recordFormatter->format($id, $record);
                $this->strategy->addRecord($id, $recordXML);
                $harvestedIds[] = $id;
            }

            // If the current record's date is newer than the previous end date,
            // remember it for future reference:
            $date = $this->normalizeDate($record->header->datestamp);
            if ($date && $date > $endDate) {
                $endDate = $date;
            }
        }

        $this->strategy->endWrite();

        $this->writeHarvestedIdsLog($harvestedIds);

        return $endDate;
    }
1042690
public function forget($key)
    {
        list($baseKey, $searchKey) = $this->fetchKey($key);

        $registry = $this->get($baseKey);

        if ($registry === null) {
            $registry = $this->cache->get($baseKey);
        }

        if (is_null($registry)) {
            throw new Exception("Item [$key] does not exists");
        }

        if ($baseKey !== $searchKey)
        {
            array_forget($registry, $searchKey);
            $this->database->table($this->config['table'])->where('key', '=', $baseKey)->update(array('value' => json_encode($registry)));

            // Update cache
            $this->cache->add($baseKey, $registry);
        }
        else
        {
            $this->database->table($this->config['table'])->where('key', '=', $baseKey)->delete();

            // Remove from cache
            $this->cache->remove($baseKey);
        }

        return true;
    }
259260
public static function writeException(\Exception $ex)
	{
		$response = array(
			'exception' => get_class($ex),
			'message' => $ex->getMessage(),
			'code' => $ex->getCode(),
		);
		static::writeJson($response);
	}
179575
public function handle($exception)
    {
        $handlers = (array)$this->config('handlers');
        foreach ($handlers as $handler => $config) {
            $handlerClass = $handler;
            if (!class_exists($handlerClass)) {
                $handlerClass = 'Josegonzalez\ErrorHandlers\Handler\\' . $handler;
            }
            if (!class_exists($handlerClass)) {
                $handlerClass = 'Josegonzalez\ErrorHandlers\Handler\\' . $handler . 'Handler';
            }
            if (!class_exists($handlerClass)) {
                continue;
            }
            $instance = new $handlerClass((array)$config);
            $instance->handle($exception);
        }

        return false;
    }
778246
public function setExceptions(array $exceptions)
    {
        $this->exceptions = array();
        foreach ($exceptions as $exception) {
            $this->add($exception);
        }

        return $this;
    }
1280128
public function isActive($store = null)
    {
        return $this->getScopeConfig()->isSetFlag(
            self::XML_PATH_ACTIVE,
            ScopeInterface::SCOPE_STORE,
            $store
        );
    }
1064268
public static function get_record_by_contextid($contextid, $exception = true) {
        global $DB;

        if (!$record = $DB->get_record(self::TABLE, array('contextid' => $contextid))) {
            if (!$exception) {
                return false;
            } else {
                throw new \dml_missing_record_exception(self::TABLE);
            }
        }

        return new static(0, $record);
    }