/** * 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); } } }
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); } } }