Hi, I'm attempting to create a basic widget from the documentation, my setup is as follows -
In the koolreports/widgets/mywidget folder
MyWidget.php
class MyWidget extends \koolreport\core\Widget
{
protected $dataStore;
public function onInit()
{
$this->dataStore = $this->params["dataStore"];
}
public function render()
{
$this->getAssetManager()->publish("my_widget_asset_folder");
$this->template("MyWidget",array(
"any_variable"=>$any_variable
));
}
static function create($params)
{
$widget = new MyWidget($params);
$widget->render();
}
}
MyWidget.tpl.php
echo $any_variable;
For the report itself
dataSource.php
require_once "../../../../koolreport/autoload.php";
use \koolreport\KoolReport;
use \koolreport\processes\Filter;
use \koolreport\processes\TimeBucket;
use \koolreport\processes\Group;
use \koolreport\processes\Limit;
class DataSource extends KoolReport
{
public function settings()
{
return array(
"dataSources"=>array(
"celebrities_data"=>array(
"class"=>'\koolreport\datasources\ArrayDataSource',
"dataFormat"=>"associate",
"data"=>array(
array("customerName"=>"Johny Deep","dollar_sales"=>100),
array("customerName"=>"Angelina Jolie","dollar_sales"=>200),
array("customerName"=>"Brad Pitt","dollar_sales"=>200),
array("customerName"=>"Nocole Kidman","dollar_sales"=>100),
)
),
)
);
}
protected function setup()
{
$this->src('celebrities_data')
->pipe($this->dataStore('data'));
}
}
dataSource.view.php
use \koolreport\widgets\mywidget\MyWidget;
MyWidget::create(array(
"dataStore"=>$this->dataStore('data'),
"any_variable"=>"value"
));
When I run the report I receive the following error -
"Warning: Declaration of MyWidget::create($params) should be compatible with koolreport\core\Widget::create($params, $return = false) in C:\xampp\htdocs\koolreport\koolreport\widgets\mywidget\MyWidget.php on line 3
Fatal error: Uncaught Error: Class 'koolreport\widgets\mywidget\MyWidget' not found in C:\xampp\htdocs\koolreport\examples\reports\basic\dataSource\dataSource.view.php:12 Stack trace: #0 C:\xampp\htdocs\koolreport\koolreport\KoolReport.php(303): include() #1 C:\xampp\htdocs\koolreport\examples\reports\basic\dataSource\index.php(18): koolreport\KoolReport->render() #2 {main} thrown in C:\xampp\htdocs\koolreport\examples\reports\basic\dataSource\dataSource.view.php on line 12"
My guess is that I am not calling the widget correctly, but I am not exactly sure. Just trying to get a basic widget passing data to work. Any help much appreciated.