Skip to content
This repository has been archived by the owner on Oct 20, 2020. It is now read-only.

Commit

Permalink
add array of css/js
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Jul 17, 2018
1 parent 6bcf98d commit 2fb9147
Showing 1 changed file with 43 additions and 8 deletions.
51 changes: 43 additions & 8 deletions lib/Controller/NavigationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,58 @@ public function navigate(): TemplateResponse {
foreach ($widgetFrames as $frame) {
$tmpl = $frame->getWidget()
->getTemplate();
if (!array_key_exists('app', $tmpl)) {
if (!is_array($tmpl) || !array_key_exists('app', $tmpl)) {
continue;
}

if (array_key_exists('css', $tmpl)) {
Util::addStyle($tmpl['app'], $tmpl['css']);
}

if (array_key_exists('js', $tmpl)) {
Util::addScript($tmpl['app'], $tmpl['js']);
}
$this->includeWidgetCss($tmpl);
$this->includeWidgetJs($tmpl);
}

return new TemplateResponse(Application::APP_NAME, 'navigate', []);
}


/**
* @param array $tmpl
*/
private function includeWidgetCss(array $tmpl) {
if (!array_key_exists('css', $tmpl)) {
return;
}

$css = $tmpl['css'];
if (!is_array($css)) {
$css = [$css];
}

foreach ($css as $file) {
Util::addStyle($tmpl['app'], $file);
}

}


/**
* @param array $tmpl
*/
private function includeWidgetJs(array $tmpl) {
if (!array_key_exists('js', $tmpl)) {
return;
}

$js = $tmpl['js'];
if (!is_array($js)) {
$js = [$js];
}

foreach ($js as $file) {
Util::addScript($tmpl['app'], $file);
}

}


/**
* @NoAdminRequired
* @NoSubAdminRequired
Expand Down

0 comments on commit 2fb9147

Please sign in to comment.