X-Git-Url: https://git.rapsys.eu/treebundle/blobdiff_plain/355ee27765195aa4f8de07da693ec151ceda8346..26306be2dd44ed3b972f1a0fd2d91b9227a3116b:/Fixture/TreeFixture.php?ds=sidebyside 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(); }