Skip to content

Commit

Permalink
Fix parameters service for Symfony 6
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Apr 19, 2022
1 parent 367a014 commit 0c2c50c
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Bundle/Controller/Parameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,24 @@
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpKernel\Kernel;

if (Kernel::MAJOR_VERSION === 5) {
if (Kernel::MAJOR_VERSION === 6) {
class Parameters extends ParameterBag
{
/**
* @param mixed $default
*/
public function get(string $key, $default = null): mixed
{
$result = parent::get($key, $default);

if (null === $result && $default !== null && $this->has($key)) {
$result = $default;
}

return $result;
}
}
} elseif (Kernel::MAJOR_VERSION === 5) {
class Parameters extends ParameterBag
{
/**
Expand Down

0 comments on commit 0c2c50c

Please sign in to comment.