cleanup global context usage in widgets

This commit is contained in:
Kevin Papst
2020-08-18 11:39:41 +02:00
parent 08696651fd
commit 9597015413
29 changed files with 458 additions and 202 deletions

View File

@@ -13,6 +13,7 @@ use App\Event\DashboardEvent;
use App\Widget\Type\AbstractContainer;
use App\Widget\Type\AuthorizedWidget;
use App\Widget\Type\CompoundRow;
use App\Widget\Type\UserWidget;
use App\Widget\WidgetContainerInterface;
use App\Widget\WidgetException;
use App\Widget\WidgetService;
@@ -31,15 +32,15 @@ class DashboardController extends AbstractController
/**
* @var EventDispatcherInterface
*/
protected $eventDispatcher;
private $eventDispatcher;
/**
* @var WidgetService
*/
protected $widgets;
private $widgets;
/**
* @var array
*/
protected $dashboard;
private $dashboard;
/**
* @param EventDispatcherInterface $dispatcher
@@ -58,8 +59,9 @@ class DashboardController extends AbstractController
*/
public function indexAction()
{
$event = new DashboardEvent($this->getUser());
$user = $this->getUser();
$event = new DashboardEvent($user);
foreach ($this->dashboard as $widgetRow) {
if (empty($widgetRow['widgets'])) {
continue;
@@ -110,6 +112,10 @@ class DashboardController extends AbstractController
$add = $tmp;
}
if ($widget instanceof UserWidget) {
$widget->setUser($user);
}
if ($add) {
$row->addWidget($widget);
}