performance improvements (#2329)

* remove work from constructor
* refactor twig extensions
* upgrade theme
* replace sub-request with direct template rendering
This commit is contained in:
Kevin Papst
2021-02-20 23:52:01 +01:00
committed by GitHub
parent 9eb25c412e
commit 607d09aefb
40 changed files with 992 additions and 1092 deletions

View File

@@ -31,17 +31,30 @@ class WidgetRepository
/**
* @var array
*/
private $definitions = [];
private $definitions;
/**
* @var array
*/
private $customDefinition;
public function __construct(TimesheetRepository $repository, array $widgets)
{
$this->repository = $repository;
$this->definitions = array_merge($this->getDefaultWidgets(), $widgets);
$this->customDefinition = $widgets;
}
private function getDefinedWidgets(): array
{
if (null === $this->definitions) {
$this->definitions = array_merge($this->getDefaultWidgets(), $this->customDefinition);
}
return $this->definitions;
}
public function has(string $id): bool
{
return isset($this->definitions[$id]) || isset($this->widgets[$id]);
return isset($this->getDefinedWidgets()[$id]) || isset($this->widgets[$id]);
}
public function registerWidget(WidgetInterface $widget): WidgetRepository
@@ -64,7 +77,7 @@ class WidgetRepository
}
// this code should ONLY be reached for internal (pre-registered) widgets
$this->registerWidget($this->create($id, $this->definitions[$id]));
$this->registerWidget($this->create($id, $this->getDefinedWidgets()[$id]));
return $this->widgets[$id];
}