Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[project-base] ErrorController uses environment from DIC parameter #1389

Merged
merged 3 commits into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,30 @@ class ErrorController extends FrontBaseController
*/
private $domain;

/**
* @var string
*/
private $environment;

/**
* @param \Shopsys\FrameworkBundle\Component\Error\ExceptionController $exceptionController
* @param \Shopsys\FrameworkBundle\Component\Error\ExceptionListener $exceptionListener
* @param \Shopsys\FrameworkBundle\Component\Error\ErrorPagesFacade $errorPagesFacade
* @param \Shopsys\FrameworkBundle\Component\Domain\Domain $domain
* @param string $environment
*/
public function __construct(
ExceptionController $exceptionController,
ExceptionListener $exceptionListener,
ErrorPagesFacade $errorPagesFacade,
Domain $domain
Domain $domain,
string $environment
) {
$this->exceptionController = $exceptionController;
$this->exceptionListener = $exceptionListener;
$this->errorPagesFacade = $errorPagesFacade;
$this->domain = $domain;
$this->environment = $environment;
}

/**
Expand Down Expand Up @@ -186,7 +194,7 @@ private function createUnableToResolveDomainResponse(Request $request): Response
$url = $request->getSchemeAndHttpHost() . $request->getBasePath();
$content = sprintf("You are trying to access an unknown domain '%s'.", $url);

if (EnvironmentType::TEST === Environment::getEnvironment(false)) {
if ($this->environment === EnvironmentType::TEST) {
$overwriteDomainUrl = $this->getParameter('overwrite_domain_url');
$content .= sprintf(" TEST environment is active, current domain url is '%s'.", $overwriteDomainUrl);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,7 @@ services:
Shopsys\ShopBundle\Model\AdvancedSearch\ProductAdvancedSearchConfig: ~

Shopsys\FrameworkBundle\Model\AdvancedSearch\ProductAdvancedSearchConfig: '@Shopsys\ShopBundle\Model\AdvancedSearch\ProductAdvancedSearchConfig'

Shopsys\ShopBundle\Controller\Front\ErrorController:
arguments:
$environment: '%kernel.environment%'
50 changes: 50 additions & 0 deletions upgrade/UPGRADE-v7.3.3-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,53 @@ This guide contains instructions to upgrade from version v7.3.2 to v7.3.3-dev.

**Before you start, don't forget to take a look at [general instructions](https://github.com/shopsys/shopsys/blob/7.3/UPGRADE.md) about upgrading.**
There you can find links to upgrade notes for other versions too.

## [shopsys/framework]

### Application
- use Environment from DIC parameter in ErrorController ([#1389](https://github.com/shopsys/shopsys/pull/1389))
- change your `services.yml` to inject `%kernel.environment%` to your `Shopsys\ShopBundle\Controller\Front\ErrorController`
```diff
+ Shopsys\ShopBundle\Controller\Front\ErrorController:
+ arguments:
+ $environment: '%kernel.environment%'
```
- change `Shopsys\ShopBundle\Controller\Front\ErrorController` to use injected environment instead of `Environment::getEnvironment(false)`
```diff
+ /**
+ * @var string
+ */
+ private $environment;

/**
* @param \Shopsys\FrameworkBundle\Component\Error\ExceptionController $exceptionController
* @param \Shopsys\FrameworkBundle\Component\Error\ExceptionListener $exceptionListener
* @param \Shopsys\FrameworkBundle\Component\Error\ErrorPagesFacade $errorPagesFacade
* @param \Shopsys\FrameworkBundle\Component\Domain\Domain $domain
+ * @param string $environment
*/
public function __construct(
ExceptionController $exceptionController,
ExceptionListener $exceptionListener,
ErrorPagesFacade $errorPagesFacade,
- Domain $domain
+ Domain $domain,
+ string $environment
) {
$this->exceptionController = $exceptionController;
$this->exceptionListener = $exceptionListener;
$this->errorPagesFacade = $errorPagesFacade;
$this->domain = $domain;
+ $this->environment = $environment;
}

//...

private function createUnableToResolveDomainResponse(Request $request): Response
{
$url = $request->getSchemeAndHttpHost() . $request->getBasePath();
$content = sprintf("You are trying to access an unknown domain '%s'.", $url);

- if (EnvironmentType::TEST === Environment::getEnvironment(false)) {
+ if ($this->environment === EnvironmentType::TEST) {
```