Skip to content

Commit

Permalink
Add missing dependency on RedirectHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
emodric committed Nov 6, 2020
1 parent 37ec222 commit 8697f48
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bundle/Controller/FullViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
19 changes: 18 additions & 1 deletion bundle/Helper/RedirectHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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
);
}
}
1 change: 1 addition & 0 deletions bundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ services:
public: false
arguments:
- "@router"
- "@netgen.ezplatform_site.site"

ngsite.repository.nguser_setting:
class: Doctrine\ORM\EntityRepository
Expand Down

0 comments on commit 8697f48

Please sign in to comment.