コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function vote(LocaleContextInterface $context)
 {
     $request = $context->getRequest();
     if (!$request) {
         throw new \Exception(sprintf('Voter "%s" needs Request on context', __CLASS__));
     }
     return $request->getPreferredLanguage($this->supportedLocales);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function vote(LocaleContextInterface $context)
 {
     $request = $context->getRequest();
     if (!$request) {
         throw new \Exception(sprintf('Voter "%s" needs Request on context', __CLASS__));
     }
     $locale = $request->get('_locale');
     if ($locale && $this->suggestLocale($locale)) {
         return $locale;
     }
 }