mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Remove ContainerAwareInterface and extend Fixture instead
This commit is contained in:
parent
5cdfee40fb
commit
5e32375dfe
@ -14,21 +14,17 @@ namespace Chill\MainBundle\DataFixtures\ORM;
|
|||||||
use Chill\MainBundle\Doctrine\Model\Point;
|
use Chill\MainBundle\Doctrine\Model\Point;
|
||||||
use Chill\MainBundle\Entity\AddressReference;
|
use Chill\MainBundle\Entity\AddressReference;
|
||||||
use Chill\MainBundle\Entity\PostalCode;
|
use Chill\MainBundle\Entity\PostalCode;
|
||||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load reference addresses into database.
|
* Load reference addresses into database.
|
||||||
*/
|
*/
|
||||||
class LoadAddressReferences extends AbstractFixture implements ContainerAwareInterface, OrderedFixtureInterface
|
class LoadAddressReferences extends Fixture implements OrderedFixtureInterface
|
||||||
{
|
{
|
||||||
protected $faker;
|
protected $faker;
|
||||||
|
|
||||||
private ?ContainerInterface $container = null;
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->faker = \Faker\Factory::create('fr_FR');
|
$this->faker = \Faker\Factory::create('fr_FR');
|
||||||
@ -51,17 +47,10 @@ class LoadAddressReferences extends AbstractFixture implements ContainerAwareInt
|
|||||||
$manager->flush();
|
$manager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setContainer(?ContainerInterface $container = null): void
|
|
||||||
{
|
|
||||||
$this->container = $container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a random reference address.
|
* Create a random reference address.
|
||||||
*
|
|
||||||
* @return AddressReference
|
|
||||||
*/
|
*/
|
||||||
private function getRandomAddressReference(): \Chill\MainBundle\Entity\AddressReference
|
private function getRandomAddressReference(): AddressReference
|
||||||
{
|
{
|
||||||
$ar = new AddressReference();
|
$ar = new AddressReference();
|
||||||
|
|
||||||
@ -81,10 +70,8 @@ class LoadAddressReferences extends AbstractFixture implements ContainerAwareInt
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a random point.
|
* Create a random point.
|
||||||
*
|
|
||||||
* @return Point
|
|
||||||
*/
|
*/
|
||||||
private function getRandomPoint(): \Chill\MainBundle\Doctrine\Model\Point
|
private function getRandomPoint(): Point
|
||||||
{
|
{
|
||||||
$lonBrussels = 4.35243;
|
$lonBrussels = 4.35243;
|
||||||
$latBrussels = 50.84676;
|
$latBrussels = 50.84676;
|
||||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\MainBundle\DataFixtures\ORM;
|
namespace Chill\MainBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
use Chill\MainBundle\Command\LoadCountriesCommand;
|
use Chill\MainBundle\Command\LoadCountriesCommand;
|
||||||
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
@ -21,10 +22,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||||||
/**
|
/**
|
||||||
* Load countries into database.
|
* Load countries into database.
|
||||||
*/
|
*/
|
||||||
class LoadCountries extends AbstractFixture implements ContainerAwareInterface, OrderedFixtureInterface
|
class LoadCountries extends Fixture implements OrderedFixtureInterface
|
||||||
{
|
{
|
||||||
private ?ContainerInterface $container = null;
|
|
||||||
|
|
||||||
public function getOrder(): int
|
public function getOrder(): int
|
||||||
{
|
{
|
||||||
return 20;
|
return 20;
|
||||||
@ -42,9 +41,4 @@ class LoadCountries extends AbstractFixture implements ContainerAwareInterface,
|
|||||||
|
|
||||||
$manager->flush();
|
$manager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setContainer(?ContainerInterface $container = null): void
|
|
||||||
{
|
|
||||||
$this->container = $container;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\MainBundle\DataFixtures\ORM;
|
namespace Chill\MainBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Language;
|
use Chill\MainBundle\Entity\Language;
|
||||||
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
@ -21,14 +22,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||||||
/**
|
/**
|
||||||
* Load languages into database.
|
* Load languages into database.
|
||||||
*/
|
*/
|
||||||
class LoadLanguages extends AbstractFixture implements ContainerAwareInterface, OrderedFixtureInterface
|
class LoadLanguages extends Fixture implements OrderedFixtureInterface
|
||||||
{
|
{
|
||||||
// Array of ancien languages (to exclude)
|
// Array of ancien languages (to exclude)
|
||||||
private array $ancientToExclude = ['ang', 'egy', 'fro', 'goh', 'grc', 'la', 'non', 'peo', 'pro', 'sga',
|
private array $ancientToExclude = ['ang', 'egy', 'fro', 'goh', 'grc', 'la', 'non', 'peo', 'pro', 'sga',
|
||||||
'dum', 'enm', 'frm', 'gmh', 'mga', 'akk', 'phn', 'zxx', 'got', 'und', ];
|
'dum', 'enm', 'frm', 'gmh', 'mga', 'akk', 'phn', 'zxx', 'got', 'und', ];
|
||||||
|
|
||||||
private ?ContainerInterface $container = null;
|
|
||||||
|
|
||||||
// The regional version of language are language with _ in the code
|
// The regional version of language are language with _ in the code
|
||||||
// This array contains regional code to not exclude
|
// This array contains regional code to not exclude
|
||||||
private array $regionalVersionToInclude = ['ro_MD'];
|
private array $regionalVersionToInclude = ['ro_MD'];
|
||||||
@ -57,11 +56,6 @@ class LoadLanguages extends AbstractFixture implements ContainerAwareInterface,
|
|||||||
$manager->flush();
|
$manager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setContainer(?ContainerInterface $container = null): void
|
|
||||||
{
|
|
||||||
$this->container = $container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare names for languages.
|
* Prepare names for languages.
|
||||||
*
|
*
|
||||||
|
@ -12,19 +12,15 @@ declare(strict_types=1);
|
|||||||
namespace Chill\MainBundle\DataFixtures\ORM;
|
namespace Chill\MainBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\LocationType;
|
use Chill\MainBundle\Entity\LocationType;
|
||||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load location types into database.
|
* Load location types into database.
|
||||||
*/
|
*/
|
||||||
class LoadLocationType extends AbstractFixture implements ContainerAwareInterface, OrderedFixtureInterface
|
class LoadLocationType extends Fixture implements OrderedFixtureInterface
|
||||||
{
|
{
|
||||||
private ?ContainerInterface $container = null;
|
|
||||||
|
|
||||||
public function getOrder(): int
|
public function getOrder(): int
|
||||||
{
|
{
|
||||||
return 52;
|
return 52;
|
||||||
@ -64,9 +60,4 @@ class LoadLocationType extends AbstractFixture implements ContainerAwareInterfac
|
|||||||
|
|
||||||
$manager->flush();
|
$manager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setContainer(?ContainerInterface $container = null): void
|
|
||||||
{
|
|
||||||
$this->container = $container;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,10 @@ namespace Chill\MainBundle\DataFixtures\ORM;
|
|||||||
|
|
||||||
use Chill\MainBundle\Entity\GroupCenter;
|
use Chill\MainBundle\Entity\GroupCenter;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
||||||
use Symfony\Component\Security\Core\Encoder\EncoderFactory;
|
use Symfony\Component\Security\Core\Encoder\EncoderFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,7 +25,7 @@ use Symfony\Component\Security\Core\Encoder\EncoderFactory;
|
|||||||
* create a user for each permission_group and center.
|
* create a user for each permission_group and center.
|
||||||
* username and password are identicals.
|
* username and password are identicals.
|
||||||
*/
|
*/
|
||||||
class LoadUsers extends AbstractFixture implements ContainerAwareInterface, OrderedFixtureInterface
|
class LoadUsers extends Fixture implements OrderedFixtureInterface
|
||||||
{
|
{
|
||||||
public static $refs = [
|
public static $refs = [
|
||||||
'center a_social' => [
|
'center a_social' => [
|
||||||
@ -52,9 +51,6 @@ class LoadUsers extends AbstractFixture implements ContainerAwareInterface, Orde
|
|||||||
'centerB_permission_group_social', ],
|
'centerB_permission_group_social', ],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
private ?ContainerInterface $container = null;
|
|
||||||
|
|
||||||
public function getOrder(): int
|
public function getOrder(): int
|
||||||
{
|
{
|
||||||
return 1000;
|
return 1000;
|
||||||
@ -91,13 +87,4 @@ class LoadUsers extends AbstractFixture implements ContainerAwareInterface, Orde
|
|||||||
|
|
||||||
$manager->flush();
|
$manager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setContainer(?ContainerInterface $container = null): void
|
|
||||||
{
|
|
||||||
if (null === $container) {
|
|
||||||
throw new \LogicException('$container should not be null');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->container = $container;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,10 @@ use Chill\PersonBundle\Entity\Person;
|
|||||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||||
use Chill\PersonBundle\Repository\MaritalStatusRepository;
|
use Chill\PersonBundle\Repository\MaritalStatusRepository;
|
||||||
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
||||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
|
||||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
use Faker\Factory;
|
use Faker\Factory;
|
||||||
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Faker\Generator;
|
use Faker\Generator;
|
||||||
use Nelmio\Alice\Loader\NativeLoader;
|
use Nelmio\Alice\Loader\NativeLoader;
|
||||||
use Nelmio\Alice\ObjectSet;
|
use Nelmio\Alice\ObjectSet;
|
||||||
@ -44,7 +44,7 @@ use Symfony\Component\Workflow\Registry;
|
|||||||
/**
|
/**
|
||||||
* Load people into database.
|
* Load people into database.
|
||||||
*/
|
*/
|
||||||
class LoadPeople extends AbstractFixture implements ContainerAwareInterface, OrderedFixtureInterface
|
class LoadPeople extends Fixture implements OrderedFixtureInterface
|
||||||
{
|
{
|
||||||
use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user