]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Factory/RepositoryFactory.php
Add apple-touch-icon 120x120 for outdated iOS
[airbundle] / Factory / RepositoryFactory.php
index 0c754ea1b3394aa52274aef5d72c1b29269c1e14..f64a4fbbc5d72186a5d9734b6c6dea65ea1c09a2 100644 (file)
@@ -26,37 +26,44 @@ final class RepositoryFactory implements RepositoryFactoryInterface {
        /**
         * The list of EntityRepository instances
         *
        /**
         * The list of EntityRepository instances
         *
-        * @var ObjectRepository[]
+        * @var array
         */
         */
-       private $repositoryList = [];
+       private array $repositoryList = [];
 
        /**
         * The list of languages
         *
 
        /**
         * The list of languages
         *
-        * @var string[]
+        * @var array
         */
         */
-       private $languages = [];
+       private array $languages = [];
+
+       /**
+        * The current locale
+        *
+        * @var string
+        */
+       private string $locale;
 
        /**
         * The RouterInterface instance
         *
         * @var RouterInterface
         */
 
        /**
         * The RouterInterface instance
         *
         * @var RouterInterface
         */
-       private $router;
+       private RouterInterface $router;
 
        /**
         * The SluggerUtil instance
         *
         * @var SluggerUtil
         */
 
        /**
         * The SluggerUtil instance
         *
         * @var SluggerUtil
         */
-       private $slugger;
+       private SluggerUtil $slugger;
 
        /**
         * The TranslatorInterface instance
         *
         * @var TranslatorInterface
         */
 
        /**
         * The TranslatorInterface instance
         *
         * @var TranslatorInterface
         */
-       private $translator;
+       private TranslatorInterface $translator;
 
        /**
         * Initializes a new RepositoryFactory instance
 
        /**
         * Initializes a new RepositoryFactory instance
@@ -65,8 +72,9 @@ final class RepositoryFactory implements RepositoryFactoryInterface {
         * @param SluggerUtil $slugger The SluggerUtil instance
         * @param TranslatorInterface $translator The TranslatorInterface instance
         * @param array $languages The languages list
         * @param SluggerUtil $slugger The SluggerUtil instance
         * @param TranslatorInterface $translator The TranslatorInterface instance
         * @param array $languages The languages list
+        * @param string $locale The current locale
         */
         */
-       public function __construct(RouterInterface $router, SluggerUtil $slugger, TranslatorInterface $translator, array $languages) {
+       public function __construct(RouterInterface $router, SluggerUtil $slugger, TranslatorInterface $translator, array $languages, string $locale) {
                //Set router
                $this->router = $router;
 
                //Set router
                $this->router = $router;
 
@@ -78,12 +86,15 @@ final class RepositoryFactory implements RepositoryFactoryInterface {
 
                //Set languages
                $this->languages = $languages;
 
                //Set languages
                $this->languages = $languages;
+
+               //Set locale
+               $this->locale = $locale;
        }
 
        /**
         * {@inheritdoc}
         */
        }
 
        /**
         * {@inheritdoc}
         */
-       public function getRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository {
+       public function getRepository(EntityManagerInterface $entityManager, mixed $entityName): ObjectRepository {
                //Set repository hash
                $repositoryHash = $entityManager->getClassMetadata($entityName)->getName() . spl_object_hash($entityManager);
 
                //Set repository hash
                $repositoryHash = $entityManager->getClassMetadata($entityName)->getName() . spl_object_hash($entityManager);
 
@@ -111,7 +122,7 @@ final class RepositoryFactory implements RepositoryFactoryInterface {
                $repositoryClass = $metadata->customRepositoryClassName ?: $entityManager->getConfiguration()->getDefaultRepositoryClassName();
 
                //Return repository class instance
                $repositoryClass = $metadata->customRepositoryClassName ?: $entityManager->getConfiguration()->getDefaultRepositoryClassName();
 
                //Return repository class instance
-               //XXX: router, slugger, translator and languages arguments will be ignored by default
-               return new $repositoryClass($entityManager, $metadata, $this->router, $this->slugger, $this->translator, $this->languages);
+               //XXX: router, slugger, translator, languages and locale arguments will be ignored by default
+               return new $repositoryClass($entityManager, $metadata, $this->router, $this->slugger, $this->translator, $this->languages, $this->locale);
        }
 }
        }
 }