diff --git a/bundle/Controller/FullViewController.php b/bundle/Controller/FullViewController.php index 0141447f..7a000b8d 100644 --- a/bundle/Controller/FullViewController.php +++ b/bundle/Controller/FullViewController.php @@ -45,7 +45,7 @@ public function viewNgCategory(Request $request, ContentView $view, array $param $location = $content->mainLocation; } - $redirectHelper = new RedirectHelper($this->router); + $redirectHelper = new RedirectHelper($this->router, $this->getSite()); $response = $redirectHelper->checkRedirect($location); if ($response instanceof Response) { @@ -120,7 +120,7 @@ public function viewNgLandingPage(ContentView $view) $location = $view->getSiteContent()->mainLocation; } - $redirectHelper = new RedirectHelper($this->router); + $redirectHelper = new RedirectHelper($this->router, $this->getSite()); $response = $redirectHelper->checkRedirect($location); if ($response instanceof Response) { diff --git a/bundle/Helper/RedirectHelper.php b/bundle/Helper/RedirectHelper.php index 5b32a802..d02c1403 100644 --- a/bundle/Helper/RedirectHelper.php +++ b/bundle/Helper/RedirectHelper.php @@ -5,6 +5,7 @@ namespace Netgen\Bundle\SiteBundle\Helper; use eZ\Publish\Core\FieldType\Url\Value as UrlValue; +use Netgen\EzPlatformSiteApi\API\Site; use Netgen\EzPlatformSiteApi\API\Values\Content; use Netgen\EzPlatformSiteApi\API\Values\Location; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -20,9 +21,15 @@ class RedirectHelper */ protected $router; - public function __construct(RouterInterface $router) + /** + * @var \Netgen\EzPlatformSiteApi\API\Site + */ + protected $site; + + public function __construct(RouterInterface $router, Site $site) { $this->router = $router; + $this->site = $site; } /** @@ -62,4 +69,14 @@ public function checkRedirect(Location $location): ?Response return null; } + + /** + * Returns the root location object for current siteaccess configuration. + */ + protected function getRootLocation(): Location + { + return $this->site->getLoadService()->loadLocation( + $this->site->getSettings()->rootLocationId + ); + } } diff --git a/bundle/Resources/config/services.yml b/bundle/Resources/config/services.yml index b47b3ec5..66e2f2c7 100644 --- a/bundle/Resources/config/services.yml +++ b/bundle/Resources/config/services.yml @@ -154,6 +154,7 @@ services: public: false arguments: - "@router" + - "@netgen.ezplatform_site.site" ngsite.repository.nguser_setting: class: Doctrine\ORM\EntityRepository