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

Commit

Permalink
Fix cache issue by caching TL_CSS and TL_JAVASCRIPT when running it t…
Browse files Browse the repository at this point in the history
…he first time.
  • Loading branch information
dmolineus committed Nov 18, 2016
1 parent 37a925e commit c40af4c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/Bit3/Contao/ThemePlus/ThemePlus.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ class ThemePlus
*/
private static $instance = null;

/**
* @var array
*/
private $contaoCssFiles = array();

/**
* @var array
*/
private $contaoJavascriptFiles = array();

/**
* Get the singleton instance.
Expand Down Expand Up @@ -950,6 +959,17 @@ protected function parseStylesheets(\LayoutModel $layout, array &$sr)
$GLOBALS['TL_FRAMEWORK_CSS'] = array();

// Add the internal style sheets
if (!empty($this->contaoCssFiles) && is_array($this->contaoCssFiles)) {
$this->addAssetsToCollectionFromArray(
$this->contaoCssFiles,
'css',
true,
$collection,
$stylesheets,
$defaultFilters
);
}

if (is_array($GLOBALS['TL_CSS']) && !empty($GLOBALS['TL_CSS'])) {
$this->addAssetsToCollectionFromArray(
$GLOBALS['TL_CSS'],
Expand All @@ -960,6 +980,7 @@ protected function parseStylesheets(\LayoutModel $layout, array &$sr)
$defaultFilters
);
}
$this->contaoCssFiles = $GLOBALS['TL_CSS'];
$GLOBALS['TL_CSS'] = array();

// Add the user style sheets
Expand Down Expand Up @@ -1140,6 +1161,18 @@ protected function parseJavaScripts(\LayoutModel $layout, array &$sr)
$collection = new AssetCollection(array(), array(), TL_ROOT);

// Add the internal scripts
if (!empty($this->contaoJavascriptFiles) && is_array($this->contaoJavascriptFiles)) {
$this->addAssetsToCollectionFromArray(
$this->contaoJavascriptFiles,
'js',
false,
$collection,
$javascripts,
$defaultFilters,
$layout->theme_plus_default_javascript_position
);
}

if (is_array($GLOBALS['TL_JAVASCRIPT']) && !empty($GLOBALS['TL_JAVASCRIPT'])) {
$this->addAssetsToCollectionFromArray(
$GLOBALS['TL_JAVASCRIPT'],
Expand All @@ -1151,6 +1184,7 @@ protected function parseJavaScripts(\LayoutModel $layout, array &$sr)
$layout->theme_plus_default_javascript_position
);
}
$this->contaoJavascriptFiles = $GLOBALS['TL_JAVASCRIPT'];
$GLOBALS['TL_JAVASCRIPT'] = array();

// Add layout files
Expand Down

0 comments on commit c40af4c

Please sign in to comment.