X-Git-Url: https://git.rapsys.eu/treebundle/blobdiff_plain/2b6beddb2a7792068e8bdfdcbe00010888ae5e1c..399693f8abe63c3a13d403105bbed688a9274d3d:/Fixture/TreeFixture.php diff --git a/Fixture/TreeFixture.php b/Fixture/TreeFixture.php index 8ea1b4b..0d32d91 100644 --- a/Fixture/TreeFixture.php +++ b/Fixture/TreeFixture.php @@ -14,6 +14,8 @@ namespace Rapsys\TreeBundle\Fixture; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Persistence\ObjectManager; +use Rapsys\PackBundle\Util\SluggerUtil; +use Rapsys\TreeBundle\Entity\Album; use Rapsys\TreeBundle\RapsysTreeBundle; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -25,12 +27,12 @@ class TreeFixture extends Fixture { /** * Config array */ - protected array $config; + private array $config; /** * Air fixtures constructor */ - public function __construct(protected ContainerInterface $container) { + public function __construct(private ContainerInterface $container, private SluggerUtil $slugger) { //Retrieve config $this->config = $container->getParameter(RapsysTreeBundle::getAlias()); } @@ -39,6 +41,19 @@ class TreeFixture extends Fixture { * {@inheritDoc} */ public function load(ObjectManager $manager) { + //Album tree + $albumTree = [ + ]; + + //Create titles + $albums = []; + foreach($albumTree as $albumTitle => $albumPath) { + $album = new Album($albumPath, $this->slugger->slug($albumTitle), $albumTitle); + $manager->persist($album); + $albums[$albumTitle] = $album; + unset($album); + } + //Flush to get the ids $manager->flush(); }