]> Raphaƫl G. Git Repositories - treebundle/blobdiff - Fixture/TreeFixture.php
Version 0.0.8
[treebundle] / Fixture / TreeFixture.php
index 8ea1b4b0677babca991fed2602b1669e1bdbc24e..0d32d9108f59b7d6ca7481b922b041d20eb619d5 100644 (file)
@@ -14,6 +14,8 @@ namespace Rapsys\TreeBundle\Fixture;
 use Doctrine\Bundle\FixturesBundle\Fixture;
 use Doctrine\Persistence\ObjectManager;
 
 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;
 use Rapsys\TreeBundle\RapsysTreeBundle;
 
 use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -25,12 +27,12 @@ class TreeFixture extends Fixture {
        /**
         * Config array
         */
        /**
         * Config array
         */
-       protected array $config;
+       private array $config;
 
        /**
         * Air fixtures constructor
         */
 
        /**
         * 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());
        }
                //Retrieve config
                $this->config = $container->getParameter(RapsysTreeBundle::getAlias());
        }
@@ -39,6 +41,19 @@ class TreeFixture extends Fixture {
         * {@inheritDoc}
         */
        public function load(ObjectManager $manager) {
         * {@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();
        }
                //Flush to get the ids
                $manager->flush();
        }