コード例 #1
0
 /**
  * Sets the repository request default locale
  *
  * @param ContainerInterface|null $container
  * 
  * @throws \InvalidArgumentException if repository is not an instance of TranslatableRepository
  */
 public function setRepositoryLocale($container)
 {
     if (null !== $container) {
         if (!$this->repository instanceof TranslatableRepository) {
             throw new \InvalidArgumentException('A TranslatableManager needs to be linked with a TranslatableRepository to sets default locale.');
         }
         if ($container->isScopeActive('request')) {
             $locale = $container->get('request')->getLocale();
             $this->repository->setDefaultLocale($locale);
         }
     }
 }
コード例 #2
0
 public function processRepositoryLocale()
 {
     if (null !== $this->container) {
         if (!$this->repository instanceof \SKCMS\CoreBundle\Repository\TranslatableRepository) {
             dump($this->repository);
             die;
             throw new \InvalidArgumentException('A TranslatableManager needs to be linked with a TranslatableRepository to sets default locale.');
         }
         if ($this->container->isScopeActive('request')) {
             //                die('locale'. $this->container->get('request')->getLocale());
             $locale = $this->container->get('request')->getLocale();
             $this->repository->setDefaultLocale($locale);
         }
     }
 }