Don't implement ContainerAwareInterface on fixtures

pull/5329/head
Angel Fernando Quiroz Campos 8 months ago
parent bfb318e040
commit cd17876d85
  1. 11
      src/CoreBundle/DataFixtures/AccessGroupFixtures.php
  2. 14
      src/CoreBundle/DataFixtures/AccessUserFixtures.php
  3. 15
      src/CoreBundle/DataFixtures/AccessUserUrlFixtures.php
  4. 14
      src/CoreBundle/DataFixtures/PageFixtures.php
  5. 9
      src/CoreBundle/DataFixtures/TicketFixtures.php

@ -9,20 +9,13 @@ namespace Chamilo\CoreBundle\DataFixtures;
use Chamilo\CoreBundle\Repository\GroupRepository;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class AccessGroupFixtures extends Fixture implements ContainerAwareInterface
class AccessGroupFixtures extends Fixture
{
public function __construct(
private GroupRepository $groupRepository
private readonly GroupRepository $groupRepository
) {}
public function setContainer(?ContainerInterface $container = null): void
{
$this->groupRepository = $container->get(GroupRepository::class);
}
public function load(ObjectManager $manager): void
{
$this->groupRepository->createDefaultGroups($this);

@ -11,26 +11,18 @@ use Chamilo\CoreBundle\Repository\Node\UserRepository;
use Chamilo\CoreBundle\Tool\ToolChain;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class AccessUserFixtures extends Fixture implements ContainerAwareInterface
class AccessUserFixtures extends Fixture
{
public const ADMIN_USER_REFERENCE = 'admin';
public const ANON_USER_REFERENCE = 'anon';
public const ACCESS_URL_REFERENCE = 'accessUrl';
public function __construct(
private ToolChain $toolChain,
private UserRepository $userRepository
private readonly ToolChain $toolChain,
private readonly UserRepository $userRepository
) {}
public function setContainer(?ContainerInterface $container = null): void
{
$this->toolChain = $container->get(ToolChain::class);
$this->userRepository = $container->get(UserRepository::class);
}
public function load(ObjectManager $manager): void
{
$timezone = 'Europe\Paris';

@ -8,28 +8,19 @@ namespace Chamilo\CoreBundle\DataFixtures;
use Chamilo\CoreBundle\Entity\AccessUrl;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\ServiceHelper\ContainerHelper;
use Chamilo\CoreBundle\Settings\SettingsManager;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
class AccessUserUrlFixtures extends Fixture implements ContainerAwareInterface
class AccessUserUrlFixtures extends Fixture
{
public function __construct(
private TokenStorageInterface $tokenStorage,
private SettingsManager $settingsManager,
private readonly TokenStorageInterface $tokenStorage,
private readonly SettingsManager $settingsManager,
) {}
public function setContainer(?ContainerInterface $container = null): void
{
$this->tokenStorage = $container->get(ContainerHelper::class)->getTokenStorage();
$this->settingsManager = $container->get(SettingsManager::class);
}
public function load(ObjectManager $manager): void
{
/** @var User $admin */

@ -10,23 +10,15 @@ use Chamilo\CoreBundle\Component\Utils\CreateDefaultPages;
use Chamilo\CoreBundle\Entity\User;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class PageFixtures extends Fixture implements ContainerAwareInterface
class PageFixtures extends Fixture
{
public function __construct(
private CreateDefaultPages $createDefaultPages,
private TranslatorInterface $translator,
private readonly CreateDefaultPages $createDefaultPages,
private readonly TranslatorInterface $translator,
) {}
public function setContainer(?ContainerInterface $container = null): void
{
$this->createDefaultPages = $container->get(CreateDefaultPages::class);
$this->translator = $container->get('translator');
}
public function load(ObjectManager $manager): void
{
/** @var User $admin */

@ -12,22 +12,15 @@ use Chamilo\CoreBundle\Entity\TicketProject;
use Chamilo\CoreBundle\Entity\TicketStatus;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use TicketManager;
class TicketFixtures extends Fixture implements ContainerAwareInterface
class TicketFixtures extends Fixture
{
public function __construct(
private TranslatorInterface $translator,
) {}
public function setContainer(?ContainerInterface $container = null): void
{
$this->translator = $container->get('translator');
}
public function load(ObjectManager $manager): void
{
$adminId = 1;

Loading…
Cancel
Save