This bundle provides a dashboard with customizable widgets.
composer require 2lenet/dashboard-bundle
Add this to services.yaml
App\Widgets\:
resource: '../src/Widgets'
tags: ['tkuska_dashboard.widget']
Add this to routes.yaml
dashboard_widgets:
resource: "@TkuskaDashboardBundle/Resources/config/routes.yaml"
You also need to update your database to have widget table.
php bin/console make:migration
php bin/console doc:mi:mi
All your widget classes will lie in src/Widgets/.
They must extend AbstractWidget.
use Tkuska\DashboardBundle\Widgets\AbstractWidget;
Existing methods that can be overriden:
You must implement the render() method.
This method returns simple HTML. You can use $twig->render("template.html.twig", array(...)). Your templates should extend the base widget template, because it has some interactions. Otherwise, make sure you implement those interactions.
{% extends '@TkuskaDashboard/widget/base_widget.html.twig' %}
Note that base template uses Bootstrap panels, which means it is better to put your widget body in a <div class="panel-body">.
If you use the widget configuration (getJsonSchema) you must pass the form to the template with getConfigForm as 'form'.
This method renders the widget that is shown. All your logic should be in there.
by default the cache is enable, you can change timeout and key with
public function getCacheKey():string{
return $this->getId() . "_".md5($this->config);
}
public function getCacheTimeout():int {
return 300;
}
above you see the default return.
If you want disable the cache for a widget getCacheTimeout have to return 0.
How can I help you explore Laravel packages today?