vendor/theofidry/alice-data-fixtures/src/Loader/SimpleLoader.php line 51

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Fidry\AliceDataFixtures package.
  4. *
  5. * (c) Théo FIDRY <theo.fidry@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. declare(strict_types=1);
  11. namespace Fidry\AliceDataFixtures\Loader;
  12. use Fidry\AliceDataFixtures\LoaderInterface;
  13. use Fidry\AliceDataFixtures\Persistence\PurgeMode;
  14. use JetBrains\PhpStorm\Pure;
  15. use Nelmio\Alice\FilesLoaderInterface;
  16. use Nelmio\Alice\IsAServiceTrait;
  17. use Psr\Log\LoggerInterface;
  18. use Psr\Log\NullLogger;
  19. /**
  20. * Minimalistic loader implementation.
  21. *
  22. * @author Baldur Rensch <brensch@gmail.com>
  23. * @author Théo FIDRY <theo.fidry@gmail.com>
  24. *
  25. * @final
  26. */
  27. /*final*/ class SimpleLoader implements LoaderInterface
  28. {
  29. use IsAServiceTrait;
  30. private FilesLoaderInterface $filesLoader;
  31. private LoggerInterface $logger;
  32. #[Pure]
  33. public function __construct(FilesLoaderInterface $fileLoader, LoggerInterface $logger = null)
  34. {
  35. $this->filesLoader = $fileLoader;
  36. $this->logger = $logger ?? new NullLogger();
  37. }
  38. /**
  39. * Loads each file one after another.
  40. *
  41. * {@inheritdoc}
  42. */
  43. public function load(array $fixturesFiles, array $parameters = [], array $objects = [], PurgeMode $purgeMode = null): array
  44. {
  45. $this->logger->info('Loading fixtures.');
  46. return $this->filesLoader->loadFiles($fixturesFiles, $parameters, $objects)->getObjects();
  47. }
  48. }