This repository has been archived by the owner on Jan 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compatibility of symfony 4 (#72)
* Add compatibility with symfony 4
- Loading branch information
Showing
6 changed files
with
76 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Lexik\Bundle\MaintenanceBundle\Tests; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Translation\Translator; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\Kernel; | ||
use Symfony\Component\Translation\Formatter\MessageFormatter; | ||
use Symfony\Component\Translation\MessageSelector; | ||
|
||
class TestHelper | ||
{ | ||
public static function getTranslator(ContainerBuilder $container, MessageSelector $messageSelector) | ||
{ | ||
if (Kernel::VERSION_ID < 30300) { | ||
// symfony 2 | ||
$translator = new Translator( | ||
$container, | ||
$messageSelector | ||
); | ||
} elseif (Kernel::VERSION_ID >= 30300 && Kernel::VERSION_ID < 40000) { | ||
// symfony 3 | ||
$translator = new Translator( | ||
$container, | ||
$messageSelector, | ||
'en' | ||
); | ||
} else { | ||
// symfony 4 | ||
$translator = new Translator( | ||
$container, | ||
new MessageFormatter($messageSelector), | ||
'en' | ||
); | ||
} | ||
|
||
return $translator; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters