sulu / SuluThemeBundle

MIT License
18 stars 15 forks source link

When using the "Theme Specific Controllers" feature the correct controller is not being used. #10

Closed josgerrits closed 4 months ago

josgerrits commented 5 years ago
Q A
Bug? yes
New Feature? no
Bundle Version 1.3
Sulu Version 1.6.22
Browser Version Any browser

Actual Behavior

When using the "Theme Specific Controllers" feature the correct controller is not being used based on the webspace theme.

Expected Behavior

When using the "Theme Specific Controllers" feature the correct controller is being used based on the webspace theme.

Steps to Reproduce

I created a new project from scratch with just the following setup:

Webspace 1:

<name>my-project.com</name>
<key>my-project</key>
<theme>default</theme>

Webspace 2:

<name>other-project.com</name>
<key>other-project</key>
<theme>your-new-shiny-theme</theme>

Config.yml:

liip_theme:
  themes: ["default", "your-new-shiny-theme"]
  active_theme: "default"
  load_controllers: false
  theme_specific_controllers: true

Routing.yml:

my_route:
  path: /x/y
  defaults:
    _controller: AppBundle:Default:index
    theme_controllers:
      default: AppBundle:Default:index
      your-new-shiny-theme: AppBundle:YourShinyNewTheme:index

AbstractKernel:

new \AppBundle\AppBundle(),
new Sulu\Bundle\ThemeBundle\SuluThemeBundle(),
new Liip\ThemeBundle\LiipThemeBundle(),

DefaultController:

class DefaultController extends Controller
{
   public function indexAction()
   {
       $webspace = $this->get('sulu_core.webspace.request_analyzer')->getWebspace();
       die($webspace->getTheme());
   }
}

YourNewShinyThemeController:

class YourNewShinyThemeController extends Controller
{
   public function indexAction()
   {
       die('YourNewShinyThemeController');
   }
}

The result is that i will always end up in the DefaultController. However, the “die($webspace->getTheme());” prints the text: “your-new-shiny-theme”.

Possible Solutions

As @alexander-schranz mentioned in the slack channel: maybe there is a problem with kernel.request priority: https://github.com/sulu/SuluThemeBundle/blob/1.3.2/Resources/config/website.xml#L11

alexander-schranz commented 4 months ago

Closing this as the bundle is not longer based on the liip theme bundle.