Skip to content

Commit

Permalink
Merge pull request #22 from vluzrmos/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
vluzrmos authored Mar 11, 2017
2 parents 6d66acc + 99b8f63 commit 4f2152f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
"config":{
"preferred-install": "dist"
},
"minimum-stability": "dev"
"minimum-stability": "dev",
"prefer-stable": true
}
17 changes: 12 additions & 5 deletions src/LanguageDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
namespace Vluzrmos\LanguageDetector;

use Closure;
use Symfony\Component\Translation\TranslatorInterface as Translator;
use Illuminate\Contracts\Translation\Translator as IlluminateTranslator;
use Symfony\Component\Translation\TranslatorInterface as SymfonyTranslator;
use Vluzrmos\LanguageDetector\Contracts\DetectorDriverInterface as Driver;
use Vluzrmos\LanguageDetector\Contracts\LanguageDetectorInterface;
use Vluzrmos\LanguageDetector\Contracts\ShouldPrefixRoutesInterface as ShouldPrefixRoute;
Expand All @@ -15,7 +16,7 @@ class LanguageDetector implements LanguageDetectorInterface
{
/**
* Translator instance.
* @var Translator
* @var SymfonyTranslator|IlluminateTranslator
*/
protected $translator;

Expand All @@ -37,11 +38,15 @@ class LanguageDetector implements LanguageDetectorInterface
protected $cookie;

/**
* @param Translator $translator
* @param SymfonyTranslator|IlluminateTranslator $translator
* @param Driver $driver
*/
public function __construct(Translator $translator, Driver $driver = null)
public function __construct($translator, Driver $driver = null)
{
if (!$translator instanceof SymfonyTranslator && !$translator instanceof IlluminateTranslator) {
throw new \InvalidArgumentException("Translator must implement the 'Symfony\\Component\\Translation\\TranslatorInterface' or 'Illuminate\\Contracts\\Translation\\Translator' interface.");
}

$this->translator = $translator;
$this->driver = $driver;
}
Expand Down Expand Up @@ -142,7 +147,9 @@ public function apply($locale)
{
$this->translator->setLocale($locale);

$this->addCookieToQueue($locale);
if (!$this->getLanguageFromCookie()) {
$this->addCookieToQueue($locale);
}

$this->applyCallbacks($locale);
}
Expand Down

0 comments on commit 4f2152f

Please sign in to comment.