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;
/**
* 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());
}
* {@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();
}