CustomEngine

This class is responsible for creating the report. An instance of this class depends on an instance of 'ReportOptions' class to pass all needed report options. To use this class you need to import it, as shown:

# Example Native PHP

 
            
use SRE\Engine\CustomEngine;
use SRE\Engine\ReportOptions;
require_once  "../sre_bootstrap.php";
try{
$report = new ReportOptions(SRE_PUBLIC_REPORT);
$report->select_tables(array("items"))
       ->set_grouping(array("country"))
       ->select_all_fields();
$engine = new CustomEngine($report);
$report_path = $engine->create_report();
 echo "Your report URL:" . $report_path;
}catch (Exception $ex) {
 echo "Caught exception message:  ".  $ex->getMessage();
}
          

# Example Laravel

 
          
            namespace App\Services;
 
            use Sre\SmartReportingEngine\src\Engine\Constants;
            use Sre\SmartReportingEngine\src\Engine\CustomEngine;
            use Sre\SmartReportingEngine\src\Engine\ReportOptions;

            class ReportService {

                public function generatePublicReport() {
                    
                     try{
                    $report = new ReportOptions(Constants::SRE_PUBLIC_REPORT);
                    $report->select_tables(array("items"))
                           ->set_grouping(array("country"))
                           ->select_all_fields();
                    $engine = new CustomEngine($report);
                    $report_path = $engine->create_report();
                      echo "Your report URL:" . $report_path;
                    }catch (Exception $ex) {
                      echo "Caught exception message:".  $ex->getMessage();
                    }                  

                }
            }

          
Method Description
__constructThis method is the class constructor, it's called when an instance of the 'CustomEngine' class is created, it requires an instance of 'ReportOptions' class to pass all needed report options.
create_reportThis method is responsible for actually creating the report. Before doing this, it validates the report options and throws exceptions if there is a problem.