From: Raphaƫl Gertz Date: Sat, 2 Nov 2024 03:54:54 +0000 (+0100) Subject: Add albums creation X-Git-Tag: 0.0.6~8 X-Git-Url: https://git.rapsys.eu/treebundle/commitdiff_plain/26306be2dd44ed3b972f1a0fd2d91b9227a3116b?ds=sidebyside Add albums creation --- 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(); }