From: Raphaƫl Gertz Date: Thu, 14 Nov 2024 08:03:53 +0000 (+0100) Subject: Add rapsyspack.file_util helper X-Git-Tag: 0.0.8~1 X-Git-Url: https://git.rapsys.eu/treebundle/commitdiff_plain/ad8124dcef6a76e6b458c44622b6285fa522ac01?ds=sidebyside Add rapsyspack.file_util helper --- diff --git a/Factory.php b/Factory.php index 1856f3f..865dab0 100644 --- a/Factory.php +++ b/Factory.php @@ -17,6 +17,7 @@ use Doctrine\Persistence\ObjectRepository; use Psr\Container\ContainerInterface; +use Rapsys\PackBundle\Util\FileUtil; use Rapsys\PackBundle\Util\SluggerUtil; use Rapsys\UserBundle\Factory as BaseFactory; @@ -27,11 +28,12 @@ use Symfony\Contracts\Translation\TranslatorInterface; /** * This factory is used to create default repository objects for entities at runtime. */ -final class Factory extends BaseFactory { +class Factory extends BaseFactory { /** * Initializes a new RepositoryFactory instance * * @param ContainerInterface $container The container instance + * @param FileUtil $file The FileUtil instance * @param RequestStack $request The request stack * @param RouterInterface $router The router instance * @param SluggerUtil $slugger The SluggerUtil instance @@ -39,7 +41,7 @@ final class Factory extends BaseFactory { * @param string $locale The current locale * @param array $languages The languages list */ - public function __construct(private ContainerInterface $container, private RequestStack $request, private RouterInterface $router, private SluggerUtil $slugger, private TranslatorInterface $translator, private string $locale, private array $languages) { + public function __construct(protected ContainerInterface $container, protected FileUtil $file, protected RequestStack $request, protected RouterInterface $router, protected SluggerUtil $slugger, protected TranslatorInterface $translator, protected string $locale, protected array $languages) { } /** @@ -61,6 +63,6 @@ final class Factory extends BaseFactory { //Return repository class instance //XXX: router, slugger, translator, languages and locale arguments will be ignored by default - return new $repositoryClass($entityManager, $metadata, $this->container, $this->router, $this->slugger, $this->translator, $this->locale, $this->languages); + return new $repositoryClass($entityManager, $metadata, $this->container, $this->file, $this->router, $this->slugger, $this->translator, $this->locale, $this->languages); } } diff --git a/Repository.php b/Repository.php index 6caf70d..2198636 100644 --- a/Repository.php +++ b/Repository.php @@ -17,6 +17,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Psr\Container\ContainerInterface; +use Rapsys\PackBundle\Util\FileUtil; use Rapsys\PackBundle\Util\SluggerUtil; use Symfony\Component\Routing\RouterInterface; @@ -48,13 +49,14 @@ class Repository extends EntityRepository { * @param EntityManagerInterface $manager The EntityManagerInterface instance * @param ClassMetadata $class The ClassMetadata instance * @param ContainerInterface $container The container instance + * @param FileUtil $file The FileUtil instance * @param RouterInterface $router The router instance * @param SluggerUtil $slugger The SluggerUtil instance * @param TranslatorInterface $translator The TranslatorInterface instance * @param string $locale The current locale * @param array $languages The languages list */ - public function __construct(protected EntityManagerInterface $manager, protected ClassMetadata $class, protected ContainerInterface $container, protected RouterInterface $router, protected SluggerUtil $slugger, protected TranslatorInterface $translator, protected string $locale, protected array $languages) { + public function __construct(protected EntityManagerInterface $manager, protected ClassMetadata $class, protected ContainerInterface $container, protected FileUtil $file, protected RouterInterface $router, protected SluggerUtil $slugger, protected TranslatorInterface $translator, protected string $locale, protected array $languages) { //Call parent constructor parent::__construct($this->manager, $this->class); diff --git a/Repository/UserRepository.php b/Repository/UserRepository.php index 5244102..73fa3b1 100644 --- a/Repository/UserRepository.php +++ b/Repository/UserRepository.php @@ -16,6 +16,7 @@ use Doctrine\ORM\Mapping\ClassMetadata; use Psr\Container\ContainerInterface; +use Rapsys\PackBundle\Util\FileUtil; use Rapsys\PackBundle\Util\SluggerUtil; use Rapsys\UserBundle\Repository\UserRepository as BaseUserRepository; @@ -30,7 +31,7 @@ class UserRepository extends BaseUserRepository { * {@inheritdoc} * @param array $languages The languages list */ - public function __construct(protected EntityManagerInterface $manager, protected ClassMetadata $class, protected ContainerInterface $container, protected RouterInterface $router, protected SluggerUtil $slugger, protected TranslatorInterface $translator, protected string $locale, protected array $languages) { + public function __construct(protected EntityManagerInterface $manager, protected ClassMetadata $class, protected ContainerInterface $container, protected FileUtil $file, protected RouterInterface $router, protected SluggerUtil $slugger, protected TranslatorInterface $translator, protected string $locale, protected array $languages) { //Call parent constructor parent::__construct($manager, $class, $container, $router, $slugger, $translator, $locale); } diff --git a/config/packages/rapsystree.yaml b/config/packages/rapsystree.yaml index 417dcf1..cffff99 100644 --- a/config/packages/rapsystree.yaml +++ b/config/packages/rapsystree.yaml @@ -156,7 +156,7 @@ services: tags: [ 'controller.service_arguments' ] # Register tree repository factory Rapsys\TreeBundle\Factory: - arguments: [ '@service_container', '@request_stack', '@router', '@rapsyspack.slugger_util', '@translator', '%rapsystree.locale%', '%rapsystree.languages%' ] + arguments: [ '@service_container', '@rapsyspack.file_util', '@request_stack', '@router', '@rapsyspack.slugger_util', '@translator', '%rapsystree.locale%', '%rapsystree.languages%' ] #Register blog fixture Rapsys\TreeBundle\Fixture\TreeFixture: arguments: [ '@service_container', '@rapsyspack.slugger_util' ]