chamilo/chamilo-lms

View on GitHub
src/CoreBundle/DataFixtures/PageFixtures.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

declare(strict_types=1);

/* For licensing terms, see /license.txt */

namespace Chamilo\CoreBundle\DataFixtures;

use Chamilo\CoreBundle\Component\Utils\CreateDefaultPages;
use Chamilo\CoreBundle\Entity\User;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Symfony\Contracts\Translation\TranslatorInterface;

class PageFixtures extends Fixture
{
    public function __construct(
        private readonly CreateDefaultPages $createDefaultPages,
        private readonly TranslatorInterface $translator,
    ) {}

    public function load(ObjectManager $manager): void
    {
        /** @var User $admin */
        $admin = $this->getReference(AccessUserFixtures::ADMIN_USER_REFERENCE);
        $url = $this->getReference(AccessUserFixtures::ACCESS_URL_REFERENCE);

        $locale = $this->translator->getLocale();
        $this->createDefaultPages->createDefaultPages($admin, $url, $locale);
    }
}