Skip to content

Commit

Permalink
Merge pull request #42 from contao-themes-net/fix/web-folder
Browse files Browse the repository at this point in the history
fix Symfony 5 public entry point
  • Loading branch information
seibtph authored Mar 9, 2022
2 parents 1663a1b + 45f2246 commit 3acaeac
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 17 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog

## [1.8.1](https://github.com/contao-themes-net/nature-theme-bundle/tree/1.8.1) – 2022-02-18
## [1.8.1](https://github.com/contao-themes-net/nature-theme-bundle/tree/1.8.1) – 2022-03-09

- [fix] add support for Symfony 5 public entry point
- [fix] update fe_page template

## [1.8.0](https://github.com/contao-themes-net/nature-theme-bundle/tree/1.8.0) – 2022-02-15
Expand Down
14 changes: 10 additions & 4 deletions src/Module/NatureThemeSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace ContaoThemesNet\NatureThemeBundle\Module;

use ContaoThemesNet\NatureThemeBundle\ThemeUtils;

class NatureThemeSetup extends \BackendModule
{
const VERSION = '1.8.1';
Expand All @@ -15,12 +17,16 @@ protected function compile()
{
switch (\Input::get('act')) {
case 'syncFolder':
$path = TL_ROOT . '/web/bundles/contaothemesnetnaturetheme';
$path = sprintf('%s/%s/bundles/contaothemesnetnaturetheme',
ThemeUtils::getRootDir(),
ThemeUtils::getWebDir()
);

if(!file_exists("files/naturetheme")) {
new \Folder("files/naturetheme");
}
$this->getFiles($path);
$this->getSqlFiles($path = TL_ROOT . "/vendor/contao-themes-net/nature-theme-bundle/src/templates");
$this->getSqlFiles(ThemeUtils::getRootDir()."/vendor/contao-themes-net/nature-theme-bundle/src/templates");
$this->Template->message = true;
$this->Template->version = NatureThemeSetup::VERSION;
break;
Expand All @@ -42,8 +48,8 @@ protected function getFiles($path) {
$filesFolder = "files/naturetheme".str_replace("contaothemesnetnaturetheme","",substr($path,$pos))."/".$dir;

if($dir != "_nature_variables.scss" && $dir != "_nature_colors.scss" && $dir != "backend.css" && $dir != "nature.scss" && $dir != "nature_win.scss" && $dir != "nature_style.scss" && $dir != "maklermodul.scss" && $dir != "fonts.scss") {
if(!file_exists(TL_ROOT."/".$filesFolder)) {
$objFile = new \File("web/bundles/".substr($path,$pos)."/".$dir, true);
if(!file_exists(ThemeUtils::getRootDir()."/".$filesFolder)) {
$objFile = new \File(ThemeUtils::getWebDir()."/bundles/".substr($path,$pos)."/".$dir, true);
$objFile->copyTo($filesFolder);
}
}
Expand Down
13 changes: 1 addition & 12 deletions src/Resources/contao/templates/frontend/fe_page_nature.html5
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,7 @@

<?= $this->stylesheets ?>

<link rel="stylesheet" type="text/css" media="all" href="<?php
// add stylesheets
$combiner = new Combiner();
$combiner->add('bundles/contaothemesnetnaturetheme/fonts/fontawesome/css/all.min.css');

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$combiner->add('bundles/contaothemesnetnaturetheme/scss/nature_win.scss');
} else {
$combiner->add('bundles/contaothemesnetnaturetheme/scss/nature.scss');
}

echo $combiner->getCombinedFile(); ?>">
<link rel="stylesheet" type="text/css" media="all" href="<?= ContaoThemesNet\NatureThemeBundle\ThemeUtils::getCombinedStylesheet(); // nature theme css optimization ?>">

<?= $this->head ?>

Expand Down
34 changes: 34 additions & 0 deletions src/ThemeUtils.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace ContaoThemesNet\NatureThemeBundle;

use Contao\Combiner;
use Contao\File;
use Contao\System;
use Contao\StringUtil;

class ThemeUtils
{
public static function getRootDir() {
return System::getContainer()->getParameter('kernel.project_dir');
}

public static function getWebDir() {
return StringUtil::stripRootDir(System::getContainer()->getParameter('contao.web_dir'));
}

public static function getCombinedStylesheet() {

// add stylesheets
$combiner = new Combiner();
$combiner->add('bundles/contaothemesnetnaturetheme/fonts/fontawesome/css/all.min.css');

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$combiner->add('bundles/contaothemesnetnaturetheme/scss/nature_win.scss');
} else {
$combiner->add('bundles/contaothemesnetnaturetheme/scss/nature.scss');
}

return $combiner->getCombinedFile();
}
}

0 comments on commit 3acaeac

Please sign in to comment.