<?php
 namespace App\QuickReports\PivotTables\Source; abstract class GeneralAbstract { protected $dbTable = null; public function __construct() { $this->dbTable = $this->getDbTable(); if (!$this->dbTable) { throw new \Exception('No table name set for `'.__CLASS__.'`.'); } } abstract protected function getDbTable(); abstract protected function initializeFilters(); public function reloadData() { $pivotSource = stripClassNamespace(get_called_class()); $db = \DB::getInstance(); $pivotCfg = \App\QuickReports\PivotTables\Configs::getInstance($pivotSource); $cacheObj = new \Engine\Cache\DiskWithLRU(); $CFG = \Engine\Loader_Cfg::getInstance()->getGlobal(); $cacheObj->setPath($CFG['paths']['quickReportsCache']); $cacheObj->flush(); $this->checkFilters(); \DB::startTransaction(); $pivotCfg->status = 'populatingContent'; $pivotCfg->startPopulateTimestamp = time(); $pivotCfg->keepAliveTimestamp = null; $pivotCfg->finishPopulateTimestamp = null; \DB::commitTransaction(); $db->Execute("TRUNCATE TABLE `{$this->dbTable}`"); $this->populateData(); \DB::startTransaction(); $pivotCfg->status = 'ok'; $pivotCfg->finishPopulateTimestamp = time(); \DB::commitTransaction(); } abstract protected function checkFilters(); abstract protected function populateData(); protected function getPivotConfig() { $class = stripClassNamespace(get_called_class()); return \App\QuickReports\PivotTables\Configs::getInstance($class); } }