Sunteți pe pagina 1din 4

12/11/2019 Events Of Report - KoolReport Documentation

Home / Architecture / Events Of Report

Events
# Introduction
# Two Types of Events
# Register An Event
# List of Events
# OnBeforeServicesInit
# OnServicesInit
# OnInit
# OnBeforeSetup
# OnSetup
# OnInitDone
# OnBeforeRun
# OnRunEnd
# OnBeforeRender
# OnRenderEnd
# OnBeforeResourceAttached
# OnResourceAttached
# OnResourceInit
# OnBeforeWidgetInit
# OnWidgetInit
# OnBeforeWidgetRender
# OnWidgetRender

Introduction #
During report life cycle, report will emit certain events. This is extremely useful for debugging, service add-on functioning and event
processing.

Two Types of Events #


There are two type of events:

1. Before: Emit right before something happens and has capability to prevent that thing to happen.
2. After: Emit right after something happens.

The events which emit before something happens normally has form of "OnBefore{SomethingHappens}" in their names.

Those events which emit after something happens normally has form of "On{SomethingHappens}" in their names.

Register An Event #
Bellow are common form to register events in KoolReport

https://www.koolreport.com/docs/architecture/events/#introduction 1/4
12/11/2019 Events Of Report - KoolReport Documentation

class MyReport extends \koolreport\KoolReport


{
...
protected function OnBeforeSetup()
{
// Happens when report is about to call setup() method

return true; // To allow setup() to run


}

protected function OnSetup()


{
//Happens when report has just run setup() method

}
}

List of Events #

OnBeforeServicesInit #
Emitted before KoolReport's services are initiated. Return true to approve action, return false to disapprove action.

protected function OnBeforeServicesInit()


{
echo "Services is about to init";
return true;
}

OnServicesInit #
Emitted after KoolReport's services are initiated.

protected function OnServicesInit()


{
echo "Services has been initiated";
}

OnInit #
Emitted after KoolReport is init, services are added but have not setup data processing.

protected function OnInit()


{
echo "Report has been initiated";
}

OnBeforeSetup #
Emitted before setting up the data process tree. Return true to approve action, return false to disapprove action.

protected function OnBeforeSetup()


{
echo "About to setup data process tree";
return true;
}

OnSetup #
Emitted after data processing tree is setup

https://www.koolreport.com/docs/architecture/events/#introduction 2/4
12/11/2019 Events Of Report - KoolReport Documentation

protected function OnSetup()


{
echo "Data processing tree has been setup";
}

OnInitDone #
Emitted after the initiation phase is completed

protected function OnInitDone()


{
echo "Report's initiation is completed";
}

OnBeforeRun #
Emitted before report is run. Return true to approve action, return false to disapprove action.

protected function OnBeforeRun()


{
echo "Report is about to run";
return true;
}

OnRunEnd #
Emitted after report is run

protected function OnRunEnd()


{
echo "Report has been run";
}

OnBeforeRender #
Emitted before report is rendered. Return true to approve action, return false to disapprove action.

protected function OnBeforeRender()


{
echo "Report is about to render";
return true;
}

OnRenderEnd #

OnBeforeResourceAttached #
Emitted before resource manager attaches resources to report's view. Return true to approve action, return false to disapprove action.

protected function OnBeforeResourceAttached()


{
echo "Report is about to have resource attached";
return true;
}

OnResourceAttached #
Emitted after resource manager attaches resources to report's view.

https://www.koolreport.com/docs/architecture/events/#introduction 3/4
12/11/2019 Events Of Report - KoolReport Documentation

protected function OnResourceAttached()


{
echo "Report has bad resouces attached";
}

OnResourceInit #
Emitted after resource manager is initiated.

protected function OnResourceInit()


{
echo "Resource manager is initiated";
}

OnBeforeWidgetInit #
Emitted before any widget is initiated. Return true to approve action, return false to disapprove action.

protected function OnBeforeWidgetInit($widget)


{
echo "[$widget->name] is about to init";
return true;
}

OnWidgetInit #
Emitted after widget is initiated

protected function OnWidgetInit($widget)


{
echo "[$widget->name] was initiated";
}

OnBeforeWidgetRender #
Emitted before any widget is rendered. Return true to approve action, return false to disapprove action.

protected function OnBeforeWidgetInit($widget)


{
echo "[$widget->name] is about to render";
return true;
}

OnWidgetRender #
Emitted after widget rendered

protected function OnWidgetRender($widget)


{
echo "[$widget->name] rendered";
}

 Assets settings DataSources - Overview 

KoolReport © 2019 KoolPHP Inc.  Contact Us

https://www.koolreport.com/docs/architecture/events/#introduction 4/4